Repository navigation
Speed up sparse takes from chunked Dict arrays - #11548
Conversation
…array `array.take(indices)` on an encoded array is a lazy `Dict` whose values are the whole encoded array. When such a Dict is a chunk of a ChunkedArray, canonicalizing appends it to a builder through `Dict::append_to_builder`. `alp_rd_take_chunked` measures that path. It takes rows from each of four ALP-RD f32 segments of 262,144 values (right bit width 24, about 2,000 left-part patches), chunks the results and canonicalizes them recursively, as a primitive column and as FixedSizeList<f32, 64>. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniBE6jGwH9sRoqTmLZFz
Merging this PR will degrade performance by 16.4%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
) ## Summary `array.take(indices)` on an encoded array is a lazy `Dict` whose values are the whole encoded array. Executing that `Dict` directly is fine, because the values' take kernel runs as an execute-parent kernel. But when the `Dict` sits inside a `ChunkedArray`, canonicalizing appends each chunk to a builder, and `Dict::append_to_builder` decoded **every** value before gathering. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
`test_counts_file_covers_every_discovered_target` requires every benchmark target in `scripts/codspeed_bench_counts.json`. Under CodSpeed, `alp_rd_take_chunked` runs 4 benchmarks. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniBE6jGwH9sRoqTmLZFz
Fold it into the Pull Requests section that develop added, and add what landing #11548 and #11545 showed: the benchmark PR must also count its benchmarks in `scripts/codspeed_bench_counts.json`, and merging the stacked change while its base is still the benchmark branch folds it into the benchmark PR. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UeniBE6jGwH9sRoqTmLZFz
|
Benchmark results for the change, which came in from #11545. CodSpeed simulation (#11545 compared with this branch before the change):
Local walltime (4 ALP-RD
The threshold is 1/16 because taking costs about 13 ns per row, against about 0.8 ns per value to decode everything, so the two break even at about one row in eleven. With a 1/4 threshold, taking 1/4 of the rows was 2.3× slower than decoding everything. The other CodSpeed regressions are in code this PR doesn't touch: Generated by Claude Code |
|
The failing CodSpeed check (
The fastlanes compare benchmark therefore runs the same code with and without this PR. The regression can be acknowledged on CodSpeed. Generated by Claude Code |
Dict::append_to_builderdecoded every value of an encodedDictbefore gathering. Taking a few rows from each segment of a chunked ALP-RD column therefore decoded every segment in full, which was 77% of a vector re-rank query. Fixed-widthDicts now run the values' take kernel when there are at most 1/16 as many codes as values, which is the break-even measured on ALP-RD. Utf8/Binary keep their existing ratio of 4.Measured against the new
alp_rd_take_chunkedbenchmark in #11545, CodSpeed shows ×5.3 for one primitive row per segment and ×2.7 for oneFixedSizeListvector. #11545 was stacked on this PR and has been merged into it, so this PR now contains both the benchmark and the change.🤖 Generated with Claude Code