-
Notifications
You must be signed in to change notification settings - Fork 19
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
Tracing aware executors wrap Runnables and Callables more cleanly #310
Conversation
Generate changelog in
|
@carterkozak I actually think your description is great as a commit message instead of one sentence summary. |
Good call, updated |
Is there a way of including an assertion about the stackframes here? The new ones are very neat and don't want to accidentally regress! |
Sure, I did something similar in tritium: https://github.com/palantir/tritium/blob/d69b494360ed69a0739345124028e16e52029821/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java#L555-L569 will put it together shortly |
Firstly, we should not optimize around stack depth in most cases because it can result in large methods that the JVM cannot efficiently inline and additional GC pressure depending on the implementation. However, we use tracing a lot, a tracing wrapped executor shows up in ~50% of stack traces in a large internal service, and exceptions propagate through multiple executors in many cases. This would not make sense to change if the tracing stack frames provided information, but wrapping from runnable to callable isn't helpful, nor are lambda frames to turn a Callable into a ThrowingCallable. This change is completely internal to tracing and does not expose any new public APIs. Before: frames 2, 3, 4, and 5 are from tracing ``` com.palantir.logsafe.exceptions.SafeRuntimeException: Stack Trace at com.palantir.tracing.TracerTest.lambda$testStackDepth$9(TracerTest.java:486) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at com.palantir.tracing.DeferredTracer.withTrace(DeferredTracer.java:104) at com.palantir.tracing.Tracers$TracingAwareCallable.call(Tracers.java:356) at com.palantir.tracing.WrappingExecutorService.lambda$wrapTask$0(WrappingExecutorService.java:67) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ``` After: line 2 handles tracing, the rest would be present without tracing ``` com.palantir.logsafe.exceptions.SafeRuntimeException: Stack Trace at com.palantir.tracing.TracerTest.lambda$testStackDepth$9(TracerTest.java:486) at com.palantir.tracing.Tracers$TracingAwareRunnable.run(Tracers.java:409) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ```
bc57f2d
to
5fa5616
Compare
Updated, added docs to the tests to make the intent clear. |
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.
Thanks Carter!
Released 3.3.0 |
==COMMIT_MSG==
Firstly, we should not optimize around stack depth in most cases
because it can result in large methods that the JVM cannot efficiently
inline and additional GC pressure depending on the implementation.
However, we use tracing a lot, a tracing wrapped executor shows up
in ~50% of stack traces in a large internal service, and exceptions
propagate through multiple executors in many cases.
This would not make sense to change if the tracing stack frames
provided information, but wrapping from runnable to callable
isn't helpful, nor are lambda frames to turn a Callable into
a ThrowingCallable.
This change is completely internal to tracing and does not expose
any new public APIs.
Before: frames 2, 3, 4, and 5 are from tracing
After: line 2 handles tracing, the rest would be present without tracing
==COMMIT_MSG==
Possible downsides?
none.