Skip to content

Add benchmark for BooleanArray::take_n_true - #10399

Draft
alamb wants to merge 1 commit into
apache:mainfrom
alamb:alamb/bench-take-n-true
Draft

Add benchmark for BooleanArray::take_n_true#10399
alamb wants to merge 1 commit into
apache:mainfrom
alamb:alamb/bench-take-n-true

Conversation

@alamb

@alamb alamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

BooleanArray::take_n_true has no benchmark coverage but I am trying to optimize it (see #10397)

What changes are included in this PR?

Add new take_n_true cases in the existing boolean_kernels benchmark, on 32768-element arrays:

Are these changes tested?

The benchmark compiles and runs (cargo bench --bench boolean_kernels --features test_utils -- --test).

Are there any user-facing changes?

No, benchmark only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alamb
alamb force-pushed the alamb/bench-take-n-true branch from f17b206 to 46663c5 Compare July 20, 2026 21:11

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is marked as a draft but it looks good to me

Comment on lines +84 to +85
// keep roughly the first half of the set bits
let n = size / 4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


criterion_group!(benches, add_benchmark);
fn add_take_n_true_benchmark(c: &mut Criterion) {
let size = 2usize.pow(13); // 8K

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, as hhhizzz mentioned here, it might be worth benchmarking both small and larger sizes -- say, 32KB and 64KB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants