rkhachatryan commented on code in PR #29954:
URL: https://github.com/apache/flink/pull/29954#discussion_r4648045683


##########
flink-runtime/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/TaskMailboxImpl.java:
##########
@@ -147,20 +179,29 @@ private Optional<Mail> tryTake(int priority, boolean 
ignoreDeferrable) {
         checkIsMailboxThread();
         checkTakeStateConditions();
 
+        Mail urgentHead = takeUrgentIfPending(priority, false);

Review Comment:
   I considered it, but the paths differ (lock-free batch vs. locked queues, 
blocking vs. non-blocking, priority filtering), so a generic loop wouldn't 
remove much. I'd prefer to keep it explicit.
   



##########
flink-runtime/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/TaskMailboxImpl.java:
##########
@@ -254,15 +327,21 @@ private Mail takeOrNull(Deque<Mail> queue, int priority, 
boolean ignoreDeferrabl
         return null;
     }
 
+    /** Drains all mails in the order in which they would be taken: urgent, 
batch, normal. */
     @Override
     public List<Mail> drain() {
-        List<Mail> drainedMails = new ArrayList<>(batch);
-        batch.clear();

Review Comment:
   `createBatch` already moved mails from the queue under the lock before; 
`addAll` + `clear` costs about the same. `drain()` is only called on close.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to