Thanks for the prompt replies.

Please read no further, PEBKAC: I was on an old compiler on the machine I 
was running on (I had updated the compiler on my desktop, but clearly not 
the Pi I was testing this on - now re-building with latest).

In truth this was a problem I came across a few weeks ago and meant to post 
about it at the time, but was busy - now clearing my task backlog before 
Christmas prompted this post. So I had to try and reproduce the issue upon 
request. Upon doing so, I actually got the opposite behaviour: that adding 
an if true/if false around code was faster than commenting. This made me 
think that I had something basic wrong!
So yes, I agree that I must be changing things like how the code was 
allocated in the cache and other micro-changes.

I'm going to take this as an I have pushed that algo far enough and I need 
to look for improvements elsewhere when I get to this last few percent 
stage that I was here.

Regards & Apologies

Chris


On Tuesday, 19 December 2017 11:40:36 UTC, Jan Mercl wrote:
>
> On Tue, Dec 19, 2017 at 12:05 PM Chris Hopkins <cbeho...@gmail.com 
> <javascript:>> 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