-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][broker] Optimize the performance of individual acknowledgments #23072
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #23072 +/- ##
============================================
- Coverage 73.57% 73.44% -0.13%
- Complexity 32624 33503 +879
============================================
Files 1877 1917 +40
Lines 139502 144051 +4549
Branches 15299 15734 +435
============================================
+ Hits 102638 105803 +3165
- Misses 28908 30127 +1219
- Partials 7956 8121 +165
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch @shibd . Added a suggestion about renaming a method & variable since the meaning has changed.
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
Outdated
Show resolved
Hide resolved
…nts (apache#23072) (cherry picked from commit 77b6378) (cherry picked from commit 487913e)
…nts (apache#23072) (cherry picked from commit 77b6378) (cherry picked from commit 487913e)
Motivation
If a subscription has many consumers and each consumer individually acknowledges messages from other consumers, this scenario is very CPU resource-intensive.
Refer this:
In fact, these three methods achieve the same goal:
get owning consumer by message ID
This operation is very CPU resource-intensive
getAckOwnerConsumer:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
Lines 735 to 748 in d7e8ea1
getBatchSize:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
Line 657 in d7e8ea1
removePendingAcks:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
Lines 1024 to 1034 in d7e8ea1
Modifications
This PR ensures that the
getAckOwnerConsumer
method is called only once during the processing of a message ack. In the future, we may need to optimize this method further.After this PR:
ATT: Client Side Test Code: https://gist.github.com/shibd/82b77eccc8145ac2c1784aca97a29c24
Verifying this change
All tests passed to make sure not have any break change.
Documentation
doc
doc-required
doc-not-needed
doc-complete