[SPARK-56896][SQL] Add bulk read paths for timestamp/date Parquet vector updaters#55923
Open
iemejia wants to merge 1 commit into
Open
[SPARK-56896][SQL] Add bulk read paths for timestamp/date Parquet vector updaters#55923iemejia wants to merge 1 commit into
iemejia wants to merge 1 commit into
Conversation
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.
What changes were proposed in this pull request?
Replace per-element
readValueloops with two-pass bulk read + in-place conversion for fiveParquetVectorUpdaterimplementations inParquetVectorUpdaterFactory:LongAsMicrosUpdaterreadLongsmillisToMicrosLongAsNanosUpdaterreadLongsmicrosToNanosLongAsMicrosRebaseUpdaterreadLongsmillisToMicros+rebaseMicrosDateToTimestampNTZUpdaterreadIntegersAsLongsdaysToMicrosDateToTimestampNTZWithRebaseUpdaterreadIntegersAsLongsrebaseDays+daysToMicrosEach updater now:
readLongsorreadIntegersAsLongs(backed bySystem.arraycopy).This avoids per-element virtual dispatch through
VectorizedValuesReaderin the hot loop. ThegetLong/putLongcalls onfinal OnHeapColumnVectorare devirtualized by C2 into direct array access.Note: extracting a shared helper taking
LongUnaryOperatorwas attempted and reverted because it caused a 4x regression onLongAsMicrosRebaseUpdater(1791 -> 434 M/s). The root cause is C2 profile pollution: multiple updaters calling the same static helper with different lambdas makes theapplyAsLongcall site megamorphic, preventing lambda inlining. The explicit inline code is necessary for this hot path.Also adds three missing benchmark cases to
ParquetVectorUpdaterBenchmark:LongAsNanosUpdater,DateToTimestampNTZWithRebaseUpdater,LongAsMicrosRebaseUpdater.Why are the changes needed?
The per-element
readValueloop issues a virtual call toVectorizedValuesReader.readLong()/readInteger()on every row, which C2 cannot always devirtualize because the reader type varies (PLAIN, RLE, DELTA, etc.). The two-pass approach replaces N virtual calls with a single bulk read (already optimized per reader implementation) followed by a tight scalar loop that C2 can fully inline and optimize.Before/after on the same machine (AMD EPYC 9V45, JDK 17, 1M rows):
LongAsMicrosUpdaterLongAsNanosUpdaterDateToTimestampNTZUpdaterDateToTimestampNTZWithRebaseUpdaterLongAsMicrosRebaseUpdaterThe
DateToTimestampNTZ*updaters show a modest improvement becausedaysToMicrosdate arithmetic dominates. The long-based updaters show large gains because the transforms (millisToMicros=Math.multiplyExact(x, 1000),microsToNanos= same) are trivial and the virtual dispatch overhead was the bottleneck.Does this PR introduce any user-facing change?
No.
How was this patch tested?
ParquetVectorUpdaterFactorySuite,ParquetQuerySuite,ParquetIOSuite,ParquetSchemaSuite,ParquetRebaseDatetimeSuite,ParquetEncodingSuite,ParquetInteroperabilitySuite,ParquetTypeWideningSuite-- 317 tests pass, 0 failures.ParquetVectorUpdaterBenchmarkwith three new cases.Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenCode with Claude claude-opus-4.6