Skip to content

Add append_non_nulls to StructBuilder#9430

Open
Fokko wants to merge 1 commit intoapache:mainfrom
Fokko:fd-append-n-non-nulls
Open

Add append_non_nulls to StructBuilder#9430
Fokko wants to merge 1 commit intoapache:mainfrom
Fokko:fd-append-n-non-nulls

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Feb 18, 2026

Which issue does this PR close?

I'm doing some performance optimization, and noticed that we have a loop adding one value to the null mask at a time. Instead, I'd suggest adding append_non_nulls to do this at once.

append_non_nulls(n) vs append(true) in a loop (with bitmap allocated)

┌───────────┬───────────────────┬─────────────────────┬─────────┐
│     n     │ append(true) loop │ append_non_nulls(n) │ speedup │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 100       │ 251 ns            │ 73 ns               │ ~3x     │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 1,000     │ 2.0 µs            │ 94 ns               │ ~21x    │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 10,000    │ 19.3 µs           │ 119 ns              │ ~162x   │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 100,000   │ 191 µs            │ 348 ns              │ ~549x   │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 1,000,000 │ 1.90 ms           │ 3.5 µs              │ ~543x   │
└───────────┴───────────────────┴─────────────────────┴─────────┘

Rationale for this change

It adds a new public API in favor of performance improvements.

What changes are included in this PR?

A new public API

Are these changes tested?

Yes, with new unit-tests.

Are there any user-facing changes?

Just a new convient API.

Closes apache#9429

I'm doing some performance optimization, and noticed that we have a loop adding one value to the null mask at a time. Instead, I'd suggest adding `append_non_nulls` to do this at once.

```
append_non_nulls(n) vs append(true) in a loop (with bitmap allocated)

┌───────────┬───────────────────┬─────────────────────┬─────────┐
│     n     │ append(true) loop │ append_non_nulls(n) │ speedup │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 100       │ 251 ns            │ 73 ns               │ ~3x     │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 1,000     │ 2.0 µs            │ 94 ns               │ ~21x    │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 10,000    │ 19.3 µs           │ 119 ns              │ ~162x   │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 100,000   │ 191 µs            │ 348 ns              │ ~549x   │
├───────────┼───────────────────┼─────────────────────┼─────────┤
│ 1,000,000 │ 1.90 ms           │ 3.5 µs              │ ~543x   │
└───────────┴───────────────────┴─────────────────────┴─────────┘
```
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.

Add append_non_nulls to StructBuilder

1 participant

Comments