-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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, runtime: optimize comparison of large values with zero #23929
Comments
I would suggest to do small compares inline (up to x bytes, like compares, not sure where the cutoff is currently) and when bigger we can call a special runtime routine isZero(*p, len) or alike as suggested. |
Why aren't non-scalar required zero values ready made in the text segment? |
And for that matter, why not use runtime.zeroVal? isZero will still be more efficient, though. |
zeroVal can be used up to 1024 bytes. However flushing multiple cache lines and loading them with zeros for a zero compare seems wasteful and slow if the zero value is not already loaded. |
Filed #23948 for using runtime.zeroVal. |
See #24416 for large struct optimization. |
Change https://golang.org/cl/186477 mentions this issue: |
Currently this sets up and zeros twenty bytes and then calls memequal. Comparing a large type to zero should be easy; we can then dispatch instead to an optimized runtime routine that doesn't need to actually construct a zero value. (Should handle != as well.)
cc @randall77 @martisch
The text was updated successfully, but these errors were encountered: