You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/10 00:37:48 UTC

[GitHub] [spark] maropu commented on a change in pull request #24028: [SPARK-26917][SQL] Further reduce locks in CacheManager

maropu commented on a change in pull request #24028: [SPARK-26917][SQL] Further reduce locks in CacheManager
URL: https://github.com/apache/spark/pull/24028#discussion_r264019535
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
 ##########
 @@ -144,16 +144,10 @@ class CacheManager extends Logging {
       } else {
         _.sameResult(plan)
       }
-    val plansToUncache = mutable.Buffer[CachedData]()
-    readLock {
-      val it = cachedData.iterator()
-      while (it.hasNext) {
-        val cd = it.next()
-        if (shouldRemove(cd.plan)) {
-          plansToUncache += cd
-        }
-      }
+    val cachedDataCopy = readLock {
+      cachedData.asScala.clone()
     }
+    val plansToUncache = cachedDataCopy.filter(cd => shouldRemove(cd.plan))
 
 Review comment:
   It seems we always use `whole` loops when performance should be a concern:
   https://github.com/databricks/scala-style-guide#traversal-and-zipwithindex
   No actual performance impact between the two pattens on your heavy workload?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org