I was wrong.

superdan super at dan.org
Thu Aug 14 09:57:37 PDT 2008


Jb Wrote:

> 
> "superdan" <super at dan.org> wrote in message
> news:g81e1l$18js$1 at digitalmars.com...
> > downs Wrote:
> 
> >> Null: 729908
> >> Naive: 1615314
> >> Speculative for B: 1692860
> >> Speculative for B/C: 1664040
> >
> > the whole premise of speculation is it oils the common path. you have
> > uniform probabilities.
> > what you gain on speculating for B you lose in the extra test when
> > misspeculating on others.
> > so to really test speculation make B like 90% of cases and retry.
> 
> To speculate localy you still have to lookup the class info, compare it to 
> the speculated object type, and then conditionaly branch. You cant avoid a 
> conditional branch, and as it will share the same pattern as the indirect 
> jump, and (in most cases) the same prediction mechanism, neither will be 
> better predicted than the other.

no that's wrong. conditional branch is better speculated than indirect jump. they share no other hardware than the instruction fetching pipe. the mechanism for conditional branch speculation is that stuff is executed in parallel on both branches inside the pipeline. the branch that makes it is committed. the other is retired without getting to write to the register file or memory. indirect jump is a whole different business altogether.

> So the point is that you cant make the common path any faster unless you 
> actualy *inline* the speculated method. In fact if you dont inline you are 
> most probably making the situation worse because you are replacing this...

you are right here tho for the wrong reasons :) yeah speculation is good if there are a few good chunky instructions to eat while speculating. if it's a function call that in turn is just a ret... the results are nothing to write home about. as it's been shown.

processors today are so complicated there's no chance to have relevant synthetic tests. when checking for speed you always must use realistic loads. if method speculation as in here shows nothing on empty functions that's nothing. i've seen much weirder things. tests must be held on 5-6 real benchmarks to be any good. 



More information about the Digitalmars-d mailing list