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
base: master
Are you sure you want to change the base?
[Fix][broker] Limit replication rate based on bytes #22674
Conversation
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
*/ | ||
private int getAvailablePermits() { | ||
public Pair<Integer, Long> getAvailablePermits() { |
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.
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.
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.
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.
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.
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>
/pulsarbot rerun-failure-checks |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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