Built-in radix sort performance improvements - #4309
Merged
Merged
Conversation
Merges the garth/radix-performance approach (smaller default bucket count avoids a 65536-entry counter/offset array being zeroed and scanned on every pass regardless of row count) with the loop bookkeeping fix already on this branch. Benchmarked: recovers radix-performance's 30-50x win at small/medium row counts, with a further small edge from the bookkeeping fix; large (~10M row) inputs still trail the BITS=16 result, a known trade-off of the static default. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Pass 0 always buckets on the low BITS bits of the projected value, regardless of the top-bit special case, so its histogram can be built for free during the traversal that already computes max_value and all_first_bit. Saves a full extra counting pass (and its proj() calls) for i==0. Verified against cpp/test/common/sort.cpp plus an ad hoc stress test covering its==0, tiny/edge sizes, negative numbers, and argsort permutation validity; benchmarked at 1.02-1.13x with no observed regressions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
garth-wells
marked this pull request as ready for review
July 20, 2026 14:13
Contributor
|
I ran the benchmark previously used for the radix sort changes from schnellerhase#24 and got the following results: main at 6aab05379045333ffae0af63896b961ca4b51126 (current HEAD):
-------------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------------
BM_create_box/10/iterations:5 2.53 ms 2.45 ms 5
BM_create_box/50/iterations:5 392 ms 392 ms 5
BM_create_box/100/iterations:5 4131 ms 4130 ms 5
BM_create_box/150/iterations:5 17315 ms 17243 ms 5
main at bde91285baf62e3c1558ce95db4e008354370fc0 (before this PR):
-------------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------------
BM_create_box/10/iterations:5 2.94 ms 2.83 ms 5
BM_create_box/50/iterations:5 404 ms 404 ms 5
BM_create_box/100/iterations:5 3829 ms 3829 ms 5
BM_create_box/150/iterations:5 15215 ms 15210 ms 5The small meshes might be noise here, and ran on a laptop, but the large setups I'm worried about. How did you benchmark this @garth-wells ? |
Member
|
I would propose backing this PR out until we can get some agreement on the performance profiling results. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Used Claude Sonnet 5.