[SPARK-59174][SS] State-store instance metrics are shipped in every task result - #58476
Open
Diveyam-Mishra wants to merge 1 commit into
Open
[SPARK-59174][SS] State-store instance metrics are shipped in every task result#58476Diveyam-Mishra wants to merge 1 commit into
Diveyam-Mishra wants to merge 1 commit into
Conversation
Author
|
Hey its my first time contributing not knowing how to ask for a review so tagging let me know if there is a different way. (I Read the contributing guide ) |
tdcmeehan
reviewed
Sep 3, 2026
| */ | ||
| lazy val instanceMetrics: Map[StateStoreInstanceMetric, SQLMetric] = | ||
| stateStoreInstanceMetrics | ||
| val instanceMetricsAccumulator: CollectionAccumulator[(StateStoreInstanceMetric, Long)] = { |
There was a problem hiding this comment.
Could we use or extend PartitionKeyedAccumulator here? Unlike CollectionAccumulator, it bounds driver-side state by partition when retries or speculative attempts produce duplicate updates. We would need to preserve StateStoreInstanceMetric.combine semantics rather than its default last-write-wins behavior, but that may avoid retaining every successful attempt’s raw metrics on the driver.
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?
This PR resolves an overhead issue with state-store instance metric reporting in
StateStoreWriter.Currently,
StateStoreWritercreates separateSQLMetricaccumulators for every(partitionId, metric, storeName)combination upfront on the physical plan. On executors, every task deserializes and registers all of those accumulators in itsTaskContext, and includes all of them in the task result payload even though only a single partition was processed.This PR replaces the upfront$O(\text{numPartitions})$
SQLMetricinstances with a singleinstanceMetricsAccumulator: CollectionAccumulator[(StateStoreInstanceMetric, Long)]onStateStoreWriter(following the pattern ofcheckpointInfoAccumulator). Each task appends only its own active partition's metric updates. The driver then aggregates, sorts, and formats the top-$K$ instance metrics duringgetProgress().Why are the changes needed?
For queries with high partition counts (e.g. 20,000 shuffle partitions), each task was shipping ~3 MiB of unused metric updates, totaling ~60 GiB across tasks. In terminal
ResultStages (such as RDD checkpoint materialization or direct file writes), this causesspark.driver.maxResultSizeerrors, severe driver heap pressure, and network congestion.Fixes #58394 and https://issues.apache.org/jira/browse/SPARK-59174.
Does this PR introduce any user-facing change?
No
How was this patch tested?
StateStoreInstanceMetricSuite:"SPARK-59174: StateStoreWriter uses single accumulator for instance metrics".StateStoreInstanceMetricSuite(all 12 tests passed).Metric | Before Fix | After Fix
Accumulator objects created | O(N × metrics × stores) — e.g. 20,000–60,000 accumulators | 1 accumulator
Task result payload (per task) | ~3 MiB / task | ~100 bytes / task
Was this patch authored or co-authored using generative AI tooling?
Yes
Generated-by: Gemini 3.7 Flash