Skip to content
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] Improve cursor.getNumberOfEntries if isUnackedRangesOpenCacheSetEnabled=true #17465

Merged
merged 6 commits into from Sep 7, 2022

Conversation

codelipenghui
Copy link
Contributor

Fixes #17451

Motivation

Improve the ManagedCursorImpl.getNumberOfEntries() if isUnackedRangesOpenCacheSetEnabled=true.
Since the ConcurrentOpenLongPairRangeSet has the ability to get the acked count for each Ledger,
the ManagedCursorImpl can avoid iterating each range to calculate the acked count.

Modifications

Make the ConcurrentOpenLongPairRangeSet able to get acked count.

Verifying this change

Unit test for the new method introduced in ConcurrentOpenLongPairRangeSet
The getNumberOfEntries() change is already covered by the existing test

Documentation

Check the box below or label this PR directly.

Need to update docs?

  • doc-not-needed
    (Just an improvement for the presented implementation)

@codelipenghui codelipenghui self-assigned this Sep 5, 2022
@codelipenghui codelipenghui added this to the 2.12.0 milestone Sep 5, 2022
@codelipenghui codelipenghui added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker doc-not-needed Your PR changes do not impact docs release/2.9.4 release/2.11.1 release/2.10.3 labels Sep 5, 2022
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great finding !

@lhotari
Copy link
Member

lhotari commented Sep 5, 2022

Nice optimization

public int cardinality(long lowerKey, long lowerValue, long upperKey, long upperValue) {
NavigableMap<Long, BitSet> subMap = rangeBitSetMap.subMap(lowerKey, true, upperKey, true);
MutableInt v = new MutableInt(0);
subMap.forEach((ledgerId, bitset) -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the class ConcurrentOpenLongPairRangeSet isn't specific to ledgers, would it make sense to avoid using ledgerId as the variable name?

@codelipenghui
Copy link
Contributor Author

@lhotari Thanks for the review. I have updated the PR according to your suggestions; please help take a look again.

Copy link
Member

@wolfstudy wolfstudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Technoboy- Technoboy- merged commit 09edcce into apache:master Sep 7, 2022
@Technoboy- Technoboy- modified the milestones: 2.12.0, 2.11.0 Sep 8, 2022
Technoboy- pushed a commit that referenced this pull request Sep 8, 2022
codelipenghui added a commit that referenced this pull request Sep 9, 2022
…sOpenCacheSetEnabled=true (#17465)

(cherry picked from commit 09edcce)
codelipenghui added a commit that referenced this pull request Sep 9, 2022
…sOpenCacheSetEnabled=true (#17465)

(cherry picked from commit 09edcce)
@lhotari
Copy link
Member

lhotari commented Sep 9, 2022

@lhotari Thanks for the review. I have updated the PR according to your suggestions; please help take a look again.

@codelipenghui LGTM, great improvement in this PR.

nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Sep 16, 2022
…sOpenCacheSetEnabled=true (apache#17465)

(cherry picked from commit 09edcce)
(cherry picked from commit a88ac65)
@codelipenghui codelipenghui deleted the penghui/fix-17451 branch October 28, 2022 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 cherry-picked/branch-2.11 doc-not-needed Your PR changes do not impact docs release/2.9.4 release/2.10.2 type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] if there are many message hole with delay message, sub will very slow and occupy the io thread
7 participants