Github user CodingCat commented on a diff in the pull request:
https://github.com/apache/spark/pull/7714#discussion_r35752238
--- Diff: core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala
---
@@ -614,6 +585,74 @@ private[worker] class Worker(
webUi.stop()
metricsSystem.stop()
}
+
+ private def trimFinishedExecutorsIfNecessary(): Unit = {
+ if (finishedExecutors.size > retainedExecutors) {
+ finishedExecutors.take(math.max(finishedExecutors.size / 10,
1)).foreach {
--- End diff --
>The logic looks correct. I suppose you can take from the keys() rather
than take pairs and match on them, but this is fine.
yes
> Is this going to cause a ConcurrentModificationException though? you
generally can't do this in Java and this is a JDK class. Does it work because
take definitely makes a copy? Tests will tell us.
I checked this when writing the patch, Scala implements `take(n)` as
```scala
override /*TraversableLike*/ def take(n: Int): Repr = {
val b = newBuilder //returns a empty map
if (n <= 0) b.result()
else {
b.sizeHintBounded(n, this)
var i = 0
val it = iterator
while (i < n && it.hasNext) {
b += it.next
i += 1
}
b.result()
}
}
```
so, I thought it's OK
> Is there in general a thread-safety problem here? I don't think the code
tries to protect this data structure to begin with, so maybe it's not actually
a problem.
Hmm... I checked that when I wrote these lines, it seems that all
operations are done by the actor (now RpcEndPoint), as long as we ensure the
thread-safety of a single RpcEndPoint, it should be fine
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]