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

[METRICS] Remove unnecessary Guava Cache #637

Closed
wants to merge 2 commits into from

Conversation

pan3793
Copy link
Member

@pan3793 pan3793 commented May 13, 2021

Why are the changes needed?

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

  • Run test locally before make a pull request

def incAndGetCount(key: String): Long = synchronized {
val counter = registry.counter(key)
counter.inc(1L)
counter.getCount
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

sgtm

@codecov-commenter
Copy link

codecov-commenter commented May 13, 2021

Codecov Report

Merging #637 (a8d607b) into master (e77ea13) will decrease coverage by 72.67%.
The diff coverage is 0.00%.

❗ Current head a8d607b differs from pull request most recent head aee29f1. Consider uploading reports for the commit aee29f1 to get more accurate results
Impacted file tree graph

@@             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     
Impacted Files Coverage Δ Complexity Δ
...cala/org/apache/kyuubi/metrics/MetricsSystem.scala 0.00% <0.00%> (-82.06%) 0.00 <0.00> (ø)
...mon/src/main/scala/org/apache/kyuubi/package.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...main/scala/org/apache/kyuubi/KyuubiException.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...ain/scala/org/apache/kyuubi/util/ThreadUtils.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...in/scala/org/apache/kyuubi/engine/ShareLevel.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...n/scala/org/apache/kyuubi/config/ConfigEntry.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
.../scala/org/apache/kyuubi/operation/Operation.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...la/org/apache/kyuubi/ha/client/RetryPolicies.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...scala/org/apache/kyuubi/cli/HandleIdentifier.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
...scala/org/apache/kyuubi/config/ConfigHelpers.scala 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (ø%)
... and 102 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e77ea13...aee29f1. Read the comment docs.


def incCount(key: String): Unit = {
val counter = registry.counter(key)
counter.inc(1L)
Copy link
Contributor

@ulysses-you ulysses-you May 14, 2021

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.

@yaooqinn yaooqinn closed this in d20a92e May 14, 2021
@yaooqinn yaooqinn added this to the v1.2.0 milestone May 14, 2021
yaooqinn pushed a commit that referenced this pull request May 14, 2021
<!--
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>
@yaooqinn
Copy link
Member

thanks, merged to master for v1.3.0 and branch 1.2 for v1.2.0

@pan3793 pan3793 deleted the metrics branch May 14, 2021 13:55
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.

None yet

4 participants