-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][broker] Optimize and clean up aggregation of topic stats #21361
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
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. |
|
This issue is occur in branch-3.0, I think it is not just a optimization, but also a bug fix which should cherry-pick this pr to branch-3.0 and branch-3.1 @lhotari |
@TakaHiR07 I think it makes sense to cherry-pick to branch-3.0. We don't maintain branch-3.1 at all. |
…pache#21361) (cherry picked from commit d6a56ad)
…pache#21361) (cherry picked from commit d6a56ad) (cherry picked from commit 4fd61ab)
…pache#21361) (cherry picked from commit d6a56ad) (cherry picked from commit 4fd61ab)
Motivation
getPublishersmethod gets called twice for every single publisher when aggregating topic stats in theaddmethod 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
getPublishersmethod 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
docdoc-requireddoc-not-neededdoc-complete