On Tue, Dec 19, 2017 at 12:05 PM Chris Hopkins <cbehopk...@gmail.com> wrote:

...

> was slower than:

...

Without more information the conclusion that the optimization is not there
cannot be established. Inspect the real produced machine code. I guess
you'll find that the machine code differs in cache-line alignment only, and
that's the cause of the observed effect.

Even changing whitespace in a program can potentially move the code in the
binary.

> So I assume the Go compiler doesn't try and do this analysis in a Compile
time vs Execution time tradeoff.

I think this kind of DCE was in at the date of the first public release.

> Anyway Hope that is useful to someone. It has certainly changed the way I
will write my (profiled) inner loops.

I don't think that's a good idea. The bug, if any, in the compiler should
be fixed. OTOH, adjusting code to a particular compiler/version/whitespace
will hurt as soon as anything of that changes.

Generally, benchmarking short inner loops is often unreliable enough to
render it unusable.

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to