Copilot commented on code in PR #3660:
URL: https://github.com/apache/celeborn/pull/3660#discussion_r3071566538


##########
master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala:
##########
@@ -1235,8 +1235,7 @@ private[celeborn] class Master(
       System.currentTimeMillis(),
       requestId)
     gaugeShuffleFallbackCounts()
-    val unknownWorkers = needCheckedWorkerList.asScala.filterNot(w =>
-      statusSystem.workersMap.containsKey(w.toUniqueId)).asJava
+    needCheckedWorkerList.removeAll(statusSystem.workersMap.values())

Review Comment:
   `needCheckedWorkerList.removeAll(statusSystem.workersMap.values())` can be 
O(M×N) because `workersMap` is a `ConcurrentHashMap` (see 
`AbstractMetaManager.workersMap`) and its `values()` view has linear-time 
`contains`, which `removeAll` relies on. Since this runs on every application 
heartbeat, it can become a CPU hotspot on large clusters; prefer 
filtering/removing based on `workersMap.containsKey(w.toUniqueId)` (e.g., 
`removeIf` or building a hash set of known IDs) to keep this O(M).
   ```suggestion
       needCheckedWorkerList.removeIf(worker => 
statusSystem.workersMap.containsKey(worker.toUniqueId))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to