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
performance issue about empty string check with str == ""
in go1.14.6
#40330
Comments
This appears to be something between 1.14.5 and 1.14.6
|
@seankhliao I test go 1.14.5 with OS |
Those benchmarks are not very meaningful. Both are optimized to an empty loop:
The difference in performance might be explained by branch alignment/code position differences due to patches in go1.14. Both run at the same speed of 1 clock cycle per iteration on my machine (darwin/amd64 Intel Ice Lake) with go tip (11f92e9), go1.14.6 and go1.14.5. For others: see if changing the order of the benchmark functions in the source file makes a difference. I do not think there is anything todo or can be improved between the versions as they both generate the same code. |
Closing given that the emitted instructions are the same and it is not consistently reproducible across machines. Feel free to reopen with a new example if there is a measurable change in a more complex benchmark or whole program runtime between sub versions of go1.14 that can be classified as performance regressions. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes, it does
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I run benchmark to test empty string check, the code is :
run benchmark with
go1.14.6
:run it with
go1.10.8
:What did you expect to see?
running benchmark with
go1.14.6
should behavior like go1.10.8.What did you see instead?
but in go1.14.6,
str == ""
is slower thanlen(str) ==0
to check empty string.The text was updated successfully, but these errors were encountered: