perf: specialize native cache statistics collection - #5734
Open
peterxcli wants to merge 1 commit into
Open
Conversation
peterxcli
force-pushed
the
perf/4781-native-cache-statistics
branch
from
September 6, 2026 06:20
180a154 to
21f1989
Compare
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?
Closes #4781.
Rationale for this change
Building an Arrow-backed cache currently dispatches on each column's data type for every row, boxes primitive values, and copies every non-null string while collecting statistics. Only the final lower and upper bounds need to survive the batch.
The issue's projection hoist and scan-wide deep-copy removal are already present. This PR implements the remaining statistics optimizations; the optional uncompressed cache format is deferred.
What changes are included in this PR?
CometInMemoryCacheBenchmark.How are these changes tested?
make corepassed.SPARK_LOCAL_IP=127.0.0.1 ./mvnw test -Dtest=none -Dsuites=org.apache.comet.exec.CometInMemoryCacheSuite: 34 tests passed on Spark 4.1.3.Benchmarks
Compared the original serializer at
75fdddc92with this patch, using Spark 4.1.3 and JDK 21.0.6 on macOS. Both workloads use three long columns and three string columns. Results are medians; allocation units are decimal.Statistics microbenchmark: invoked the actual before/after
gatherColumnStatsmethods over a prebuilt 10,000-rowOnHeapColumnVectorbatch, 500 times per sample. Both implementations ran in the same JVM with alternating order, five warmup rounds and 15 measured rounds. Bounds and null counts were checked for equality; results were consumed through a volatile sink. Allocation was measured usingThreadMXBean. These timings isolate statistics over Spark on-heap vectors, not decoded Arrow vectors.Full materialization: used the same input expressions as
CometInMemoryCacheBenchmark, withlocal[1], 16 partitions, 10,000-row batches and an 8 GiB JVM heap. Spark generated the rows and the selected Arrow serializer populated the cache; native execution was disabled for both versions. Timing included row generation, Arrow conversion, statistics, compression and storage. Each cache was unpersisted synchronously outside the timer. Four separate JVMs ran in before/after/after/before order, each with three warmups and seven measured samples. Pooled medians use 14 samples per implementation. The actual cached-batch classes were verified, and all runs produced exactly 168,804,118 serialized bytes.Per-JVM materialization medians were 2.017 s / 2.172 s / 1.749 s / 1.826 s. This variation means the isolated-loop gain does not establish an end-to-end cache-build speedup. Measurements used temporary comparison harnesses; the committed materialization benchmark case supports subsequent whole-pipeline benchmarking.