-
Notifications
You must be signed in to change notification settings - Fork 896
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
[METRICS] Remove unnecessary Guava Cache #637
Conversation
def incAndGetCount(key: String): Long = synchronized { | ||
val counter = registry.counter(key) | ||
counter.inc(1L) | ||
counter.getCount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value never used, if return Unit
, we can remove synchronized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm
Codecov Report
@@ Coverage Diff @@
## master #637 +/- ##
============================================
- Coverage 79.88% 7.21% -72.68%
- Complexity 0 132 +132
============================================
Files 120 120
Lines 4683 4674 -9
Branches 563 562 -1
============================================
- Hits 3741 337 -3404
- Misses 625 4293 +3668
+ Partials 317 44 -273 Continue to review full report at Codecov.
|
|
||
def incCount(key: String): Unit = { | ||
val counter = registry.counter(key) | ||
counter.inc(1L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is thread safe ?
nvm, I see this object is singleton.
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/NetEase/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> `MetricRegistry` hold counters in `ConcurrentHashMap`, it's unnecessary to use Guava Cache. ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request Closes #637 from pan3793/metrics. Closes #637 aee29f1 [Cheng Pan] remove synchronized a8d607b [Cheng Pan] [METRICS] Remove unnecessary Guava Cache Authored-by: Cheng Pan <379377944@qq.com> Signed-off-by: Kent Yao <yao@apache.org> (cherry picked from commit d20a92e) Signed-off-by: Kent Yao <yao@apache.org>
thanks, merged to master for v1.3.0 and branch 1.2 for v1.2.0 |
Why are the changes needed?
MetricRegistry
hold counters inConcurrentHashMap
, it's unnecessary to use Guava Cache.How was this patch tested?
Add some test cases that check the changes thoroughly including negative and positive cases if possible
Add screenshots for manual tests if appropriate
Run test locally before make a pull request