You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/07/20 20:59:52 UTC

[PR] Add benchmark for `BooleanArray::take_n_true` [arrow-rs]

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

   # Which issue does this PR close?
   
   - Follow on to #10397 (part of #6430)
   
   # Rationale for this change
   
   `BooleanArray::take_n_true` is used in the parquet reader's limit pushdown path (`evaluate_predicate`) but has no benchmark coverage. #10397 changes its implementation to reuse the values allocation when the buffer is unshared, so a benchmark is needed to measure that change (and future ones).
   
   # What changes are included in this PR?
   
   A new `boolean_take_n_true` benchmark covering four cases on 8192-element arrays:
   
   - `shared`: the values buffer is shared, so the retained prefix must be copied
   - `unshared`: a fresh array per iteration, eligible for allocation reuse with #10397
   - `nulls shared`: exercises the null-skipping scan
   - `no truncation`: fewer than `n` set bits, returns `self` unchanged
   
   Baseline on `main` (before #10397): `shared` ~1.07µs, `unshared` ~1.13µs — with #10397 the `unshared` case is expected to improve as it avoids the copy.
   
   # Are these changes tested?
   
   The benchmark compiles and runs (`cargo bench --bench boolean_take_n_true -- --test`).
   
   # Are there any user-facing changes?
   
   No, benchmark only.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add benchmark for `BooleanArray::take_n_true` [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10399:
URL: https://github.com/apache/arrow-rs/pull/10399#discussion_r3666713587


##########
arrow/benches/boolean_kernels.rs:
##########
@@ -79,5 +79,39 @@ fn add_benchmark(c: &mut Criterion) {
     c.bench_function("not_slice_24", |b| b.iter(|| bench_not(&array1_sliced_24)));
 }
 
-criterion_group!(benches, add_benchmark);
+fn add_take_n_true_benchmark(c: &mut Criterion) {
+    let size = 2usize.pow(13); // 8K
+    // keep roughly the first half of the set bits
+    let n = size / 4;

Review Comment:
   nit: did you mean keep 1/4 of the set bits?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add benchmark for `BooleanArray::take_n_true` [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10399:
URL: https://github.com/apache/arrow-rs/pull/10399#issuecomment-5474969016

   - superseded by https://github.com/apache/arrow-rs/pull/10703


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add benchmark for `BooleanArray::take_n_true` [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed pull request #10399: Add benchmark for `BooleanArray::take_n_true`
URL: https://github.com/apache/arrow-rs/pull/10399


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add benchmark for `BooleanArray::take_n_true` [arrow-rs]

Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10399:
URL: https://github.com/apache/arrow-rs/pull/10399#discussion_r3666747698


##########
arrow/benches/boolean_kernels.rs:
##########
@@ -79,5 +79,39 @@ fn add_benchmark(c: &mut Criterion) {
     c.bench_function("not_slice_24", |b| b.iter(|| bench_not(&array1_sliced_24)));
 }
 
-criterion_group!(benches, add_benchmark);
+fn add_take_n_true_benchmark(c: &mut Criterion) {
+    let size = 2usize.pow(13); // 8K

Review Comment:
   Also, as [hhhizzz](https://github.com/hhhizzz) mentioned [here](https://github.com/apache/arrow-rs/pull/10397#issuecomment-5030552974), it might be worth benchmarking both small and larger sizes -- say, 32KB and 64KB.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org