Avoid allocating a Vec in StructBuilder#9428
Merged
Dandandan merged 1 commit intoapache:mainfrom Feb 18, 2026
Merged
Conversation
Resolves apache#9427 While going through the code, @scovich noticed that it allocates a `vec![false; n]` to be appended to the null buffer, which is not very efficent: ``` append_nulls: vec![false; n] (old) vs append_n_nulls (new) ┌─────────┬─────────────────┬──────────────────────┬─────────┐ │ n │ old (vec alloc) │ new (append_n_nulls) │ speedup │ ├─────────┼─────────────────┼──────────────────────┼─────────┤ │ 100 │ 82 ns │ 43 ns │ ~2x │ ├─────────┼─────────────────┼──────────────────────┼─────────┤ │ 1,000 │ 319 ns │ 47 ns │ ~7x │ ├─────────┼─────────────────┼──────────────────────┼─────────┤ │ 10,000 │ 2,540 ns │ 68 ns │ ~37x │ ├─────────┼─────────────────┼──────────────────────┼─────────┤ │ 100,000 │ 25,526 ns │ 293 ns │ ~87x │ └─────────┴─────────────────┴──────────────────────┴─────────┘ ```
Dandandan
approved these changes
Feb 18, 2026
Contributor
|
Thank you @Fokko ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Resolves #9427
While going through the code, @scovich noticed that it allocates a
vec![false; n]to be appended to the null buffer, which is not very efficent:Rationale for this change
MOAR efficient
What changes are included in this PR?
Avoid allocating a
Vec.Are these changes tested?
Existing tests
Are there any user-facing changes?
Less memory consumption and a happy CPU