dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 982 forks source link

Add ETW events that would measure application start up time. #6646

Open Tanya-Solyanik opened 2 years ago

Tanya-Solyanik commented 2 years ago

This is a request from the runtime team, aligned with their Arm64 effort. Related to https://github.com/dotnet/runtime/issues/64993

As an example, here’s a pointer to how the perf lab does this. All of the start-up tests emit an event when they have completed start-up: https://github.com/dotnet/performance/blob/23b05253055e3c5253bf4a1c8d4d767f33c2b77b/src/tools/ScenarioMeasurement/Startup/GenericStartupParser.cs#L8

merriemcgaw commented 2 years ago

Definitely something we want to try to measure.

dreddy-work commented 2 years ago

@Tanya-Solyanik, Are you planning to take this up in 7.0?

Tanya-Solyanik commented 2 years ago

@Tanya-Solyanik, Are you planning to take this up in 7.0?

No, this is a request from the runtime team. Someone from our team should work with Rich to understand his goal, and then we need to decide if his goals align with ours.

elachlan commented 1 year ago

This would be nice to have. One of my main goals for working on Winforms was to try and speed up app performance. We currently rely heavily on NGEN as a part of the install process(.net 4.8). Currently .NET 6 starts significantly slower.

Related runtime issue which has an example app: https://github.com/dotnet/runtime/issues/13339

JeremyKuhne commented 1 year ago

Measuring time isn't really generically practical as there aren't great places to measure and we're at the mercy of Windows message processing. When I was working on startup performance I was seeing wildly fluctuating times on Application.Run for a new Form().

What we do need and should have are allocation tracking tests for startup scenarios. We can do a hacky bit where we implement some tests that expect a specific amount of thread allocations, but they'll need a lot of attention as changes in the lower level runtime will also impact this from time to time. It would be best to get a perf test solution up and running but I don't see that we'll get that scheduled in the near future.

@elachlan if you can come up with measurement points that you think would be useful we can discuss.

elachlan commented 1 year ago

Thanks for the information, I guess the ETW events would help application developers profile their code better in production scenarios.

For myself, I am interested in general performance improvements across the board. Not just start-up performance.

jkotas commented 1 year ago

What we do need and should have are allocation tracking tests for startup scenarios.

Note that the common techniques for reducing allocations often regress startup performance. GC allocations are not a good proxy for startup performance. The best proxy for tracking startup performance of .NET apps is total number and code size of managed methods that are touched during startup.