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

uros-b pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new ea8ee24307c9 [SPARK-58356][CORE] Use exists instead of 
filter(...).nonEmpty in MasterPage
ea8ee24307c9 is described below

commit ea8ee24307c92ad46fb718d777ac2f7a94d234ee
Author: Uros Bojanic <[email protected]>
AuthorDate: Mon Jul 27 04:10:54 2026 +0000

    [SPARK-58356][CORE] Use exists instead of filter(...).nonEmpty in MasterPage
    
    ### What changes were proposed in this pull request?
    Replaces `filter(_.resourcesInfoUsed.nonEmpty).nonEmpty` with 
`exists(_.resourcesInfoUsed.nonEmpty)` in `MasterPage` when deciding whether to 
show the resources column.
    
    ### Why are the changes needed?
    `state.workers` is an `Array[WorkerInfo]`; the `filter(...).nonEmpty` form 
allocates a throwaway filtered array and scans every worker, while `exists` 
allocates nothing and short-circuits on the first match. The resulting Boolean 
is identical.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    Equivalent, behavior-preserving change on a UI code path. No new tests 
needed.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    Generated-by: Claude Code (Opus 4.8)
    
    Closes #57547 from uros-b/perf-masterpage-exists.
    
    Lead-authored-by: Uros Bojanic <[email protected]>
    Co-authored-by: Uros Bojanic <[email protected]>
    Signed-off-by: Uros Bojanic <[email protected]>
    (cherry picked from commit 59734428bf762dc544c2d46e53a1bd55d73a40ef)
    Signed-off-by: Uros Bojanic <[email protected]>
---
 core/src/main/scala/org/apache/spark/deploy/master/ui/MasterPage.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/core/src/main/scala/org/apache/spark/deploy/master/ui/MasterPage.scala 
b/core/src/main/scala/org/apache/spark/deploy/master/ui/MasterPage.scala
index 35da728ab4a4..2f38b6fcfb4f 100644
--- a/core/src/main/scala/org/apache/spark/deploy/master/ui/MasterPage.scala
+++ b/core/src/main/scala/org/apache/spark/deploy/master/ui/MasterPage.scala
@@ -101,7 +101,7 @@ private[ui] class MasterPage(parent: MasterWebUI) extends 
WebUIPage("") {
   def render(request: HttpServletRequest): Seq[Node] = {
     val state = getMasterState
 
-    val showResourceColumn = 
state.workers.filter(_.resourcesInfoUsed.nonEmpty).nonEmpty
+    val showResourceColumn = state.workers.exists(_.resourcesInfoUsed.nonEmpty)
     val workerHeaders = if (showResourceColumn) {
       Seq("Worker Id", "Address", "State", "Cores", "Memory", "Resources")
     } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to