-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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][java-client]Shrink BatchMessageContainer maxBatchSize #17854
Conversation
bfa1149
to
875db28
Compare
875db28
to
f079f3d
Compare
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.
Thanks for submitting this patch! Comments inline.
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AbstractBatchMessageContainer.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AbstractBatchMessageContainer.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java
Show resolved
Hide resolved
@tjiuming @Jason918 @merlimat @codelipenghui PTAL thanks |
pulsar-client/src/test/java/org/apache/pulsar/client/impl/BatchMessageContainerImplTest.java
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java
Show resolved
Hide resolved
pulsar-client/src/test/java/org/apache/pulsar/client/impl/BatchMessageContainerImplTest.java
Show resolved
Hide resolved
f54c34e
to
391aeae
Compare
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.
nice work
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.
LGTM. Thank you!
/pulsarbot run-failure-checks |
Motivation
There will be memory waste when producer publishes messages with batch enable, which may cause some problems, e.g., issue #17662 and issue #14943
The PR #15033 try to fixed the memory waste problem but bringing a significant performance regression.
Here we introduce another way to solve the memory waste problem through shrinking the
maxBatchSize
ofBatchMessageContainerImpl
, without bringing performance regression, which will solve the two issues list above.Following is the test result to approve it:
1. Solved memory waste
Reducing the memory waste will be very helpful for this issue: #17662
After applying this PR, following the steps of the issue to reproduce it, we can see that memory will not exceed the client memory limit:
2. Without bring performance regression
buffer : means using
allocator.buffer()
to allocatebatchedMessageMetadataAndPayload
without shrink.shrink : means applied this PR
compositeBuffer : means applied #15033, which using
allocator.compositeBuffer()
to allocatebatchedMessageMetadataAndPayload
Modifications
AbstractBatchMessageContainer#maxBatchSize
if meet the conditions.allocator.compositeBuffer()
toallocator.buffer(Math.min(maxBatchSize, ClientCnx.getMaxMessageSize()))
Verifying this change
org.apache.pulsar.client.impl.BatchMessageContainerImplTest#testUpdateMaxBatchSize
Documentation
doc-not-needed
(Please explain why)
PR in forked repository: AnonHxy#5