Repository navigation
testing: benchmarks are context-sensitive #7920
Copy link
Copy link
Closed
Description
josharian
opened on May 1, 2014
Issue body actions
Reactions are currently unavailable
Activity
Can you see if the generated code for the benchmark is the same in both cases? It's possible that what you are seeing is the effect of crossing instruction cache lines in a tight loop. If that is indeed the case there isn't much the compiler or the testing framework can do, except serve as a cautionary tale for authors of microbenchmarks. On the other hand, if the code changes, then there is probably a bug.
Labels changed: added repo-main, release-go1.3maybe.
In that case I don't see what can be done on the Go side. I'd be happy to hear suggestions, but basically this is a microbenchmark of trivial code for which the loop and function call overhead dominate. It is presumably sensitive to the exact code alignment.
Labels changed: added release-none, removed release-go1.3maybe.
Status changed to Unfortunate.
Unrolling 8x here causes the delta to shrink. Instead of 1.08 to 0.81 (-25%), it is 0.81 to 0.74 (-10%). It's hard to be sure that this is attributable directly to the unrolling and not to new code alignment, but it does appear to help. And unrolling is good for reducing benchmark overhead anyway. The question then is whether it's worth the ugliness to do by hand, in the short term.
CL https://golang.org/cl/91850043 mentions this issue.
- locked and limited conversation to collaborators
on Jun 25, 2016