-
Notifications
You must be signed in to change notification settings - Fork 0
Initial work to port EventPipe library to NativeAOT #1
Description
Getting EventPipe to full functionality as outlined in #79241 still has significant work remaining, but this PR is at a sweet spot between demonstrating end-to-end event data flowing from a NativeAOT application to a listening client and having too much new code to CR.
The current status allows a NativeAOT application to send EventSource events to a listening client (command CollectTracing2 in https://github.com/dotnet/diagnostics/blob/main/documentation/design-docs/ipc-protocol.md) in windows. This is done by adding a new opt-in library for AOT.
| Managed EventSource Support | Native AOT Library | NativeAOT EventSource Application |
|---|---|---|
| Disabled | Disabled | Same behavior as .NET 7 |
| Enabled | Enabled | Managed EventSource data and native ProcessInfo events are received by the listening client |
| Disabled | Enabled | Native ProcessInfo event is received by the listening client |
| Enabled | Disabled | Not supported |
The NativeAOT EventSource sample application is currently shown in reproNative and the listening client application is a .NET application similar to https://github.com/LakshanF/CSharp/blob/master/src/aot/experiments/Diagnostics/Logging/EventSource/DiagnsoticsClient/Program.cs
New Code
Although the 'new code' in this initial PR seems large with 6000+, there is really not much new code that is getting checked in as explained below. As outlined in https://github.com/dotnet/runtime/tree/main/src/native/eventpipe#eventpipe-and-diagnosticserver, NativeAOT EventPipe library uses the common code that both Mono and CoreCLR runtime uses and provides the following features as required by the EventPipe library;
- Container classes (this is currently being moved to common code. Specifically, when that happens, the container classes in this checkin will be removed). This checkin has around ~1000 lines of code for this.
- Runtime functionality. NativeAOT runtime code started with a copy of CoreCLR code and these checkins in the PR show a way to more easily see the differences. See this commit to see specific differences from the CoreCLR implementation easily. The changes here has around ~5000 lines of code.
The rest of the new code is mostly as below:
- Hooks between Managed and Native code to enable EventSource events to flow
- Some changes in the NativeAOT runtime side to support EventPipe
- Opt-in EventPipe library that contains hookup code from Startup.cpp to the EventPipe library (Aot.EventPipe.lib which is used when EventSource is enabled in NativeAOT and Aot.Disabled.EventPipe.lib when EventSource is disabled). This commit shows details
- Changes to EventPipe common code
- Build artifacts
- A native sample application with EventSource to demonstrate EventPipe. This is not meant to be checked in. A client application similar to this can be used to test.