You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mridulm (via GitHub)" <gi...@apache.org> on 2023/09/01 04:39:26 UTC

[GitHub] [spark] mridulm commented on a diff in pull request #42742: [SPARK-45025] Allow block manager memory store iterator to handle thread interrupt and perform task completion gracefully

mridulm commented on code in PR #42742:
URL: https://github.com/apache/spark/pull/42742#discussion_r1312531275


##########
core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala:
##########
@@ -220,7 +220,8 @@ private[spark] class MemoryStore(
     }
 
     // Unroll this block safely, checking whether we have exceeded our threshold periodically
-    while (values.hasNext && keepUnrolling) {
+    // and if no thread interrupts have been received.
+    while (values.hasNext && keepUnrolling && !Thread.currentThread().isInterrupted) {

Review Comment:
   I am slightly wary of calling `isInterrupted` for every iteration.
   Given we already have the `if  (elementsUnrolled ...` condition below, do we want to move it to that ?
   
   IIRC `isInterrupted` is a couple of orders more expensive than a boolean check.
   
   Something like:
   ```
   var interrupted = false
   while (values.hasNext && keepUnrolling && !interrupted) {
     valueHolder ...
     if (... ){
       interrupted = Thread.currentThread().isInterrupted
      ...
   }
   ```
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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