From 38e39cb35f2c44537a51b43dceb0bb9e17c3155d Mon Sep 17 00:00:00 2001 From: yangjie01 Date: Thu, 23 Jan 2025 21:12:49 -0800 Subject: [PATCH] [SPARK-50971][CORE] Combine the two retrievals of `taskDescription` in `CoarseGrainedExecutorBackend#statusUpdate` ### What changes were proposed in this pull request? This PR reduces the two retrievals of `taskDescription` in `CoarseGrainedExecutorBackend#statusUpdate` to one. ### Why are the changes needed? Combine the two retrievals of `taskDescription` in `CoarseGrainedExecutorBackend#statusUpdate` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Pass GitHub Acitions ### Was this patch authored or co-authored using generative AI tooling? No Closes #49638 from LuciferYang/taskDescription. Authored-by: yangjie01 Signed-off-by: Dongjoon Hyun (cherry picked from commit 1569c8a33aa6baecc4018c97c4471f9249512389) Signed-off-by: Dongjoon Hyun --- .../apache/spark/executor/CoarseGrainedExecutorBackend.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/executor/CoarseGrainedExecutorBackend.scala b/core/src/main/scala/org/apache/spark/executor/CoarseGrainedExecutorBackend.scala index a73380cab690e..a30759e5d794e 100644 --- a/core/src/main/scala/org/apache/spark/executor/CoarseGrainedExecutorBackend.scala +++ b/core/src/main/scala/org/apache/spark/executor/CoarseGrainedExecutorBackend.scala @@ -265,8 +265,9 @@ private[spark] class CoarseGrainedExecutorBackend( } override def statusUpdate(taskId: Long, state: TaskState, data: ByteBuffer): Unit = { - val resources = executor.runningTasks.get(taskId).taskDescription.resources - val cpus = executor.runningTasks.get(taskId).taskDescription.cpus + val taskDescription = executor.runningTasks.get(taskId).taskDescription + val resources = taskDescription.resources + val cpus = taskDescription.cpus val msg = StatusUpdate(executorId, taskId, state, data, cpus, resources) if (TaskState.isFinished(state)) { lastTaskFinishTime.set(System.nanoTime())