vanzin commented on a change in pull request #24616: [SPARK-27726] [Core] Fix
performance of ElementTrackingStore deletes when using InMemoryStore under high
loads
URL: https://github.com/apache/spark/pull/24616#discussion_r284494865
##########
File path:
core/src/main/scala/org/apache/spark/status/ElementTrackingStore.scala
##########
@@ -46,7 +50,26 @@ import org.apache.spark.util.kvstore._
*/
private[spark] class ElementTrackingStore(store: KVStore, conf: SparkConf)
extends KVStore {
- private val triggers = new HashMap[Class[_], Seq[Trigger[_]]]()
+ private class LatchedTriggers(val triggers: Seq[Trigger[_]]) {
+ val countDeferred = new AtomicInteger(0)
+
+ def fireOnce(f: Seq[Trigger[_]] => Unit): Boolean = {
+ val shouldExecute = countDeferred.compareAndSet(0, 1)
+ if (shouldExecute) {
+ doAsync {
+ countDeferred.set(0)
+ f(triggers)
+ }
+ }
+ shouldExecute
Review comment:
You could avoid the `WriteQueueResult` object with an inlined `if...else`
here.
----------------------------------------------------------------
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]