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/11/17 05:11:08 UTC

[GitHub] [pulsar] AndrewJD79 opened a new issue #12844: [pulsar-client-cpp] Excessive locking cause significant performance degradation

AndrewJD79 opened a new issue #12844:
URL: https://github.com/apache/pulsar/issues/12844


   **Describe the bug**
   Implementation of statistics in cpp client have two concurrency issues.
   
   1. ProducerStatsImpl (and ConsumerStatsImpl) classes use a single shared lock to protect access to internal data.  The lock is taken on each sent or received message. Under high load this shared lock causes signficant contention and performance degradation.
   Profiler shows that sending and receiving threads block each-other.
   
   ![original-profiling](https://user-images.githubusercontent.com/2276675/142137028-b1dab92d-d6a4-47c3-84fd-666bccfd188a.png)
   
   Since sending and receving functions access different member subset they should be protected by different mutex or other approach should be selected.
   As example after patching issue I've got about 1/3 throughtput improvement. As you can see on screenshot below threads are witing on I/O but not on mutexes.
   ![pathed-profiling](https://user-images.githubusercontent.com/2276675/142137475-36f31817-29da-43d5-9ddd-ecbbb4948d8b.png)
   
   
   2. ProducerStatsImpl implementation has races between destructor and DeadlineTimer callback. Consider following scenario:
   
   
      1. ProducerStatsImpl  destructor acquire the mutex
      2. DeadlineTimer calls calback flushAndReset and blocked on mutex
      3. ProducerStatsImpl  calls timer.cancel and cancel any pending operation but it cannot cancel already executed calbback at step 2
      4. ProducerStatsImpl  destructor release mutex 
      5. DeadlineTimer acquire the mutex 
      6. ProducerStatsImpl  destructor destroy object
      7. DeadlineTimer callback access to deallocated memory
   
   Are you willing accept PR for issue one or both?
   
   


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



[GitHub] [pulsar] github-actions[bot] commented on issue #12844: [pulsar-client-cpp] Excessive locking cause significant performance degradation

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #12844:
URL: https://github.com/apache/pulsar/issues/12844#issuecomment-1069835769


   The issue had no activity for 30 days, mark with Stale label.


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



[GitHub] [pulsar] AndrewJD79 commented on issue #12844: [pulsar-client-cpp] Excessive locking cause significant performance degradation

Posted by GitBox <gi...@apache.org>.
AndrewJD79 commented on issue #12844:
URL: https://github.com/apache/pulsar/issues/12844#issuecomment-976066157


   I'll provide PR in a few days 


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



[GitHub] [pulsar] merlimat commented on issue #12844: [pulsar-client-cpp] Excessive locking cause significant performance degradation

Posted by GitBox <gi...@apache.org>.
merlimat commented on issue #12844:
URL: https://github.com/apache/pulsar/issues/12844#issuecomment-971885581


   > Are you willing accept PR for issue number one or both?
   
   @AndrewJD79 Fixes for any of these are warmly welcomed. 


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