This is an automated email from the ASF dual-hosted git repository.

zaynt4606 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git


The following commit(s) were added to refs/heads/main by this push:
     new ac30bb16c5 [CELEBORN-2574] Fix Spark UI shuffle write time aggregation
ac30bb16c5 is described below

commit ac30bb16c571c8bc8a47d833bb165a6e437555f6
Author: huangxiaoping <[email protected]>
AuthorDate: Fri Nov 20 10:38:30 2026 +0800

    [CELEBORN-2574] Fix Spark UI shuffle write time aggregation
    
    ### What changes were proposed in this pull request?
    
    Aggregate shuffle write time in nanoseconds, as Spark does, and convert the 
total to milliseconds when persisting the Celeborn UI data. Add a regression 
test for sub-millisecond task times across flushes.
    
    ### Why are the changes needed?
    
    Converting each task's write time before summing discards its fractional 
millisecond. For example, two tasks with 600,000 ns each currently produce a 
total of 0 ms instead of 1 ms, which also affects the displayed write speed.
    
    Jira: https://issues.apache.org/jira/browse/CELEBORN-2574
    
    ### Does this PR resolve a correctness bug?
    
    - [x] Yes
    
    ### Does this PR introduce _any_ user-facing change?
    
    - [x] Yes
    
    ### How was this patch tested?
    
    - `mvn -o -Pspark-3.5 -pl client-spark/spark-3-ui -am 
-Dtest=CelebornListenerSuite -Dsurefire.failIfNoSpecifiedTests=false 
-DwildcardSuites=none -Dspotless.skip=true test` (20 tests passed). The new 
test failed before the fix with `expected:<1> but was:<0>`.
    - `mvn -o -Pspark-3.5 -pl client-spark/spark-3-ui 
com.diffplug.spotless:spotless-maven-plugin:2.24.1:check`
    
    Closes #3990 from huangxiaopingRD/codex/fix-spark-ui-write-time.
    
    Authored-by: huangxiaoping <[email protected]>
    Signed-off-by: zhengtao <[email protected]>
    
    AI-Contributed/Feature: 0/8
    AI-Contributed/UT: 0/26
---
 .../spark/shuffle/celeborn/CelebornListener.scala  |  8 +++----
 .../shuffle/celeborn/CelebornListenerSuite.scala   | 26 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git 
a/client-spark/spark-3-ui/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornListener.scala
 
b/client-spark/spark-3-ui/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornListener.scala
index 7a238d2dac..83e849e4f2 100644
--- 
a/client-spark/spark-3-ui/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornListener.scala
+++ 
b/client-spark/spark-3-ui/src/main/scala/org/apache/spark/shuffle/celeborn/CelebornListener.scala
@@ -17,6 +17,7 @@
 
 package org.apache.spark.shuffle.celeborn
 
+import java.util.concurrent.TimeUnit
 import java.util.concurrent.atomic.AtomicLong
 
 import scala.collection.JavaConverters._
@@ -48,7 +49,7 @@ private[celeborn] class CelebornListener(
   @volatile private var pluginEnabled = !requirePluginOptIn
 
   private val totalWriteBytes = new AtomicLong(0L)
-  private val totalWriteTimeMs = new AtomicLong(0L)
+  private val totalWriteTimeNs = new AtomicLong(0L)
   private val totalReadBytes = new AtomicLong(0L)
   private val totalFetchWaitTimeMs = new AtomicLong(0L)
   private val totalTaskDurationMs = new AtomicLong(0L)
@@ -82,8 +83,7 @@ private[celeborn] class CelebornListener(
     Option(taskEnd.taskMetrics).foreach { metrics =>
       // Count every attempt regardless of its end reason, like 
AppStatusListener.
       totalWriteBytes.addAndGet(metrics.shuffleWriteMetrics.bytesWritten)
-      // writeTime is in nanoseconds; normalize to ms.
-      totalWriteTimeMs.addAndGet(metrics.shuffleWriteMetrics.writeTime / 
1000000L)
+      totalWriteTimeNs.addAndGet(metrics.shuffleWriteMetrics.writeTime)
       totalReadBytes.addAndGet(metrics.shuffleReadMetrics.totalBytesRead)
       totalFetchWaitTimeMs.addAndGet(metrics.shuffleReadMetrics.fetchWaitTime)
       totalTaskDurationMs.addAndGet(taskEnd.taskInfo.duration)
@@ -222,7 +222,7 @@ private[celeborn] class CelebornListener(
     try {
       kvstore.write(AggregatedTaskInfoUIData(
         totalWriteBytes.get(),
-        totalWriteTimeMs.get(),
+        TimeUnit.NANOSECONDS.toMillis(totalWriteTimeNs.get()),
         totalReadBytes.get(),
         totalFetchWaitTimeMs.get(),
         totalTaskDurationMs.get(),
diff --git 
a/client-spark/spark-3-ui/src/test/scala/org/apache/spark/shuffle/celeborn/CelebornListenerSuite.scala
 
b/client-spark/spark-3-ui/src/test/scala/org/apache/spark/shuffle/celeborn/CelebornListenerSuite.scala
index 83d56f9b97..94ffeb6584 100644
--- 
a/client-spark/spark-3-ui/src/test/scala/org/apache/spark/shuffle/celeborn/CelebornListenerSuite.scala
+++ 
b/client-spark/spark-3-ui/src/test/scala/org/apache/spark/shuffle/celeborn/CelebornListenerSuite.scala
@@ -103,6 +103,32 @@ class CelebornListenerSuite {
     assertEquals(120L, agg.compressedShuffleBytes)
   }
 
+  @Test
+  def aggregateSubMillisecondShuffleWriteTimes(): Unit = {
+    val store = new InMemoryStore()
+    val statusStore = new CelebornStatusStore(store)
+    val listener = new CelebornListener(store, new SparkConf())
+
+    def taskWithWriteTime(nanos: Long): SparkListenerTaskEnd = {
+      val task = newTaskEnd(100L, 0L, 0L, 1L)
+      task.taskMetrics.shuffleWriteMetrics.incWriteTime(nanos)
+      task
+    }
+
+    listener.onTaskEnd(taskWithWriteTime(600000L))
+    listener.flush()
+    assertEquals(0L, statusStore.aggregatedTaskInfo().shuffleWriteTimeMs)
+
+    listener.onTaskEnd(taskWithWriteTime(600000L))
+    listener.flush()
+    assertEquals(1L, statusStore.aggregatedTaskInfo().shuffleWriteTimeMs)
+
+    listener.onTaskEnd(taskWithWriteTime(800000L))
+    listener.onTaskEnd(taskWithWriteTime(2000000L))
+    listener.flush()
+    assertEquals(4L, statusStore.aggregatedTaskInfo().shuffleWriteTimeMs)
+  }
+
   @Test
   def compressionRatioSidesComeFromTheSameMapperEndAttemptSet(): Unit = {
     // Regression: a task failing after its writer completed already reported

Reply via email to