Skip to content
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

optimize performance for MetricsFilter #12329

Merged
merged 10 commits into from
May 19, 2023

Conversation

finefuture
Copy link
Contributor

ReflectionUtils add event type cache, reduce the time consumption of MetricsFilter

What is the purpose of the change

Brief changelog

Verifying this change

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

Copy link
Member

@songxiaosheng songxiaosheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix ci problem @wxbty PATL

Copy link
Member

@wxbty wxbty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, write a unit test by the way?

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2023

Codecov Report

Merging #12329 (b8df7db) into 3.2 (b7fc2b9) will increase coverage by 1.96%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                3.2   #12329      +/-   ##
============================================
+ Coverage     67.38%   69.35%   +1.96%     
+ Complexity       22        2      -20     
============================================
  Files          3551     1607    -1944     
  Lines        153785    66267   -87518     
  Branches      23666     9719   -13947     
============================================
- Hits         103629    45958   -57671     
+ Misses        40460    15851   -24609     
+ Partials       9696     4458    -5238     

see 1983 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@wxbty wxbty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@AlbumenJ AlbumenJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

How about cache in AbstractMetricsListener.

Allocate a map to cache class is not a good idea, and this may cause classloader unable to being gc.

@finefuture
Copy link
Contributor Author

finefuture commented May 17, 2023

image

How about cache in AbstractMetricsListener.

Allocate a map to cache class is not a good idea, and this may cause classloader unable to being gc.

@AlbumenJ Good idea, Is this ok?
image

Tested to improve performance by 2% than cache in ReflectionUtils

@wxbty
Copy link
Member

wxbty commented May 17, 2023

image
How about cache in AbstractMetricsListener.
Allocate a map to cache class is not a good idea, and this may cause classloader unable to being gc.

@AlbumenJ Good idea, Is this ok? image

Tested to improve performance by 2% than cache in ReflectionUtils

Would it be better to put the match method in util, and use Object for the event type? It is not the responsibility of the current class

@finefuture
Copy link
Contributor Author

image
How about cache in AbstractMetricsListener.
Allocate a map to cache class is not a good idea, and this may cause classloader unable to being gc.

@AlbumenJ Good idea, Is this ok? image
Tested to improve performance by 2% than cache in ReflectionUtils

Would it be better to put the match method in util, and use Object for the event type? It is not the responsibility of the current class

Okay, Moved


public abstract class AbstractMetricsListener<E extends MetricsEvent> implements MetricsListener<E> {

private final Map<Class<?>, Boolean> eventMatchCache = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConcurrentHashMap here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@finefuture finefuture requested a review from AlbumenJ May 18, 2023 12:16
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

11.1% 11.1% Coverage
0.0% 0.0% Duplication

@AlbumenJ AlbumenJ merged commit 35fdf9d into apache:3.2 May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants