-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Basic infrastructure for binder tracing #27383
Basic infrastructure for binder tracing #27383
Conversation
a5742a3
to
b6559e4
Compare
Add event listener for tests
b6559e4
to
453ee01
Compare
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.
Just a few minor nits, but LGTM otherwise. I'll test it soon to see if I'll hit the same issues I had with the prototype.
It's passing on Linux (on my machine), so I guess the changes in |
functionality into static methods in ActivityTracker
@@ -588,6 +588,25 @@ private void ActivityChanging(AsyncLocalValueChangedArgs<ActivityInfo?> args) | |||
// currently we do nothing, as that seems better than setting to Guid.Emtpy. | |||
} | |||
|
|||
// Assembly bind runtime activity name | |||
private const string AssemblyBindName = "AssemblyBind"; |
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 know we like to call this assembly binding for historic reasons, but our documentation and customers call this assembly loading. E.g.: https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed
I would stick with assembly loading for anything that is public facing.
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.
Does that mean we don't want to call it assembly binding in the events either? I put them under the Binder
keyword (that used to be Fusion
); I didn't want to have them under Loader
, since I think we'd want to enable them separately. The new events are also under the AssemblyBinder
task and named AssemblyBind*
.
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.
Would it make sense to call this AssemblyLoader
/ AssemblyLoad
?
I would be interested to know what other people (e.g. PMs) think about the right public facing names for 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.
Or maybe also AssemblyResolver
/AssemblyResolve
? Since we have the AssemblyLoadContext.Resolving
and AppDomain.AssemblyResolve
events.
Will check with PMs.
@@ -123,5 +123,8 @@ public static Assembly GetCallingAssembly() | |||
|
|||
[MethodImpl(MethodImplOptions.InternalCall)] | |||
internal static extern uint GetAssemblyCount(); | |||
|
|||
[MethodImpl(MethodImplOptions.InternalCall)] | |||
internal static extern bool IsBinderTracingEnabled(); |
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 am wondering whether AssemblyLoadContext would be a more appropriate place for this. Assembly is a grab bag of everything. AssemblyLoadContext is very specific to assembly loading and presumably quite a bit of the tracing will live on ALC.
Also, this method can be called just IsTracingEnabled
.
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.
LGTM modulo one nit. Thanks!
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
This broke Mono and CoreRT builds.
/cc @marek-safar @jkotas |
I think these assembly loader specific tracing methods should not be in |
Could you please add this to Mono somewhere to workaround this?
|
Yeah, that is also an option and I agree it belongs somewhere else. We may eventually want to adapt this tracing for Mono too and share it but right now I am more concerned about the build breaks. |
Sure, I am on it. |
I have added dotnet/corefx@3eb5f9e to the mirror PR in CoreFX that will propagate around in the next round. |
Thanks! |
Sorry, completely missed the shared/non-shared thing - #27535 |
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Add basic infrastructure for binder tracing
AssemblyBindStart
andAssemblyBindStop
eventsAppDomain::BindAssemblySpec
andAssemblyNative::LoadFromPEImage
Notes:
AssemblyBindStart
andAssemblyBindStop
events aren't properly populated yet.AssemblyBindStop
is not fired if tracing was not enabled at the start of the bind. This will be updated when we actually populate all the events' properties.System.Private.CoreLib.resources
. That load can be triggered by the creation of anEventSource
(which can be triggered byActivityTracker
), so calling back intoActivityTracker
could result in infinite recursion between the bind and tracing the bind. Potential options:System.Private.CoreLib.resources
(this PR, no events at all)ActivityTracker
functions to indicate it should not use anyEventSource
during those callsSystem.Private.CoreLib.resources
binds (events, but without correlation)