Skip to content
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

opt: make floating-point stats calculations precise #115304

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

DrewKimball
Copy link
Collaborator

This patch makes two changes to the floating-point operators in the adjustNullCountsForOuterJoins statistics method:

  1. The results of floating-point subtractions are adjusted to be at least epsilon; this avoids precision errors.
  2. Calculation is avoided entirely when the result is known to be zero. This ensures an exact result in the common case when no adjustment is made to the null count estimate.

This commit also reverts #115287, since the failing tests are now fixed.

Fixes #115278

Release note: None

This patch makes two changes to the floating-point operators in the
`adjustNullCountsForOuterJoins` statistics method:
1. The results of floating-point subtractions are adjusted to be at
   least `epsilon`; this avoids precision errors.
2. Calculation is avoided entirely when the result is known to be
   zero. This ensures an exact result in the common case when no
   adjustment is made to the null count estimate.

This commit also reverts cockroachdb#115287, since the failing tests are now fixed.

Fixes cockroachdb#115278

Release note: None
@DrewKimball DrewKimball requested review from a team and rharding6373 November 29, 2023 23:53
@DrewKimball DrewKimball requested a review from a team as a code owner November 29, 2023 23:57
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

blathers-crl bot commented Nov 29, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Copy link
Collaborator

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Thanks for digging into this and coming up with a robust fix!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@DrewKimball
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 30, 2023

Build succeeded:

@craig craig bot merged commit 830d4f2 into cockroachdb:master Nov 30, 2023
9 checks passed
@mgartner
Copy link
Collaborator

Thanks for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opt: replacing custom max function with Go's built-in causes tests to fail on ARM64
4 participants