-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 assembly tracing #1466
Conversation
On Java 8, `getStackTraceDepth` + `getStackTraceElement` are much faster than `new Exception().getStackTrace()`. There are no such methods in Java 9, but `StackWalker` API, which is a bit slower than native ones, but also outperforms `getStackTrace()`.
Codecov Report
@@ Coverage Diff @@
## master #1466 +/- ##
===========================================
+ Coverage 84.27% 84.48% +0.2%
- Complexity 3895 4216 +321
===========================================
Files 358 359 +1
Lines 29435 30528 +1093
Branches 5464 5671 +207
===========================================
+ Hits 24806 25791 +985
- Misses 3030 3105 +75
- Partials 1599 1632 +33
Continue to review full report at Codecov.
|
* @author Simon Baslé | ||
* @author Sergei Egorov | ||
*/ | ||
final class Tracer { |
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.
Maybe not Tracer to keep that naming space for tracing (aka zipkin) features
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.
I removed the class, not needed anymore. The content moved to Traces
where it belongs :)
On Java 8,
getStackTraceDepth
+getStackTraceElement
are much faster thannew Exception().getStackTrace()
.There are no such methods in Java 9, but
StackWalker
API, which is a bit slower than native ones, but also outperformsgetStackTrace()
.If I run the provided benchmark on my machine (Mac OS X, 2,2 GHz Intel Core i7), I get the following numbers:
Reactor core 3.2.3.RELEASE:
This branch:
As you can see, it is 4-10x times faster and much less dependant on the stack size. Also, the error is lower.
Open questions
sun.misc.*
hack. I haven't figured out how to do it with JDK 9+ and-release 8
(see Remove sun.misc.* stubs #1469)