Each resolve of a loaded pointer emitted 16 unrolled binary-search steps before the loop that
finished sets of more than 2^16 entries. RADV inlines every call of the search, so a module with
many loaded pointers paid the 16 steps at every site: on a curve-shading kernel with 1,065
searches, its creation on the 780M took 92.9 s and 8.4 GiB of compile memory.
The search now starts the loop from all N entries. A step halves the candidates whatever its
compare gives, so the trip count, ceil(log2 N), depends on N alone: every invocation that
searches one table takes the same branches, and a set below 2^16 entries does fewer entry loads
than the 16 steps did (they kept loading after one candidate was left). search_step is the loop's
step; search_rest is now bisect, from (0, N). SEARCH_STEPS is gone, SEARCH_WORDS charges one step
plus the loop, and the docs (roots.rs, API.md) and the tests that named the unrolled reach say
what is true now. The handle-table search keeps its own unrolled steps. Answers are unchanged.
Measured on the 780M (RADV PHOENIX), before (1125fb62d2) and after, one job (m3-max-23016), one
run each:
The curve-shading kernel's creation (pipeline cache off, RADV_DEBUG=shaderstats):
time in the driver 92.9 s -> 62.6 s
peak RSS 8,462 -> 5,846 MiB
ACO instructions 1,741,690 -> 1,000,747
spilled VGPRs 179,037 -> 105,970
spilled SGPRs 95,824 -> 46,562
GPU time of a dispatch whose 262,144 threads each resolve 64 loaded pointers, over M buffers made
resident, every lane's address the same (uniform) or its own (divergent); median of 15 commits,
every thread's sum checked (0 wrong in every row):
M form before after
16 uniform 5.56 ms 4.02 ms -28%
16 divergent 4.61 ms 4.03 ms -13%
1,024 uniform 5.58 ms 6.52 ms +17%
1,024 divergent 8.37 ms 7.84 ms -6%
66,048 uniform 7.86 ms 9.04 ms +15%
66,048 divergent 92.4 ms 95.8 ms +4% (ranges overlap)
Uniform addresses over sets of 1,024 entries or more cost 15-17% more GPU time: the loop's exit
test and back branch at each step cost more there than the unrolled chain's extra steps.