-
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] [broker] Improve CPU resources usege of TopicName Cache #23052
[improve] [broker] Improve CPU resources usege of TopicName Cache #23052
Conversation
/pulsarbot rerun-failure-checks |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #23052 +/- ##
============================================
- Coverage 73.57% 73.45% -0.12%
- Complexity 32624 33503 +879
============================================
Files 1877 1915 +38
Lines 139502 143956 +4454
Branches 15299 15727 +428
============================================
+ Hits 102638 105743 +3105
- Misses 28908 30113 +1205
- Partials 7956 8100 +144
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
Outdated
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Outdated
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/naming/NamespaceName.java
Outdated
Show resolved
Hide resolved
b96dbbd
to
e794b67
Compare
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java
Show resolved
Hide resolved
Here is the benchmark's source code: https://github.com/BewareMyPower/CacheBenchmark A typical output:
The overhead for expiration seems significant. @ben-manes @lhotari Please help review if there is something wrong with it. The motivation is that the time cost of parsing a |
Thanks! I’ll look later today (it’s late my time). If you are running this on Mac/Windows then reading the current time is a system call, iirc. That’s much slower than a user space call like Linux, so that can artificially skew your results by not being matching the deployment destination. The ticker can be defined if truly necessary to optimize the clock reads. |
3f19821
to
61a7595
Compare
pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
Show resolved
Hide resolved
Co-authored-by: Zixuan Liu <nodeces@gmail.com>
The concern is not important, we can impove the code in ther future
Since @ben-manes and @lhotari did not answer, let me merge it first. We can improve the code continuously in the future. |
Good job! LGTM. |
…ache#23052) Co-authored-by: Zixuan Liu <nodeces@gmail.com> (cherry picked from commit 81aed6c) (cherry picked from commit 5a83958)
…ache#23052) Co-authored-by: Zixuan Liu <nodeces@gmail.com> (cherry picked from commit 81aed6c) (cherry picked from commit 5a83958)
Motivation
LoadableCache.get
cost too many CPU resourcesbroker_cpu.html.txt
Modifications
Because there is no need for a strict invalidate time, change the implementation to
ConcurrentHashMap
.after_improvement.html
Performance review
Env
master
11000
topics.110
partitioned topic, each partitioned topic contains100
partitionspublic/default/{uuid}
enableBrokerSideSubscriptionPatternEvaluation
:false
2.11.4
1
client with220
pattern consumers220
consumers can put pressure make the broker’s CPU usage to keep 90%16
timer task for220
consumers ( in default, there is only a single timer for each client )patternAutoDiscoveryPeriod
toseconds
, and set it to 1connectionsPerBroker
: 100Test cases:
Caffiene Cache
perf_result.zip
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: x