Skip to content

feat: reduce allocations in Spark Decimal access - #9842

Open
xiaoh1024 wants to merge 2 commits into
vortex-data:developfrom
xiaoh1024:exp/decimal-accessor-pr
Open

xiaoh1024 wants to merge 2 commits into
vortex-data:developfrom
xiaoh1024:exp/decimal-accessor-pr

Conversation

@xiaoh1024

Copy link
Copy Markdown

Summary

Closes #9837. See the issue for the motivation, design, benchmark results, and decimal-specific validation.

Changes

  • Add SmallDecimalAccessor for source precision 1–18, preserving full-width fallback and Spark's decimal conversion semantics.
  • Add regression tests for decimal decoding, conversions, and returned-value independence.

AI assistance: AI assistance was used for implementation, tests, validation tooling, and this description, including translation from Chinese.

Read small-precision Decimal128 values from native long words, retaining
the full-width Arrow conversion when the integer cannot fit in a long.
Handle both native word orders and use the source scale when constructing
BigDecimal, leaving requested rescaling and overflow checks to Spark.
Preserve Spark's expanded Decimal representation for checked integer casts.

Add tests for decimal values, rescaling, malformed buffers, both word
orders, slices, object independence, negative scales and checked casts.

Validated on Spark 3.5.9/Scala 2.12 and Spark 4.1.2/Scala 2.13, with 26
targeted tests per version plus Javadoc and test formatting checks.
AI-assisted implementation and tests.

Signed-off-by: Peifeng Li <lipeifeng@xiaohongshu.com>
@codspeed

codspeed Bot commented Sep 14, 2026

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 1 improved benchmark
❌ 2 regressed benchmarks
✅ 2194 untouched benchmarks
⏩ 218 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime dict_canonicalize_gt_u8_avx2[16000000] 8 ms 10.1 ms -21.32%
WallTime words_gather_scalar_avx2[65536] 8.3 µs 9.4 µs -12.06%
WallTime arrow_checked_add_u32_neon[16384] 20.4 µs 13.4 µs +52.66%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing xiaoh1024:exp/decimal-accessor-pr (f3a1eb6) with develop (d1fe2dc)

Open in CodSpeed

Footnotes

  1. 218 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@robert3005 robert3005 added the changelog/performance A performance improvement label Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce allocations when reading small-precision decimals in the Spark connector

2 participants