-
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
[fix][client] Reserve allocated buffer in BatchMessageContainer on client memory limitation. #17936
Conversation
284e110
to
c5e3d16
Compare
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
Outdated
Show resolved
Hide resolved
a37be35
to
32ef485
Compare
32ef485
to
ed4b8f1
Compare
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
@codelipenghui @Jason918 @merlimat PTAL :) |
/pulsarbot run-failure-checks |
Codecov Report
@@ Coverage Diff @@
## master #17936 +/- ##
=========================================
Coverage ? 49.39%
Complexity ? 6908
=========================================
Files ? 393
Lines ? 43424
Branches ? 4464
=========================================
Hits ? 21451
Misses ? 19595
Partials ? 2378
Flags with carried forward coverage won't be shown. Click here to find out more. |
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, left a minor comment.
Motivation
We should reserve the allocated buffer in BatchMessageContainer on client memory limitation.
Modifications
In this patch, we only take care of the buffer init size and final size
Added a variable
batchAllocatedSize
inBatchMessageContainer
to record the current allocated buffer size. It is used to release the allocated buffer size from memory limit controllerAdded a method
reserveBatchAllocatedSizeWhenInit()
inBatchMessageContainer
, will be call when init the allocated buffer. This method will initiliaze thebatchAllocatedSize
and reserve memory to the memory limit controller.Added a method
updateBatchAllocatedSizeWhenLeave()
inBatchMessageContainer
, will be call when the batch leaving theBatchMessageContainer
. This method will update the finalbatchAllocatedSize
as the size after compress.Then the value of
batchAllocatedSize
will be added toOpSendMsg#uncompressedSize
for release thebatchAllocatedSize
memory from memory limit controller when send succesfully or failed.The following diagram could be helpful to understand this patch
Verifying this change
org.apache.pulsar.client.api.MemoryLimitTest
org.apache.pulsar.client.impl.ProducerMemoryLimitTest
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: AnonHxy#9