[SPARK-46585][CORE] Directly constructed metricPeaks as an immutable.ArraySeq instead of use mutable.ArraySeq.toSeq in Executor
#44586
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?
The following code exists in branch-3.5:
spark/core/src/main/scala/org/apache/spark/executor/Executor.scala
Lines 744 to 749 in fb90ade
From the code comments, when using Scala 2.12,
metricsPoller.getTaskMetricPeaks(taskId)is wrapped asWrappedArrayto avoid collection copying, and the subsequentmetricPeaks.toSeqis a redundant collection conversion for Scala 2.12.However, for Scala 2.13, if
metricsPoller.getTaskMetricPeaks(taskId)is still wrapped asWrappedArray/mutable.ArraySeq, it is impossible to avoid collection conversion, because the subsequentmetricPeaks.toSeqwill trigger a collection copy when using Scala 2.13.So this pr changes the process to directly wrap
metricPeaksasimmutable.ArraySeqto ensure the same effect as when using Scala 2.12, which is also more in line with the original comment description.Why are the changes needed?
Avoid unnecessary collection copying when using Scala 2.13.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Pass GitHub Actions
Was this patch authored or co-authored using generative AI tooling?
No