-
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] Optimize and clean up aggregation of topic stats #21361
[improve][broker] Optimize and clean up aggregation of topic stats #21361
Conversation
- getPublishers is a costly method that is called in each loop twice - also optimize and clean up code form subscription and replication stats
0caea0c
to
49d31a8
Compare
Can we also cache the sorted publisher list? It seems unnecessary to sort the same list repeatedly. |
Codecov Report
@@ Coverage Diff @@
## master #21361 +/- ##
=============================================
+ Coverage 33.49% 73.32% +39.83%
- Complexity 12257 32553 +20296
=============================================
Files 1636 1888 +252
Lines 127789 140255 +12466
Branches 13963 15435 +1472
=============================================
+ Hits 42798 102846 +60048
+ Misses 79372 29324 -50048
- Partials 5619 8085 +2466
Flags with carried forward coverage won't be shown. Click here to find out more.
|
One possibility is to eliminate the getPublishers method. It looks like it doesn't make much sense at the moment. That could be refactored in another PR. |
Motivation
getPublishers
method gets called twice for every single publisher when aggregating topic stats in theadd
method ofTopicStatsImpl
:pulsar/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java
Lines 262 to 263 in 1a352f1
This is a slight problem since
getPublishers
method is fairly costly and causes unnecessary garbage:pulsar/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java
Lines 152 to 158 in 1a352f1
Modifications
Documentation
doc
doc-required
doc-not-needed
doc-complete