Repository navigation
Trim child data on Arrow slice imports - #10379
Conversation
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
Merging this PR will improve performance by 13.45%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | bitpack_blocked_compress_avx2 |
7.6 µs | 6.7 µs | +13.45% |
| Simulation | bench_compare_sliced_dict_primitive[(3333, 10000)] |
76 µs | < 1 ns | N/A |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing bp/arrow-import-trim-slices (ebf4bbf) with develop (09df3e8)
Footnotes
-
518 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
Should we do this for more types? |
Arrow's Parquet reader points each batch's Utf8View/BinaryView views into the whole decompressed page. from_arrow_byte_view imported those buffers whole, so every batch kept, and nbytes() reported, every page it touched. TPC-H l_comment batches of ~27 KiB of strings reported about 1 MiB each, which stopped the writer from coalescing them. The import now walks the valid, non-inlined views once and per buffer: - drops buffers no valid row references, - slices buffers whose used range is at least half used, without copying, - copies the values of sparsely used buffers. Views of null rows become empty. Fully used buffers are still shared zero-copy. This extends #10379, which trimmed sliced Utf8/Binary/List imports, to view types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsHPGatG1T9kXdC662vKcm Signed-off-by: Claude <noreply@anthropic.com>
Summary
Sliced Arrow string, binary, and list arrays retain child data outside their selected rows. Imports now expose only the referenced data and rebase offsets to zero.
Changes
ArrowSessionlist imports.Measured example
A temporary Rust example reproduced the import code from parent commit
9324b04d4and compared it withArrowSessionimports atebf4bbfcb.Strings contained
value-{row}. Lists contained[row, row + 1]with non-nullableInt64elements. Each slice selected two rows at the middle of its parent.nbytes()nbytes()Utf8List<Int64>LargeList<Int64>List<Int64>LargeList<Int64>For the 1,000-row
List<Int64>case, the old import exposed all 2,000 child values. The new import exposes only four child values.The old size was
1,000 × 2 × 8 + 3 × 4 = 16,012bytes. The new size is2 × 2 × 8 + 3 × 4 = 44bytes.Both versions returned the same values as fresh two-row arrays. After the change,
nbytes()also matched the fresh arrays in every case.nbytes()counts logical buffer lengths, including offsets and children. These results do not measure RSS, file size, or runtime.Arrow allocations remain shared, so the original allocation can remain resident.
Validation
cargo test --locked -p vortex-arrow --lib test_sliced_: 12 passed, 0 failed.