-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Define and implement behavior of tracing functionality when EventSource is disabled via a feature switch #43657
Comments
Related to #43635. |
@noahfalk, Can you review additional testing that would be interesting for this please? I removed the types EventPipe, NativeRuntimeEventSource from CoreLib's root descriptor to explore the behavior when the feature-switch, EventSourceSupport, is set to false. I tested this lightly as follows;
|
That test only covers the scenario where the app is not trimmed, and the EventSource.IsSupported AppContext switch is set to If we are going to unroot the EventPipe code, we should probably add a "TrimmingTest" that trims the app with the EventSource feature switch set to See runtime/src/libraries/System.Runtime/tests/TrimmingTests/System.Runtime.TrimmingTests.proj Lines 21 to 25 in 738dcf7
for how to set feature switches in our current "TrimmingTests" support. |
Thanks for the heads up @tommcdon.
Actually I've been meaning to remove a large chunk of this rooted EventPipe code. I've managed to get the internal partner team that uses reflection to access these private methods to stop doing that and move to officially supported API. I got the OK from them on removing these, so I'll follow up with a PR to remove the unused bits (there are some tests that use these, so I'll have to rewrite some of them) in a day or two. |
@LakshanF, you may want to also check for behavior of other tools, specifically ETW tracing, e.g., PerfView collection. Another potential pitfall is the infrastructure for forwarding native events to managed EventSources. You need to validate that turning on the native providers via ETW/EventPipe while EventSource* is trimmed out doesn't cause the native diagnostics code to break.
This sounds like something went wrong while tracing, causing the trace to be cut prematurely (In the face of most failures, the IPC connections are closed unceremoniously by the runtime). What providers did you turn on when you were collecting this trace? What was the state of the diagnostics server after this, could you start a second trace? In my mind, trimming out EventSource shouldn't preclude a user from doing CPU profiling. That doesn't require any managed eventing code if I recall. It also shouldn't break the Diagnostic Port infrastructure (IPC for diagnostic tools) even if eventing sources aren't available. |
/cc @lateralusX |
The consensus is to honor the developer intent when they switch off EventSource feature and not enable any events from the application. The user experience when they use an external tool like dotnet-trace should be to fail gracefully. The current behavior with dotnet-trace is not optimal since it crashes the app and generates a trace file that is corrupted (issue #46047).
We also need to document the expected behavior very clearly when this feature is turned off. In terms of diagnostics impact, there may be additional things that disabling EventSource may introduce that are not very obvious to the end user:
|
Still have the NativeRuntimeEventSource to unroot but updating with the latest thinking from the team External Tooling Experience Impact on EventPipe-dependent tools (dotnet-trace) Impact on Visual Studio Profiler Impact on Distributed Tracing Experience with turning on EventSource Providers Ability for a well known provider to give information that EventSource is turned off |
We should not make functional decisions based on the current location of the event firing code. Currently it's easy to keep all of the native code call sites even if EventSource is turned off, but it's something we should not do. It would prevent us from freely choosing if a given functionality can be in native or managed. We're already migrating large parts of the native runtime to managed and if we did the above this would become problematic. Having one special event fired from native seems OK, but I would try to limit only to that and nothing else. Ideally we would not even have that - in the most size constrained environments we would like to remove all of event tracing code from the app, including the native parts (one day). So ideally the tooling should be able to handle those cases - at least somewhat gracefully. It's similar to debugging - I could imagine one day we support some special way to produce an app which doesn't even start the debugger thread and doesn't open the debugger IPC. (Both as a security/reliability as well as size feature). |
+1 on @vitek-karas answer. I think there is a few other reasons that lead to a similar conclusion:
|
As long as we can describe the diagnostic impact to the users in a clear way when the feature switch is disabled, I think it is fine to just disable all tracing bottoms-up. As previously discussed, for tools that rely on ETW (i.e. VS Profiler), it may be worth firing an event that shows that the feature switch has been turned off in the app, so that it is diagnosable when no events show up in the trace. |
Closing this issue for this round of changes that have been done:
|
In .NET 5 we introduced a new feature switch
EventSourceSupport
- it effectively disables all event sources (typical observed behavior is that they can't be enabled and thus don't produce any events). For the most part this has been implemented for Mono/WASM scenarios which don't support event source anyway, so the code was effectively unused.If used on CoreCLR, there's still quite a bit of code left in the app (which linker can't remove right now) related to EventPipe - currently all of this code is rooted. It's easy to remove it via the
EventSourceSupport
feature switch, but it's unclear what that will do to the EventPipe infrastructure.Specifically:
dotnet trace collect
and similar.This issue is meant to track both the design an implementation of these changes.
The text was updated successfully, but these errors were encountered: