Sakibpedia opened a new pull request, #12506:
URL: https://github.com/apache/arrow-rs/pull/12506

   # Which issue does this PR close?
   
   - Closes #10846
   
   # Rationale for this change
   
   `RunEndBuffer::get_physical_indices` sorts the requested logical indices and 
then walks every physical run from the start of the (possibly sliced) run-end 
buffer, even after all requested indices have been assigned. For a small prefix 
selection on a large buffer, the cost is therefore proportional to the *entire* 
buffer: mapping two logical indices over 1,048,576 runs takes about 1.37 ms.
   
   A related draft (#10849) explores per-index binary search for small 
selections. This change is complementary: a simple early exit that helps every 
selection size while leaving the existing sequential algorithm (and its 
behavior) untouched.
   
   # What changes are included in this PR?
   
   - Break out of the run-iteration loop as soon as all requested logical 
indices have been mapped.
   - Add a regression test covering prefix, reordered/duplicate, empty, 
out-of-bounds, and sliced selections on a large buffer.
   - Add criterion benchmarks for prefix and sparse selections at 1,024 and 
1,048,576 runs (first commit).
   
   # Are these changes tested?
   
   Yes. `cargo test -p arrow-buffer` passes (455 unit tests and 113 doc tests), 
as do `cargo clippy -p arrow-buffer --all-targets --all-features -- -D 
warnings` and `cargo fmt --all -- --check`. The new test passes with the fix 
and guards the documented edge cases.
   
   Benchmarks measured locally (Rust 1.100, windows-gnu, criterion, warm-up 1 s 
/ measurement 3 s; baseline is the first commit of this PR, `e680608`):
   
   | Selection | Before | After |
   | --- | ---: | ---: |
   | 2 early rows, 1,024 runs | 1.405 us | 240 ns |
   | 2 early rows, 1,048,576 runs | 1.372 ms | 228 ns |
   | 1,024 sparse rows, 1,024 runs | 7.384 us | 5.524 us |
   | 1,024 sparse rows, 1,048,576 runs | 3.00 ms | 2.29 ms |
   
   # Are there any significant user-facing changes?
   
   No. Results, ordering, duplicate handling, slices, and bounds errors are 
unchanged; only unnecessary work is avoided.
   
   # AI usage disclosure
   
   AI assistance (OpenCode) generated the early-exit change, the regression 
test, the benchmark, and this description. I reviewed the implementation, 
confirmed the edge cases with the full `arrow-buffer` test suite, and measured 
the benchmarks locally before and after the change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to