Repository navigation
[improve][broker] Optimize the performance of individual acknowledgments - #23072
Merged
Merged
Conversation
shibd
requested review from
Technoboy-,
congbobo184,
gaoran10,
hangc0276,
lhotari,
poorbarcode and
zymap
July 24, 2024 13:38
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.
🚀 New features to boost your workflow:
|
gaoran10
reviewed
Jul 25, 2024
lhotari
reviewed
Jul 29, 2024
lhotari
approved these changes
Jul 29, 2024
gaoran10
approved these changes
Jul 29, 2024
nikhil-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 30, 2024
…nts (apache#23072) (cherry picked from commit 77b6378) (cherry picked from commit 487913e)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 30, 2024
…nts (apache#23072) (cherry picked from commit 77b6378) (cherry picked from commit 487913e)
2 of 3 tasks
2 of 3 tasks
hanmz
pushed a commit
to hanmz/pulsar
that referenced
this pull request
Feb 12, 2025
1 of 14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 IDThis 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
getAckOwnerConsumermethod 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
docdoc-requireddoc-not-neededdoc-complete