perf: optimize spark_unhex in spark-expr#4876
Conversation
|
I can't find all of the benchmarks in the PR description in the code. Were they temporary, hallucinated, or am I missing something? |
This was the first live run and there were some glitches. Will update the PR with the full benchmarks. |
Cover valid/nulls/long/invalid/mixed columns instead of a single case, and replace the fully-qualified arrow::array::BinaryBuilder with a use import.
|
Updated. Two things: Benchmarks — you were right, the original description listed benchmark IDs that weren't in the code. This was the first live run of an automated tool, and it had a bug: criterion measurements from earlier attempts on this same function accumulated in
The description now reflects exactly these numbers. FQN — replaced the fully-qualified |
comphead
left a comment
There was a problem hiding this comment.
Thanks @andygrove I would also port more tests from spark with bad inputs.
unhex('-123')
unhex('\0')
I created a separate PR to add these cases. |
…2026-07-09-pr1 # Conflicts: # native/spark-expr/Cargo.toml
What changed
Optimizes
spark_unhexin the nativespark-exprcrate.Replace unhex's per-digit range-match with a compile-time 256-entry hex lookup table and preallocate the
BinaryBuilderto its known output size, cutting per-byte branching and repeated buffer reallocations.Evidence
main).main) vs this branch, across five input shapes (8192-row columns). All changes are statistically significant (p < 0.05).