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

[Fix][broker] Limit replication rate based on bytes #22674

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nodece
Copy link
Member

@nodece nodece commented May 8, 2024

Motivation

When the replicator rate limit value based on bytes is less than the org.apache.pulsar.broker.service.persistent.PersistentReplicator#readMaxSizeBytes, this will cause the outgoing bytes to exceed the limit value.

The goal is to make outgoing bytes as close to the rate limit value as possible.

Modifications

  • org.apache.pulsar.broker.service.persistent.PersistentReplicator#getAvailablePermits returns the available messages and bytes, and then reads the entries based on that.

Verifying this change

The test has been added.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece nodece requested a review from lhotari May 8, 2024 10:38
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label May 8, 2024
*/
private int getAvailablePermits() {
public Pair<Integer, Long> getAvailablePermits() {
Copy link
Member

Choose a reason for hiding this comment

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

It's better to use a record than to use Pair. Pair results in hard-to-read code. An additional reason here is that Integer and Long are boxed objects which are adding additional overhead compared to a record.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add a class to hold the available messages and bytes, so like:

    @Data
    @AllArgsConstructor
    private static class AvailablePermits {
        private int messages;
        private long bytes;
    }

record requires the JDK 14, we cannot cherry-pick this PR to the previous version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ping @lhotari

Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece
Copy link
Member Author

nodece commented May 13, 2024

/pulsarbot rerun-failure-checks

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 65.38462% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 73.18%. Comparing base (bbc6224) to head (a3277c3).
Report is 264 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #22674      +/-   ##
============================================
- Coverage     73.57%   73.18%   -0.40%     
- Complexity    32624    32849     +225     
============================================
  Files          1877     1889      +12     
  Lines        139502   141370    +1868     
  Branches      15299    15515     +216     
============================================
+ Hits         102638   103457     +819     
- Misses        28908    29911    +1003     
- Partials       7956     8002      +46     
Flag Coverage Δ
inttests 27.52% <42.30%> (+2.93%) ⬆️
systests 24.70% <0.00%> (+0.38%) ⬆️
unittests 72.20% <65.38%> (-0.65%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...roker/service/persistent/PersistentReplicator.java 67.54% <65.38%> (-1.34%) ⬇️

... and 353 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants