Open richlander opened 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
There is an event for "about to start managed main", which is located here: https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/assembly.cpp#L1469. It's not ideal as is because to turn it on, you have to turn on lots of other events, but it does work. You must turn on the private provider, start-up keyword, and verbosity level of informational. It would be worthwhile to see how many of these other events actually fire, since some of them look to me like they could be specific to .NET Framework, but I don't know that for sure.
If we need to do work here, we should add a new event to the public provider just prior to execution of main.
@noahfalk
What I have done in the past is create a trivial EventSource and then instrument my example app to invoke them, but agreed that investigations would be easier if there were some events ready to go and it feels perfectly reasonable to ask for. Surprisingly @richlander you are the first person that I can recall to ask about it : ) @brianrob do you know if you or Vance got earlier requests for these types of events?
For Asp.Net there is an ILogger message here but no strongly typed ETW event that I am aware of. For Kestrel specifically I assume you could look at the AcceptStart event for System.Net.Sockets (https://source.dot.net/#System.Net.Sockets/System/Net/Sockets/SocketsTelemetry.cs,54). In my past investigations of ASP.Net there is a lot of work that occurs lazily when receiving the first request, so the first RequestStop event might be more meaningful. I filed this issue: https://github.com/dotnet/aspnetcore/issues/40238
Do you guys know which devs are maintaining WinForms/WPF these days?
Application idle - this one seems ambiguous. I think some app models have tried to define this with heuristics and we could ask each app model to instrument the code that implements their definition of it, but I don't think there is a uniform definition we could apply that would get broad agreement.
Application terminating - typically I've used the OS process exit event or I have a more explicit workload that I've instrumented myself. I probably need more info on the scenario to understand what this one was intended to help measure.
I've also done what you've done in the past @noahfalk. Vance and I haven't had other requests for this, but we have been the ones looking to request such things. If I recall correctly, this just never came to the top of the priority list at the time. I think overall, having some platform events to be able to measure reliably, especially for points in the app that occur in the platform, would be valuable.
That said, we don't always need to have a specific "startup" event - if we determine that something like AcceptStart is reasonable for web workloads, then that is OK for such scenarios.
Do you guys know which devs are maintaining WinForms/WPF these days?
We can probably just file an issue in https://github.com/dotnet/winforms and https://github.com/dotnet/wpf.
Application idle - this one seems ambiguous.
Agreed that this is app type specific. For example, I don't think of console apps as having an idle state.
Application terminating
I usually use OS process exit as well. This one is interesting if we want to pay attention to runtime shutdown. If we're going to do the exercise and add new events to be able to track app lifetime, this is probably worth having. Usually runtime shutdown is fast, but I have run into cases where it is not.
Thanks @brianrob!
We've now got: WPF - https://github.com/dotnet/wpf/issues/6138 Winforms - https://github.com/dotnet/winforms/issues/6646 ASP.NET - https://github.com/dotnet/aspnetcore/issues/40238
Usually runtime shutdown is fast, but I have run into cases where it is not.
What do you think should define the beginning of app shutdown, after we've returned from Main()?
What do you think should define the beginning of app shutdown, after we've returned from Main()?
Yes, I think that's right. From there, everything else is pretty much runtime/process shutdown.
What do you think should define the beginning of app shutdown, after we've returned from Main()?
That's over-simplification. The shutdown is app-model specific just like startup is app-model specific. Number of app models do a lot of (potentially asynchronous) work during shutdown before exiting Main. Some app models actually exit Main right away during startup and keeping the application running via non-background threads.
For Windows UI apps, the shutdown starts by user clicking the X for Windows UI apps. For container apps, the shutdown starts by the container orchestrator sending SIGTERM
signal to the process.
I agree that there are app-model specific definitions of shutdown too. For me it was more if Brian and Rich are the proxy for users wanting this capability, what is the scenario that they believe is interesting to measure? If they (or others) want to measure a wide variety of app-model specific definitions of shutdown I'm happy to let folks enumerate all the situations they care about. Given that I'd never seen any asks on the topic before, my default response was to start with a very simple proposal.
Yup, totally agree that not all apps will follow this pattern - depending on the apps we're looking at, we will need to select the right set of events for measurement.
I'm doing some performance analysis of .NET apps. I'm working on Windows with PerfView, however this issue isn't intended to be Windows specific.
I'm new at doing performance analysis via our tools. Naively, I was expecting the following types of events to be available:
app.run
called and server availableNote: I did find the first one.
It is entirely possible that I'm doing this wrong. It seems like basic performance analysis would be easier if these events existed and would compliment/compose nicely with custom events.
If these events make sense and we don't have them, do folks think we should start an effort to add them?