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: