shujingyang-db opened a new pull request, #59802:
URL: https://github.com/apache/spark/pull/59802

   ### What changes were proposed in this pull request?
   
   When `TaskResultGetter` receives a task result, it sets the task result size 
on the `RESULT_SIZE` accumulator. It did this with `map`, which rebuilds the 
whole accumulator update sequence. This PR walks the updates with `foreach` and 
sets the matching `LongAccumulator` in place. The name check now uses 
`Option.contains` instead of comparing with a new `Some`.
   
   ### Why are the changes needed?
   
   This code runs on the driver once per task result. The update sequence can 
hold hundreds of entries when SQL metrics are involved. The old code already 
mutated the matching accumulator in place, so the new sequence held the same 
objects as the old one. Building it, and allocating a `Some` for every name 
check, was unnecessary work.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. `result.accumUpdates` keeps the same elements, and the result-size 
accumulator gets the same value. The update still runs at the same point, 
because `accumUpdates` is a strict `Seq` after deserialization 
(`ArrayBuffer.toSeq` or `Seq.empty` in `DirectTaskResult.readExternal`). The 
assert is unchanged.
   
   ### How was this patch tested?
   
   No new test, because the accumulator updates and their values do not change. 
Existing suites cover this path and pass locally:
   
   ```
   build/sbt "core/testOnly org.apache.spark.scheduler.TaskResultGetterSuite 
org.apache.spark.scheduler.TaskSchedulerImplSuite 
org.apache.spark.AccumulatorSuite"
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)
   
   This pull request and its description were written by Isaac.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to