perf(parquet): slice up contiguous buffer for decimals and fsb#10364
Open
MassivePizza wants to merge 6 commits into
Open
perf(parquet): slice up contiguous buffer for decimals and fsb#10364MassivePizza wants to merge 6 commits into
MassivePizza wants to merge 6 commits into
Conversation
3-6% improved arrow_writer "decimal" bench
etseidl
reviewed
Jul 17, 2026
|
|
||
| #[inline(always)] | ||
| #[allow(clippy::eq_op)] | ||
| fn is_nan_with<T: ParquetValueType>(logical_type_ref: Option<&LogicalType>, val: &T) -> bool { |
Contributor
There was a problem hiding this comment.
I don't think the compare_greater/is_nan changes are really relevant to this PR, and will conflict with work already in progress to revamp NaN handling per changes to the spec (#9619). We can revisit once that merges.
etseidl
reviewed
Jul 17, 2026
| )?) | ||
| } | ||
|
|
||
| fn create_decimal_bench_batch(size: usize, null_density: f32) -> Result<RecordBatch> { |
Contributor
There was a problem hiding this comment.
Could you break the benchmarks out into a separate PR? 🙏 It would be helpful.
Jefffrey
reviewed
Jul 18, 2026
Comment on lines
+1840
to
+1843
| let mut out = [0; 12]; | ||
| let value = array.value(i); | ||
| out[0..4].copy_from_slice(&value.to_le_bytes()); | ||
| arena.extend_from_slice(&out); |
Contributor
There was a problem hiding this comment.
would it make a difference to change arena to vec![0; indices.len() * VALUE_SIZE] then use copy_from_slice into offsets to arena to avoid this intermediate out?
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?
N/A
Rationale for this change
Converting decimals and FixedLenByteArrays to individual allocs requires a lot of alloc+drop time and memory overhead.
What changes are included in this PR?
Allocate one big buffer, and cut it up into slices of
bytes::Bytes. This amortizes the alloc upfront, and effectively eliminates the drop overhead by turning a dealloc to an Arc decrement per slice.This still has moderate memory overhead.
Bytesis 32 bytes, while the slices usually expose less than 16 bytes at a time e.g. UUIDs or decimal128, but a lot more effort would be required to implement a (perhaps borrowed?) alternative that behaves likeFixedLenByteArray.There are a few other ideas worth exploring, primarily custom
ColumnValueEncoders that converts on the fly to avoid the temporary allocs all together.There is also a small outlining+inlining in
compare_greaterto help out in theget_min_maxloop.Are these changes tested?
Should be covered by existing tests. There are also new benches included:
decimal bench
fsb bench
Are there any user-facing changes?
No.