-
Notifications
You must be signed in to change notification settings - Fork 3.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
exec: fix NaN comparison logic #38881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+ |
Mind blown that this doesn't affect benchmarks too much. Does it affect selection benchmarks? |
Yeah, good point, I should have run that one too. Noticeable drop-off in performance there unfortunately.
|
I figured. I bet if we changed things around to do another pass over the vectors searching for NaNs, things would be different... but I think the effort there is probably too high to justify. You could also imagine doing something similar to nulls/sel array for NaNs, and fast path when you know there's no NaNs at all, but again I don't think it's worth it here. |
Hm, it appears that bors just ignored "r+" from several hours ago :) |
pkg/sql/exec/float.go
Outdated
return 1 | ||
} | ||
if math.IsNaN(a) { | ||
if math.IsNaN(b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could avoid this second check by changing a == b
to be int64(a) == int64(b)
or whatever - aren't the bits of NaN the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thought. I think we would use math.Float64bits
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I was worried this might be slower than the normal float equality check, but it's actually faster! Presumably because the normal one has to do NaN checks.
I added special NaN handling for float comparisons. In SQL, NaNs are treated as less than any other float value. Thankfully I'm not seeing a performance hit when I run our sort benchmarks with float64 values. Fixes cockroachdb#38751 Release note: None
540d2f8
to
9bec27f
Compare
bors r+ |
38767: exec: fix planning of count operator r=yuzefovich a=yuzefovich Previously, when planning a count operator, we would add it to the flow and would ignore any post-operator planning (like projections). Now, this is fixed. Additionally, this commit fixes slicing within projections operators - previously, we would always slice up to BatchSize, but the underlying memory not always has sufficient capacity (for example, count operator uses a batch with a capacity of 1) which would cause an index out of bounds. Fixes: #38752. Release note: None 38881: exec: fix NaN comparison logic r=solongordon a=solongordon I added special NaN handling for float comparisons. In SQL, NaNs are treated as less than any other float value. Thankfully I'm not seeing a performance hit when I run our sort benchmarks with float64 values. Fixes #38751 Release note: None 38891: c-deps: bump rocksdb for macOS build fix r=ajkr a=ajkr Pick up cockroachdb/rocksdb#39 Release note: None Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com> Co-authored-by: Solon Gordon <solon@cockroachlabs.com> Co-authored-by: Andrew Kryczka <andrew.kryczka2@gmail.com>
Build succeeded |
I added special NaN handling for float comparisons. In SQL, NaNs are
treated as less than any other float value.
Thankfully I'm not seeing a performance hit when I run our sort
benchmarks with float64 values.
Fixes #38751
Release note: None