-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow forcing traces #5738
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
Allow forcing traces #5738
Conversation
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5738/ to see the changes. Benchmarks is based on merging with master (b4a26ca) |
@AleksanderBG this is CI only right? |
@biboudis I actually wanted this to be a proper PR, but then pickling broke. It's WIP for now. |
test performance please |
performance test scheduled: 2 job(s) in queue, 1 running. |
I checked the stacktrace created by throwing an exception from the body of
|
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/5738/ to see the changes. Benchmarks is based on merging with master (4c4d5a1) |
@OlivierBlanvillain this is the |
@@ -7,34 +7,35 @@ import config.Config | |||
import config.Printers | |||
import core.Mode | |||
|
|||
object trace { | |||
abstract class TraceSyntax { | |||
val isForced: Boolean |
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.
Use a field TraceSyntax(isForced: Boolean)
? I would expect it is cheaper
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.
Could you be more clear on what it is you call a field? The goal here is to override isForced
with a final val
, which should be guaranteed to be inlined whenever referenced, which would then mean that we get rid of useless branches in the inlined logging methods. This is somewhat moot, since forceInline
does not seem to inline nested methods properly ( see #5738 (comment) ), but I don't see how making isForced
a constructor argument makes it any cheaper.
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.
Here the final val
implements an abstract one. It will be compiled to a virtual method call, I don't think the compiler can inline in this case. If isForced
is a constructor argument, it will be compiled to a field. A field access is much cheaper than a virtual method call.
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 see the reasoning, but all the methods that access isForced
are @forceInline
, so after the body is inlined the compiler should see that the member being accessed is a final val
and therefore is inlineable, no? Anyway, this PR has no impact on performance and after we bootstrap we will probably rewrite all the methods in this class to inline
, which will guarantee that they are inlined the way we want.
Side note: I am bookmarking this discussion to show the next person that tries to convince me it's a good idea to rely on the optimizer for inlining.
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'm not very familiar with the tracing logic so I might not be best person to review this code, but LGTM
@@ -92,4 +100,11 @@ object trace { | |||
throw ex | |||
} | |||
} | |||
} | |||
|
|||
object trace extends TraceSyntax { |
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.
Are you using this?
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.
This replaces the previous trace
object - now wherever there are calls like trace("isSubtype") { ... }
it's possible to replace trace
with trace.force
to have only that particular trace printed.
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 see. Then that might be a could place to put two lines of scaladoc...
What is the point of this? Is isForced just another way to enable tracing besides Config.tracingEnabled? My gut reaction is this is a bad idea. All control of reporting behavior should be in Config or config.Printers. Don't spread it out to other switches. |
I personally found the |
No description provided.