Skip to content

Built-in radix sort performance improvements - #4309

Merged
garth-wells merged 4 commits into
mainfrom
garth/radix-performance-2
Jul 21, 2026
Merged

Built-in radix sort performance improvements#4309
garth-wells merged 4 commits into
mainfrom
garth/radix-performance-2

Conversation

@garth-wells

Copy link
Copy Markdown
Member

Used Claude Sonnet 5.

garth-wells and others added 3 commits July 20, 2026 11:17
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
garth-wells marked this pull request as ready for review July 20, 2026 14:13
@garth-wells
garth-wells added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 8446bb7 Jul 21, 2026
20 checks passed
@garth-wells
garth-wells deleted the garth/radix-performance-2 branch July 21, 2026 07:24
@schnellerhase

Copy link
Copy Markdown
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            5

The 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 ?

@jhale

jhale commented Jul 22, 2026

Copy link
Copy Markdown
Member

I would propose backing this PR out until we can get some agreement on the performance profiling results.

@jhale
jhale restored the garth/radix-performance-2 branch July 22, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants