@@ -23,7 +23,7 @@ import scala.xml.Node
2323
2424import org .mockito .Mockito .{mock , when , RETURNS_SMART_NULLS }
2525
26- import org .apache .spark .{ LocalSparkContext , SparkConf , SparkFunSuite , Success }
26+ import org .apache .spark ._
2727import org .apache .spark .executor .TaskMetrics
2828import org .apache .spark .scheduler ._
2929import org .apache .spark .ui .jobs .{JobProgressListener , StagePage , StagesTab }
@@ -47,6 +47,14 @@ class StagePageSuite extends SparkFunSuite with LocalSparkContext {
4747 assert(html3.contains(targetString))
4848 }
4949
50+ test(" SPARK-10543: peak execution memory should be per-task rather than cumulative" ) {
51+ val unsafeConf = " spark.sql.unsafe.enabled"
52+ val conf = new SparkConf (false ).set(unsafeConf, " true" )
53+ val html = renderStagePage(conf).toString().toLowerCase
54+ // verify min/25/50/75/max show task value not cumulative values
55+ assert(html.contains(" <td>10.0 b</td>" * 5 ))
56+ }
57+
5058 /**
5159 * Render a stage page started with the given conf and return the HTML.
5260 * This also runs a dummy stage to populate the page with useful content.
@@ -67,12 +75,19 @@ class StagePageSuite extends SparkFunSuite with LocalSparkContext {
6775
6876 // Simulate a stage in job progress listener
6977 val stageInfo = new StageInfo (0 , 0 , " dummy" , 1 , Seq .empty, Seq .empty, " details" )
70- val taskInfo = new TaskInfo (0 , 0 , 0 , 0 , " 0" , " localhost" , TaskLocality .ANY , false )
71- jobListener.onStageSubmitted(SparkListenerStageSubmitted (stageInfo))
72- jobListener.onTaskStart(SparkListenerTaskStart (0 , 0 , taskInfo))
73- taskInfo.markSuccessful()
74- jobListener.onTaskEnd(
75- SparkListenerTaskEnd (0 , 0 , " result" , Success , taskInfo, TaskMetrics .empty))
78+ // Simulate two tasks to test PEAK_EXECUTION_MEMORY correctness
79+ (1 to 2 ).foreach {
80+ taskId =>
81+ val taskInfo = new TaskInfo (taskId, taskId, 0 , 0 , " 0" , " localhost" , TaskLocality .ANY , false )
82+ val peakExecutionMemory = 10
83+ taskInfo.accumulables += new AccumulableInfo (0 , InternalAccumulator .PEAK_EXECUTION_MEMORY ,
84+ Some (peakExecutionMemory.toString), (peakExecutionMemory * taskId).toString, true )
85+ jobListener.onStageSubmitted(SparkListenerStageSubmitted (stageInfo))
86+ jobListener.onTaskStart(SparkListenerTaskStart (0 , 0 , taskInfo))
87+ taskInfo.markSuccessful()
88+ jobListener.onTaskEnd(
89+ SparkListenerTaskEnd (0 , 0 , " result" , Success , taskInfo, TaskMetrics .empty))
90+ }
7691 jobListener.onStageCompleted(SparkListenerStageCompleted (stageInfo))
7792 page.render(request)
7893 }
0 commit comments