mridulm commented on a change in pull request #26682: [SPARK-29306][CORE] Stage 
Level Sched: Executors need to track what ResourceProfile they are created with 
URL: https://github.com/apache/spark/pull/26682#discussion_r370982539
 
 

 ##########
 File path: 
core/src/main/scala/org/apache/spark/scheduler/dynalloc/ExecutorMonitor.scala
 ##########
 @@ -392,8 +418,26 @@ private[spark] class ExecutorMonitor(
    * which the `SparkListenerTaskStart` event is posted before the 
`SparkListenerBlockManagerAdded`
    * event, which is possible because these events are posted in different 
threads. (see SPARK-4951)
    */
-  private def ensureExecutorIsTracked(id: String): Tracker = {
-    executors.computeIfAbsent(id, _ => new Tracker())
+  private def ensureExecutorIsTracked(id: String, resourceProfileId: Int): 
Tracker = {
+    val numExecsWithRpId = 
execResourceProfileCount.computeIfAbsent(resourceProfileId, _ => 0)
+    val execTracker = executors.computeIfAbsent(id, _ => {
+        val newcount = numExecsWithRpId + 1
+        execResourceProfileCount.put(resourceProfileId, newcount)
+        logDebug(s"Executor added with ResourceProfile id: $resourceProfileId 
" +
+          s"count is now $newcount")
+        new Tracker(resourceProfileId)
+      })
 
 Review comment:
   What is the impact if concurrent updates to execResourceProfileCount (via 
put) result in inconsistency w.r.t execResourceProfileCount itself and w.r.t 
executors ? (due to the 'put' happening - across this class).
   If we expect execResourceProfileCount for some key to be some value V while 
updating it to V1, we could use compute() instead and ensure the invariant is 
satisfied ? Or do we not expect this to happen ?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to