-
Notifications
You must be signed in to change notification settings - Fork 566
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
contention from MetricUtil.getMetricID() when using Metrics using annotations #1595
Comments
From the thread dumps taken during the load we see that most threads on two stacks,
java.lang.Thread.State: BLOCKED (on object monitor)
java.lang.Thread.State: RUNNABLE
|
Just to understand if the contention is sue to parameers "mp.metrics.appName" and "mp.metrics.tags" parameters missing from configuration , added the below configuration to microprofile-config.properties mp.metrics.tags=app=compute,container=helidon This did help avoid creation of io.helidon.config.MissingValueException() during metric update. |
These repeated lookups for "mp.metrics.appName" and "mp.metrics.tags" are originating from the constructor for org.eclipse.microprofile.metrics.MetricID. For every metric update one new instance of MetricID is created, during which these lookups happen. These instances of MetricID don't seem to get cached and thus adding overhead. public MetricID(String name, Tag... tags) { |
Just to understand the overhead from the continuous lookup,
and re-ran the same tests. |
creating new instances of " org.eclipse.microprofile.metrics.MetricID" for every metric update operation seems to be root cause for this contention. Would it be feasible to avoid this new instance creation every invocation, instances MetricID of cached in the implementation of io.helidon.microprofile.metrics.MetricUtil.getMetricID()? |
@vasanth-bhat Thanks for the analysis. Are you interested in providing a PR for this? |
The change i did is just to understand the performance impact of avoiding the repetitive config lookups and not the real solution. |
Of course, I thought you may have gone further and explore the use of a cache. |
No, I haven't |
But maybe there are some intentional design decisions? It looks like the Adding a print statement to
|
Given that the metric ID creation seems to be the worse problem, that's where we're looking currently. The negative caching idea might be suitable for a separate issue on the config component. There are a few possible solutions to the metrics ID issue, each with varying impact on the code. We're working on that now. |
Undoing the auto-close of this issue until the 1.x PR can be merged. Currently it's waiting for the grpc cert fix so the pipeline can pass. |
Fixed in 1.x and 2.x |
Repeated the test updated Helidon from 1.x branch (1.4.5-SNAPSHOT) that includes fixes for issues #1595, #1570 & #1571 With the fixes, we no longer have the significant overhead that we used to have when using metrics via Annotations. Thanks for the excellent fix |
Thanks for testing again and sharing your results. |
Repeated the tests used for overhead measurement of metric annotation with the fix from #1581 from helidon-1.x branch. With that fix there is about the tests showed 20% improvement in Avg RT.
repeated config lookup for "mp.metrics.appName" and "mp.metrics.tags", These are originating from creation of instances of org.eclipse.microprofile.metrics.MetricID, which is done for every metric update operation when using annotation
This is happening from the below stack
at io.helidon.microprofile.config.MpConfig.getOptionalValue(MpConfig.java:240)
at org.eclipse.microprofile.metrics.MetricID.(MetricID.java:124)
at io.helidon.microprofile.metrics.MetricUtil.getMetricID(MetricUtil.java:60)
at io.helidon.microprofile.metrics.InterceptorBase.called(InterceptorBase.java:133)
at io.helidon.microprofile.metrics.InterceptorBase.aroundMethod(InterceptorBase.java:114)
Environment Details
The text was updated successfully, but these errors were encountered: