Repository navigation
[improve][broker] Make MessageRedeliveryController work more efficiently - #17804
Merged
codelipenghui merged 2 commits intoSep 23, 2022
Merged
Conversation
mattisonchao
approved these changes
Sep 23, 2022
| } | ||
| } | ||
|
|
||
| public synchronized void removeUpTo(long item1, long item2) { |
Member
There was a problem hiding this comment.
Question: why do we need synchronized here?
Contributor
Author
There was a problem hiding this comment.
😁, I copied the method signature from another class
| import org.apache.pulsar.common.util.collections.LongPairSet; | ||
| import org.roaringbitmap.RoaringBitmap; | ||
|
|
||
| public class BitmapSortedLongPairSet { |
Member
There was a problem hiding this comment.
Maybe we can indicate this class is thread-safe by adding a comment or name like Concurrent***?
315157973
reviewed
Sep 23, 2022
Comment on lines
+76
to
+79
| Map.Entry<Long, RoaringBitmap> firstEntry = map.firstEntry(); | ||
| while (firstEntry != null && firstEntry.getKey() <= item1) { | ||
| if (firstEntry.getKey() < item1) { | ||
| map.remove(firstEntry.getKey(), firstEntry.getValue()); |
Contributor
There was a problem hiding this comment.
Is it possible to avoid loop traversal by using subMap?
Contributor
Author
There was a problem hiding this comment.
Sub map will have the low and upper boundaries. If we change to sub map here e.g. from 3 to 10, you will not able to add 2 or 11 again.
coderzc
reviewed
Sep 23, 2022
coderzc
approved these changes
Sep 23, 2022
315157973
approved these changes
Sep 23, 2022
nicoloboschi
pushed a commit
to datastax/pulsar
that referenced
this pull request
Sep 28, 2022
…tly (apache#17804) (cherry picked from commit c60f895) (cherry picked from commit 19eb842)
dragonls
pushed a commit
to dragonls/pulsar
that referenced
this pull request
Oct 21, 2022
…tly (apache#17804) (cherry picked from commit c60f895)
dragonls
pushed a commit
to dragonls/pulsar
that referenced
this pull request
Oct 21, 2022
…request !71) [improve][broker] Make MessageRedeliveryController work more efficiently (apache#17804)
2 of 15 tasks
2 of 15 tasks
Closed
1 of 2 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.
Fixes: #15445
Motivation
The implementation of MessageRedeliveryController is inefficient
The issue usually happens if you have a large number of backlogs with the Key_Shared subscription. The publish latency will go high due to the IO thread and
BookKeeperClientWorkerthread with high high CPU usageA related fix #15354, but the fix can't fix the case that the
MessageRedeliveryControllerhave many redelivery messagesThis PR can make the
MessageRedeliveryControllerwork more efficiently by introducing a new Ordered Map and Bitmap based LongPair Ordered SetAnd the issue can be reproduced by standalone and pulsar-perf
bin/pulsar-perf produce test -r 1000 -bm 1 -mk randombin/pulsar-perf consume -st Key_Shared -r 100 -n 50 testWith this PR, the situation will not happen
Modifications
Verifying this change
New test added BitmapSortedLongPairSetTest
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc-required(Your PR needs to update docs, and you will update later)
doc-not-needed(Please explain why)
doc(Your PR contains doc changes)
doc-complete(Docs have been already added)
Matching PR in forked repository
PR in forked repository: codelipenghui#14