luoyuqinlaura commented on code in PR #59966:
URL: https://github.com/apache/spark/pull/59966#discussion_r4647391229
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/ui/SQLAppStatusListener.scala:
##########
@@ -275,25 +275,27 @@ class SQLAppStatusListener(
maxMetricsFromAllStages(id) = updated
}
- exec.driverAccumUpdates.foreach { case (id, value) =>
- if (accumIds.contains(id)) {
+ // Group updates by accumulator id so that each id is appended once,
+ // avoiding repeated array copies.
+ exec.driverAccumUpdates
+ .filter { case (id, _) => accumIds.contains(id) }
+ .groupBy(_._1)
+ .foreach { case (id, updatesForId) =>
+ val values = updatesForId.map(_._2)
val prev = allMetrics.getOrElse(id, null)
- val updated = if (prev != null) {
+ if (prev != null) {
// If the driver updates same metrics as tasks and has higher value
then remove
// that entry from maxMetricsFromAllStage. This would make
stringValue function default
// to "driver" that would be displayed on UI.
- if (maxMetricsFromAllStages.contains(id) && value >
maxMetricsFromAllStages(id)(0)) {
+ if (maxMetricsFromAllStages.contains(id) &&
+ values.max > maxMetricsFromAllStages(id)(0)) {
Review Comment:
Added a listener-level test: tasks report a size metric, then a
SparkListenerDriverAccumUpdates carries several values for the same id. It
covers both the prev ++ values merge and the (driver) attribution.
--
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]