New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: dip in small struct copy performance in go1.17beta #47074
Comments
Maybe it is not a code bug. If var struct3_1 struct{a, b, c int} is changed to var struct3_1 = struct{a, b, c int}{3, 2, 1} , then the result is constantly about
So it looks like a cpu cache related problem. I don't know whether or not some improvements should be applied to the testing package (I hope it could handle the problem). If not, feel free to close this issue. |
Its not uncommon to see benchmarks improve or regress in performance when unrelated code is added or removed. ANy code change e.g. compiler or linker or user code can effect this. This can be due to caching, branch alignment or if the loop fits into the internal loop buffer of the cpu. There are all kinds of constraints e.g. how many branches are within a specific cacheline window. Maybe there is something that be done to harden benchmarks better (even higher alignment?). To figure out what happens in this case a hardware profile could be made and seeing if any cpu internal stats like branch predictions or cache misses change majorly. |
|
As @martisch points out, benchmarks with tight loops like this can end up being very sensitive to instruction caching and alignment. I'm not sure it's worth dwelling on this too much. Like @martisch says though, if you're interested, you can probably figure out exactly what's wrong with hardware performance counters. The easiest way to do this on Linux is with Linux's perf tool. |
Given that everything's fine on tip and the nature of these kinds of benchmarks, I'm going to close this issue unless there's a more clear indication that something went wrong with the code the compiler produced. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Not for go1.16.5 and tip.
What did you do?
What did you expect to see?
What did you see instead?
It at least one in the
Benchmark_xxx
orBenchmark_yyy
is removed, then the result is normal.Otherwise, the result is double.
The problem doesn't exist in go1.16.5 and tip. I don't know whether or not it is fixed in the go1.17 release branch.
I didn't find the go1.17 release branch in the repo, so I haven't tested it.
The text was updated successfully, but these errors were encountered: