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

   ### Motivation
   
   The consumer will apply the default batch receive policy even if the user 
will not use the batch receive API.
   
   
https://github.com/apache/pulsar/blob/6704f12104219611164aa2bb5bbdfc929613f1bf/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/BatchReceivePolicy.java#L60-L61
   
   This will consume lots of CPU if the client has many consumers (100k 
consumers)
   
   <img width="1846" alt="image" 
src="https://user-images.githubusercontent.com/12592133/174783886-a4da085d-2cb8-4153-ba96-19414be65502.png";>
   
   
[consumer-cpu-threads.html.txt](https://github.com/apache/pulsar/files/8948238/consumer-cpu-threads.html.txt)
   
   The Pulsar perf tool can also reproduce the problem if run the test with 
many consumers
   
   ### Modification
   
   If there is no pending batch receive operation for a consumer, no need to 
trigger the
   batch timeout task periodically. We can only start the timeout check after 
adding batch
   receive request to pending request queue.
   
   Remove the lock in MultiTopicsConsumerImpl as #10352 does
   
   ### Verification
   
   Added new test to verify the batch receive timeout task will not start if no 
batch
   receive request
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
     
   - [x] `doc-not-needed` 
   (Please explain why)
     
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already added)


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