-
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
[improvement][client-java] Avoid too large memory preallocation for batch message. #15033
Conversation
The pr had no activity for 30 days, mark with Stale label. |
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
@codelipenghui seems the PR is able to merge |
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java
Outdated
Show resolved
Hide resolved
The pr had no activity for 30 days, mark with Stale label. |
@codelipenghui Please help merge the PR |
Please fix the CI failure @tjiuming |
@tjiuming Please provide a correct documentation label for your PR. |
This patch broken |
Hi @merlimat , If we want to avoid any memory copies, I think we could set the valule of |
@AnonHxy Can we do a quick test to validate this? Focus on the case with large number of messages in one batch. |
Sure |
@AnonHxy If we are writing bytes into the composite buffer, it either needs to have space into its own last buffer or to allocate a buffer and copy data into it. |
@merlimat @AnonHxy @Jason918 |
Allocating many small buffers will have a significant large impact compared to allocating 1 single large buffer:
|
@merlimat
which means for a Producer, only 1 thread could send message at the same time, I think even there is allocator synchronization, it wouldn't have a significant large impact.
For this part, I don't think it will make a big difference. Yes, read bytes from I think the only problem is when the batch is |
@AnonHxy Is there a significant throughput difference between these two? |
OK. @Jason918
|
And here is the attachment of Flame Graph for the first time test |
Fixes (#14943)
Motivation
Allocate small memory for batch message first, and let it grow(with no memory resizes and memory copies).
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
Check the box below or label this PR directly (if you have committer privilege).
Need to update docs?
doc-required
(If you need help on updating docs, create a doc issue)
no-need-doc
(Please explain why)
doc
(If this PR contains doc changes)