poorbarcode opened a new pull request, #19344:
URL: https://github.com/apache/pulsar/pull/19344

   ### Motivation
   
   When we call `pulsar-admin topics stats`, we calculate the backlog size of 
each subscription; during this process, managed-ledger's synchronization lock 
is used(see `code-1` below), which affects the sending of messages. If there 
are `N` subscriptions under this topic, then will acquire this synchronization 
lock N times , which magnifies the impact.
   
   #### Code-1: synchronization in ManagedLedger
   
   
https://github.com/apache/pulsar/blob/644be5fdd6d080accffd72229b2e21e35a27d722/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L1269-L1283
   
   ### Modifications
   
   <strong>(Highlight)</strong>No matter how many subscriptions there are, the 
synchronization lock in the managed ledger is only acquired once when 
`pulsar-admin topics stats` is called.
   - Take a snapshot of the Managed ledger (which would require a lock to 
ensure that multiple variables match), and then use the snapshot to calculate 
backlog size for each subscription(this will incur excess memory).
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local 
preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR 
description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: 
   - https://github.com/poorbarcode/pulsar/pull/55
   


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