perf: reuse input null buffer and add no-nulls fast path in Spark hex#23721
Closed
jackylee-ch wants to merge 1 commit into
Closed
perf: reuse input null buffer and add no-nulls fast path in Spark hex#23721jackylee-ch wants to merge 1 commit into
hex#23721jackylee-ch wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23721 +/- ##
==========================================
- Coverage 80.69% 80.69% -0.01%
==========================================
Files 1088 1088
Lines 367766 367826 +60
Branches 367766 367826 +60
==========================================
+ Hits 296781 296803 +22
- Misses 53276 53311 +35
- Partials 17709 17712 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
Hi @jackylee-ch we already have an open pr for this #23688 |
Contributor
Author
Thanks, sorry for miss that. |
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?
Rationale for this change
Follow-on from review feedback on #23473.
hex_encode_bytesindatafusion/spark/src/function/math/hex.rsrebuilt the outputNullBufferrow by row viaNullBufferBuilder, even though hex encoding maps rows 1:1 (a null in maps to a null out), so the output nulls are always identical to the input's.This PR applies both optimizations suggested in the issue:
NullBuffer. The input array's null buffer is now cloned (a cheapArc-based clone) and attached to the output array directly, removing the per-rowappend_null/append_non_nullbookkeeping.Optioncheck.What changes are included in this PR?
hex_encode_bytesnow takes the input array'sOption<NullBuffer>and reuses it for the output array instead of rebuilding it withNullBufferBuilder; all call sites (top-level arrays and dictionary values) passarray.nulls().cloned().Benchmark results from the existing
datafusion/spark/benches/hex.rs(null_density = 0.1) againstmainon an M-series MacBook:Are these changes tested?
Yes. Existing unit tests cover the string/binary/dictionary paths, and a new test
test_spark_hex_utf8_with_nullsexercises the has-nulls path with interleaved nulls and empty strings to verify the reused null buffer stays aligned with the encoded values.Are there any user-facing changes?
No.