ijuma commented on code in PR #15324:
URL: https://github.com/apache/kafka/pull/15324#discussion_r1488125293


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerStateManager.java:
##########
@@ -177,7 +177,7 @@ private void addProducerId(long producerId, 
ProducerStateEntry entry) {
     }
 
     private void removeProducerIds(List<Long> keys) {
-        producers.keySet().removeAll(keys);
+        keys.forEach(producers.keySet()::remove);

Review Comment:
   This JDK implementation looks risky - it nows `remove` is reasonably cheap 
for a `Set` while `Collection.contains` could be really expensive. It's worth 
adding a comment to the code to make sure someone doesn't revert this change in 
the future.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerStateManager.java:
##########
@@ -177,7 +177,7 @@ private void addProducerId(long producerId, 
ProducerStateEntry entry) {
     }
 
     private void removeProducerIds(List<Long> keys) {
-        producers.keySet().removeAll(keys);
+        keys.forEach(producers.keySet()::remove);

Review Comment:
   This JDK implementation looks risky - it knows `remove` is reasonably cheap 
for a `Set` while `Collection.contains` could be really expensive. It's worth 
adding a comment to the code to make sure someone doesn't revert this change in 
the future.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to