-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[improve][broker] Improve the performance of TopicName #24463
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
base: master
Are you sure you want to change the base?
[improve][broker] Improve the performance of TopicName #24463
Conversation
Before 48ffb7a, there is a constructor parameter that determines whether to initialize the The benchmark result is:
As you can see
|
I wouldn't trust JMH results from benchmarking on Mac OS. In the case of PR #24457, the results are very different when benchmarking on Linux x86_64 with Intel i9 processor (Dell XPS 2019 laptop). |
@lhotari So could you help run benchmark in your Linux environment to see the difference? I can also create a workflow via GitHub Actions to see the result. |
I don't want to debate about it in this PR. If you have a chance to look at how The ultimate solution is to create some utils methods instead of leveraging the |
Updated test results to compare it with the legacy implementation in https://github.com/BewareMyPower/pulsar/actions/runs/15872434081/job/44752001433?pr=45
|
48ffb7a
to
355140a
Compare
@lhotari @codelipenghui @nodece @dao-jun @poorbarcode @coderzc This PR is now ready to review, PTAL |
Motivation
The
TopicName
's constructor has poor performance:NamespaceName#get
is very slowSplitter.on("/").splitToList(rest)
is slowString.format
is slower than the+
operation on strings andcompleteTopicName
is unnecessarily created againModifications
NamespaceName
in a lazy waySplitter
with a manually writtensplitBySlash
introduced from [fix][proxy] Fix proxy OOM by replacing TopicName with a simple conversion method #24465. Actually,StringUtils#split
has good performance as well. But it will split"//xxx/yyy/zzz"
to["xxx", "yyy", "zzz"]
without reporting any error.completeTopicName
from the argument directly without any concentrate operationString.format
with+
infromPersistenceNamingEncoding
TopicNameBenchmark
for benchmarkExpose the constructor, so the downstream can choose not to use the buggy
TopicName
cache or establish its custom cache mechanism forTopicName
.Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: BewareMyPower#44