microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.85k stars 322 forks source link

Dynamic dependencies have a significant impact on application startup time #4697

Open lhak opened 2 months ago

lhak commented 2 months ago

Describe the bug

Looking at startup time of winui applications, I noticed that using dynamic dependencies for unpackaged apps has a significant impact. Compared to using appsdk self contained deployment, using dynamic dependencies increases startup time by 100-300ms depending on processor speed.

Interestingly, using the Windows functions TryCreatePackageDependency() and AddPackageDependency() for the appsdk runtime package results in a lot better performance. So I guess improvements should be possible here.

Steps to reproduce the bug

Use https://github.com/jonathanpeppers/measure-startup to measure the startup time of unpackaged apps with and without appsdk self contained deployment enabled.

Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.6.0: 1.6.240829007

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

DarranRowe commented 2 months ago

There was work being done to just use the Windows 11 Dynamic Dependencies API when available, I wonder what happened to it.

mominshaikhdevs commented 2 months ago

this is the PR: https://github.com/microsoft/WindowsAppSDK/pull/4136

DrusTheAxe commented 2 months ago

Interestingly, using the Windows functions TryCreatePackageDependency() and AddPackageDependency() for the appsdk runtime package results in a lot better performance

Not too surprising. We made changes inside Windows to enable that behavior. Unfortunately these changes required pretty deeply invasive (read: high risk) changes to make downlevel, thus WinAppSDK has its own parallel implementation that approximates the same net result but using mechanisms already available on e.g. RS5. So the latter works (yay!) but can't be quite as lean as the former.

DrusTheAxe commented 2 months ago

There was work being done to just use the Windows 11 Dynamic Dependencies API when available, I wonder what happened to it.

It ran into a couple of deep technical snags requiring more time than available to sort out so it got deferred (sleepy, not dead :-)

But for all things a season... I've started digging back into this. It's a little tricky to thread the needle to enable without introducing regressions, but I'm cautiously optimistic it'll get it sorted out soon enough.

I've actually been itching to get my hands on this for a while. Looking forward to hacking away, even if it's a meticulous hackery. Stay tuned.

DrusTheAxe commented 2 months ago

FYI MS tracking => https://task.ms/47326505