Closed lukasznowak-viacom closed 1 month ago
Thank you for the issue. I've edited your comment to improve the formatting of the stacktrace. You might want to check out this Mastering Markdown guide for future reference.
I'm not sure there is anything we can do on Micrometer Tracing side. As you can see in the stacktrace, Micrometer Tracing calls brave.Tracer.nextSpan
which eventually boils down to a call to java.lang.ref.ReferenceQueue::poll
(from WeakConcurrentMap
) which holds a ReentrantLock
and lock
on it is a blocking call.
It seems Brave's WeakConcurrentMap
was borrowed from Rafael Winterhalter’s WeakConcurrentMap
which says this should be a "concurrent, lock-free (as in lock-less) hash map". The implementation uses java.lang.ref.ReferenceQueue
's poll
method which could seem non-blocking according to its javadoc but it seems it blocks on a lock
(or I might miss something).
I think you can verify it by injecting brave.Tracer
into one of your components and calling nextSpan
on it, you should see the same error from BlockHound but without Micrometer Tracing.
I would open an issue for Brave and another one for Rafael's weak-lock-free repo and reference this issue from there but I think this should have minimal impact on you project.
Do you have profiling data that proves that the lock causes higher CPU usage and higher latencies? (I think the lock should not cause higher CPU usage but because of using Reactor, your throughput and your CPU utilization can be higher compared to MVC.)
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open.
Recently we started moving towards reactive stack based on WebFlux. Unfortunately during the PoC tests we encountered performance degradation compared to the old solution based on MVC. After investigation we found that micrometer-tracing library is called by reactive stack in blocking way and because of that we see much more CPU usage + higher overall latencies. Does it mean that it is not adapted to the reactive programming at all?
We are using:
Please find stack trace from https://github.com/reactor/BlockHound used in our service: