Skip to content

Commit 8506404

Browse files
yaooqinndongjoon-hyun
authored andcommitted
[SPARK-52502][UI] Thread count overview
### What changes were proposed in this pull request? This PR proposes to add a thread count overview to the thread dump pages ### Why are the changes needed? Thread-consuming is a critical feature for driver and executor JVMs ### Does this PR introduce _any_ user-facing change? Yes, UI updates ### How was this patch tested? Build and test locally ![image](https://github.com/user-attachments/assets/08278492-8718-46cc-9334-4c1406ade904) ### Was this patch authored or co-authored using generative AI tooling? no Closes #51197 from yaooqinn/SPARK-52502. Authored-by: Kent Yao <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent fd74b5e commit 8506404

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

core/src/main/scala/org/apache/spark/ui/exec/ExecutorThreadDumpPage.scala

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private[ui] class ExecutorThreadDumpPage(
7373
<div class="row">
7474
<div class="col-12">
7575
<p>Updated at {UIUtils.formatDate(time)}</p>
76+
{threadDumpSummary(threadDump)}
7677
{ if (flamegraphEnabled) {
7778
drawExecutorFlamegraph(request, threadDump) }
7879
else {
@@ -123,10 +124,8 @@ private[ui] class ExecutorThreadDumpPage(
123124
</div>
124125
}.getOrElse(Text("Error fetching thread dump"))
125126
UIUtils.headerSparkPage(request, s"Thread dump for executor $executorId", content, parent)
126-
// scalastyle:on
127127
}
128128

129-
// scalastyle:off
130129
private def drawExecutorFlamegraph(request: HttpServletRequest, thread: Array[ThreadStackTrace]): Seq[Node] = {
131130
val js =
132131
s"""
@@ -154,5 +153,32 @@ private[ui] class ExecutorThreadDumpPage(
154153
</div>
155154
</div>
156155
}
157-
// scalastyle:off
156+
157+
158+
private def threadDumpSummary(threadDump: Array[ThreadStackTrace]): Seq[Node] = {
159+
val totalCount = threadDump.length
160+
<div>
161+
<span class="thead-dump-summary collapse-table" onClick="collapseTable('thead-dump-summary', 'thread-dump-summary-table')">
162+
<h4>
163+
<span class="collapse-table-arrow arrow-open"></span>
164+
<a>Thread Dump Summary: { totalCount }</a>
165+
</h4>
166+
</span>
167+
<table class={UIUtils.TABLE_CLASS_STRIPED + " accordion-group" + " sortable" + " thread-dump-summary-table collapsible-table"}>
168+
<thead><th>Thread State</th><th>Count</th><th>Percentage</th></thead>
169+
<tbody>
170+
{
171+
threadDump.groupBy(_.threadState).map { case (state, threads) =>
172+
<tr>
173+
<td>{state}</td>
174+
<td>{threads.length}</td>
175+
<td>{"%.2f%%".format(threads.length * 100.0 / totalCount)}</td>
176+
</tr>
177+
}.toSeq
178+
}
179+
</tbody>
180+
</table>
181+
</div>
182+
}
183+
// scalastyle:on
158184
}

0 commit comments

Comments
 (0)