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: reduce allocations in OrderingSet.LongestCommonPrefix #86443

Merged

Conversation

mgartner
Copy link
Collaborator

Previously, the *OrderingChoice returned by LongestCommonPrefix was
allocated on the heap (except in the case where the ordering set
contained a ordering choice that implies the given ordering). Now,
LongestCommonPrefix returns a non-pointer type and avoids these
allocations.

Release justification: This is a minor change that improves performance.

Release note: None

Previously, the `*OrderingChoice` returned by `LongestCommonPrefix` was
allocated on the heap (except in the case where the ordering set
contained a ordering choice that implies the given ordering). Now,
`LongestCommonPrefix` returns a non-pointer type and avoids these
allocations.

Release justification: This is a minor change that improves performance.

Release note: None
@mgartner mgartner requested a review from a team as a code owner August 19, 2022 10:55
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner
Copy link
Collaborator Author

This provides a fairly significant improvement to the slow queries benchmarks:

name                         old time/op    new time/op    delta
SlowQueries/slow-query-1-24    35.4ms ± 1%    35.3ms ± 0%     ~     (p=0.310 n=5+5)
SlowQueries/slow-query-2-24     549ms ± 0%     495ms ± 1%   -9.78%  (p=0.008 n=5+5)

name                         old alloc/op   new alloc/op   delta
SlowQueries/slow-query-1-24    12.3MB ± 0%    12.3MB ± 0%   -0.29%  (p=0.008 n=5+5)
SlowQueries/slow-query-2-24     181MB ± 0%     155MB ± 0%  -14.04%  (p=0.008 n=5+5)

name                         old allocs/op  new allocs/op  delta
SlowQueries/slow-query-1-24      131k ± 0%      130k ± 0%   -0.57%  (p=0.008 n=5+5)
SlowQueries/slow-query-2-24     1.65M ± 0%     1.24M ± 0%  -24.66%  (p=0.008 n=5+5)

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

Wow nice improvement! :lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @michae2)

@mgartner
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 19, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 19, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 19, 2022

Build succeeded:

@craig craig bot merged commit fe19f5d into cockroachdb:master Aug 19, 2022
@mgartner mgartner deleted the reduce-ordering-choice-allocations branch August 20, 2022 13:58
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.

3 participants