-
Notifications
You must be signed in to change notification settings - Fork 982
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
Use a MergeSorter taking advantage of extra storage for StableMSBRadixSorter #12623
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.
Nice!
} | ||
|
||
private void merge(int from, int to, int mid) { | ||
assert to > mid && mid > from; |
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.
In merge sort, it is common to check if the value at mid-1 is less than or equal to the value at mid, to save work in case the data is already (partially) sorted, maybe we could do that here too?
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.
Great advice! Thank you!
Description
As
StableMSBRadixSorter
always requires aO(n)
extra memory. We can use aMergeSorter
taking advantage of the extra memory instead ofInPlaceMergeSorter
.Benchmark
This reduces around 12% took of sorting ~10,000,000 timestamp values (LongPoint) during indexing.