-
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]Add init capacity for messages in BatchMessageContainerImpl #17822
Conversation
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java
Show resolved
Hide resolved
f3b59bf
to
1d7f302
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.
LGTM
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
it is worth to cherry-pick this to branch-2.10 and branch-2.11
/pulsarbot ready-to-test |
@AnonHxy just curious which VM/platform you are running on. I'm wondering about the large portion of "gettimeofday" as part of the stack Regarding "gettimeofday", there's a Brendan Gregg blog post "The Speed Of Time". In many cases, the fastest clocksource on Linux is tsc. GCP's GKE uses tsc by default. Since Arrays.copyOf / System.arraycopy (or it's native implementations) don't seem to call gettimeofday at all, it might be GC related activity which is happening. The default initial size for ArrayList is 10. In this PR it's changed to 64. That could make sense. However, I would assume that the average batch size is very rarely over 20, so this change won't make a difference in most cases. Since average batch size is rarely over 20, a better default could be a lower value, such as 32. |
the gettimeofday stack looks like MacOS, https://opensource.apple.com/source/xnu/xnu-3789.41.3/libsyscall/wrappers/__commpage_gettimeofday.c.auto.html |
Thanks for your reminder @lhotari , There is anothoer profiling result on Linux, the simiar conclusions can be drawn. |
It makes sense to me. Updated default capacity from 64 to 32. PTAL @lhotari |
Can you share the whole flamegraph? A lot of information is lost if you just provide a snippet of the whole graph. |
OK, here is the flamegraph file. @lhotari test case is below
|
/pulsarbot run-failure-checks |
…ontainerImpl (apache#17822) (cherry picked from commit 15a347c) (cherry picked from commit 166a7ab)
…ontainerImpl (apache#17822) (cherry picked from commit 15a347c) (cherry picked from commit 166a7ab)
Motivation
When adding messages to
BatchMessageContainerImpl
, it takes a lot of cpu time for the list growing ofBatchMessageContainerImpl#messages
, see below:Modifications
BatchMessageContainerImpl#messages
with capacity.Verifying this change
Documentation
doc-required
(Your PR needs to update docs and you will update later)
doc-not-needed
(Please explain why)
doc
(Your PR contains doc changes)
doc-complete
(Docs have been already added)
Matching PR in forked repository
PR in forked repository: AnonHxy#3