You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/15 09:19:26 UTC

[GitHub] [pulsar] lhotari commented on a change in pull request #12045: Optimize the memory usage of Cache Eviction

lhotari commented on a change in pull request #12045:
URL: https://github.com/apache/pulsar/pull/12045#discussion_r709002098



##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -2108,17 +2111,7 @@ void doCacheEviction(long maxTimestamp) {
     }
 
     private PositionImpl getEarlierReadPositionForActiveCursors() {
-        PositionImpl smallest = null;
-        for (ManagedCursor cursor : activeCursors) {
-            PositionImpl p = (PositionImpl) cursor.getReadPosition();
-            if (smallest == null) {
-                smallest = p;
-            } else if (p.compareTo(smallest) < 0) {
-                smallest = p;
-            }
-        }
-
-        return smallest;
+        return (PositionImpl) (activeCursors.getSlowestReader()).getReadPosition();

Review comment:
       there's also a method called `ManagedCursorContainer.getSlowestReaderPosition()`, could that have been used?




-- 
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: commits-unsubscribe@pulsar.apache.org

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