This is an automated email from the ASF dual-hosted git repository. srowen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 6341310711e [SPARK-44895][CORE][UI] Add 'daemon', 'priority' for ThreadStackTrace 6341310711e is described below commit 6341310711ee0e3edbdd42aaeaf806cad4edefb5 Author: Kent Yao <y...@apache.org> AuthorDate: Thu Sep 28 18:04:03 2023 -0500 [SPARK-44895][CORE][UI] Add 'daemon', 'priority' for ThreadStackTrace ### What changes were proposed in this pull request? Since version 9, Java has supported the 'daemon' and 'priority' fields in ThreadInfo. In this PR, we extract them from ThreadInfo to ThreadStackTrace ### Why are the changes needed? more information for thread pages in UI and rest APIs ### Does this PR introduce _any_ user-facing change? yes, ThreadStackTrace changes ### How was this patch tested? new tests ### Was this patch authored or co-authored using generative AI tooling? no Closes #43095 from yaooqinn/SPARK-44895. Authored-by: Kent Yao <y...@apache.org> Signed-off-by: Sean Owen <sro...@gmail.com> --- .../main/scala/org/apache/spark/status/api/v1/api.scala | 10 ++++++---- core/src/main/scala/org/apache/spark/util/Utils.scala | 4 +++- .../test/scala/org/apache/spark/ui/UISeleniumSuite.scala | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/status/api/v1/api.scala b/core/src/main/scala/org/apache/spark/status/api/v1/api.scala index 3e4e2f17a77..7a0c69e2948 100644 --- a/core/src/main/scala/org/apache/spark/status/api/v1/api.scala +++ b/core/src/main/scala/org/apache/spark/status/api/v1/api.scala @@ -540,19 +540,21 @@ case class ThreadStackTrace( lockName: Option[String], lockOwnerName: Option[String], suspended: Boolean, - inNative: Boolean) { + inNative: Boolean, + isDaemon: Boolean, + priority: Int) { /** * Returns a string representation of this thread stack trace * w.r.t java.lang.management.ThreadInfo(JDK 8)'s toString. * - * TODO(SPARK-44895): Considering 'daemon', 'priority' from higher JDKs - * * TODO(SPARK-44896): Also considering adding information os_prio, cpu, elapsed, tid, nid, etc., * from the jstack tool */ override def toString: String = { - val sb = new StringBuilder(s""""$threadName" Id=$threadId $threadState""") + val daemon = if (isDaemon) " daemon" else "" + val sb = new StringBuilder( + s""""$threadName"$daemon prio=$priority Id=$threadId $threadState""") lockName.foreach(lock => sb.append(s" on $lock")) lockOwnerName.foreach { owner => sb.append(s"""owned by "$owner"""") diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 48dfbecb7cd..dcffa99dc64 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -2196,7 +2196,9 @@ private[spark] object Utils Option(threadInfo.getLockName), Option(threadInfo.getLockOwnerName), threadInfo.isSuspended, - threadInfo.isInNative) + threadInfo.isInNative, + threadInfo.isDaemon, + threadInfo.getPriority) } /** diff --git a/core/src/test/scala/org/apache/spark/ui/UISeleniumSuite.scala b/core/src/test/scala/org/apache/spark/ui/UISeleniumSuite.scala index dd9927d7ba1..7e74cc9287f 100644 --- a/core/src/test/scala/org/apache/spark/ui/UISeleniumSuite.scala +++ b/core/src/test/scala/org/apache/spark/ui/UISeleniumSuite.scala @@ -885,6 +885,20 @@ class UISeleniumSuite extends SparkFunSuite with WebBrowser with Matchers { } } + test("SPARK-44895: Add 'daemon', 'priority' for ThreadStackTrace") { + withSpark(newSparkContext()) { sc => + val uiThreads = getJson(sc.ui.get, "executors/driver/threads") + .children + .filter(v => (v \ "threadName").extract[String].matches("SparkUI-\\d+")) + val priority = Thread.currentThread().getPriority + + uiThreads.foreach { v => + assert((v \ "isDaemon").extract[Boolean]) + assert((v \ "priority").extract[Int] === priority) + } + } + } + def goToUi(sc: SparkContext, path: String): Unit = { goToUi(sc.ui.get, path) } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org