Skip to content

Significant performance overhead in WinRT API calls (ApplicationData, Package.Current) #6223

Description

@ekalchev

Describe the bug

I am seeing unexpected latency when calling standard WinRT APIs within a WPF application (Desktop Bridge/MSIX) using Windows App SDK 1.8.

Environment:
CPU: 12th Gen Intel i9
RAM: 64GB
Framework: Microsoft.WindowsAppRuntime 1.8

Observations:
Using both a profiler and Stopwatch verification, I’ve found that calls to ApplicationData.Current.LocalCacheFolder and ApplicationData.Current.GetPublisherCacheFolder consistently take ~25ms to execute.
Furthermore, these results do not appear to be cached internally; calling them multiple times results in the same 25ms delay per call. Other APIs show similar overhead:
Package.Current.InstalledLocation: ~15ms
ApiInformation.IsTypePresent: ~15ms
On high-end hardware, 15–25ms for a property access is extremely high. Is this expected behavior?

Steps to reproduce the bug

Just call any of those method and measure them with stopwatch

Expected behavior

No response

Screenshots

No response

NuGet package version

None

Packaging type

No response

Windows version

No response

IDE

No response

Additional context

No response

Activity

  1. added
    area-ApplicationData
    area-PackageManagement
    and removed on Feb 22, 2026
  2. DrusTheAxe commented on Feb 22, 2026

    @DrusTheAxe
    Member

    Expected? Yes.

    Could be better? Possibly (with work)

    On high-end hardware, 15–25ms for a property access is extremely high

    Because these properties are often doing more than just return this->string_attribute;.

    ApplicationData.Current.LocalCacheFolder

    That does 2 operations. Do you know the attributed cost?

    ApplicationData.Current = query current process' package identity, query bookkeeping information and return an object

    .LocalCacheFolder = query location information to get path for the local cache folder and create a StorageFolder

    Performance can further vary depending if this is called in an AppContainer vs MediumIL+

    One optimization in the backlog is to add .*Path properties equivalent to .*Folder but return the path as a string. The implementation's not quite as linear as one might think, so .*Path is expected to less cost to their equivalent .*Folder but it's hard to guess the delta. But regardless, if you need the path as a string and not a StorageFolder this should be a win.

    these results do not appear to be cached internally
    Correct - they're live calls, ByDesign. If you use them repeatedly you can cache their result.

    Package.Current.InstalledLocation: ~15ms

    Again, 2 operations -- Package.Current vs .InstalledLocation, and similar performance implications.

    Package.Current (mostly) prepopulates the object with a snapshot of current information, and optimizations in the backlog to address this. See #6222 (comment) for more information.

    .InstalledLocation likewise incurs the cost to create a StorageFolder object out of a path string, but .*Path properties are already available here e.g. .InstalledPath vs .InstalledLocation. As a general rule, if you don't need a StorageFolder object, always favor .*Path over *.Location.

    ApiInformation.IsTypePresent

    ApiInformation needs WinRT metadata thus it can involve a .winmd lookup and access to retrieve the type information. Depending on the type, caller's security context (AppContainer, MediumIL, etc) and other factors performance longer than instantaneous isn't surprising.

    Better performance is always desirable, but are these problematic for you today?

  3. ekalchev commented on Feb 22, 2026

    @ekalchev
    Author

    Yes they are problematic. I am sorry that I want to build windows desktop application that have fast startup. When you have many winrt calls during startup they add up.

    Are there alternative win32 calls of this winrt apis?

  4. DrusTheAxe commented on Mar 8, 2026

    @DrusTheAxe
    Member

    Are there alternative win32 calls of this winrt apis?

    There is no perfier alternative today to ApplicationData. WinAppSDK's Microsoft.Windows.Storage.ApplicationData today is powered by Windows.Storage.ApplicationData so it won't have any better performance. Something I hope to see improve in time, but not today.

    If you don't need a StorageFolder Package.Current.InstalledLocation.Path is better done with Package.Current.InstalledPath, and often even better (more correct) with Package.Current.EffectivePath or GetPackagePathByFullName2. Depends if you're looking for your own path (so you know you couldn't have a Mutable or ExternaLocation path) or someone else's, and if you can call Win32 C exports vs need WinRT/projections.

    ApiInformation has no alternative that I know of, other than the classic instantiate-the-object and trap ERROR_CLASSDB_NOT_REG, E_NOINTERFACE, etc as the not-found case. Ye' olde Beg-Forgiveness (vs Ask-Permission) sort of model.

  5. duckheadsoftware commented on Aug 2, 2026

    @duckheadsoftware

    I'm having the same issue in a WinUI app. Thre are multiple things slowing down my launch time, ApplicationData.Current.LocalFolder.Path takes 30ms on a fast machine. WinRT isn't finished yet in my opinion, it needs to be updated for WinUI, anything related to Storage is a huge mess.

  6. DrusTheAxe commented on Sep 27, 2026

    @DrusTheAxe
    Member

    ApplicationData.Current.LocalFolder.Path takes 30ms on a fast machine

    If so then something uniquely weird is happening in your test. How are you measuring?

    For a MediumIL caller that'll happen in (very small) fractions of a second.

    Are you in an AppContainer? Additional work's needed there, but still, 30s is an insanely unexpected value.

    For one trivial benchmark, on my desktop -- 11th Gen i7, 32GB RAM, 26GB RAM in use per taskmgr, Windows 11 25H2

    appdata.exe path Microsoft.WindowsTerminal_8wekyb3d8bbwe

    does...

    • C# AnyCPU (MSIL) exe
    • ApplicationDataManger.CreateForPackageFamily()
    • Fetch applicationdata.*Folder().Path for LocalFolder + LocalCacheFolder + RoamingFolder + TemporaryFolder
    • Determine MachineFolder, if any
    • Console.WriteLine() each string

    and even with all the C#-ness overhead it does all that in <150ms

  7. DrusTheAxe commented on Sep 27, 2026

    @DrusTheAxe
    Member

    ApplicationData: Optimize *Path properties #6731 optimizes ApplicationData methods:

    • LocalPath
    • LocalCachePath
    • MachinePath
    • TemporaryPath
  8. duckheadsoftware commented on Sep 27, 2026

    @duckheadsoftware

    ApplicationData.Current.LocalFolder.Path takes 30ms on a fast machine

    If so then something uniquely weird is happening in your test. How are you measuring?

    For a MediumIL caller that'll happen in (very small) fractions of a second.

    Are you in an AppContainer? Additional work's needed there, but still, 30s is an insanely unexpected value.

    For one trivial benchmark, on my desktop -- 11th Gen i7, 32GB RAM, 26GB RAM in use per taskmgr, Windows 11 25H2

    appdata.exe path Microsoft.WindowsTerminal_8wekyb3d8bbwe

    does...

    • C# AnyCPU (MSIL) exe
    • ApplicationDataManger.CreateForPackageFamily()
    • Fetch applicationdata.*Folder().Path for LocalFolder + LocalCacheFolder + RoamingFolder + TemporaryFolder
    • Determine MachineFolder, if any
    • Console.WriteLine() each string

    and even with all the C#-ness overhead it does all that in <150ms

    30ms is less than 150ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-ApplicationDataarea-PackageManagement

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions