void-ptr974 opened a new pull request, #26019:
URL: https://github.com/apache/pulsar/pull/26019

   ### Motivation
   
   `PendingAcksMap.size()` currently computes the pending ack count by scanning 
all per-ledger pending ack maps. This makes a simple size lookup O(number of 
ledgers), even though callers only need the total number of pending ack entries.
   
   On consumers with many pending acknowledgments, this adds unnecessary CPU 
cost to paths that inspect or drain pending acks.
   
   ### Modifications
   
   Maintain a cached pending ack count in `PendingAcksMap`.
   
   The counter is updated when pending ack entries are added, removed, 
range-removed, or cleared. With this, `PendingAcksMap.size()` becomes an O(1) 
read instead of scanning nested maps.
   
   The change keeps the existing `TreeMap` structure and only optimizes size 
accounting.
   
   ### Verifying this change
   
   - `./gradlew :pulsar-broker:test --tests 
org.apache.pulsar.broker.service.PendingAcksMapTest`
   - `./gradlew :pulsar-broker:checkstyleMain`


-- 
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