You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Significant performance overhead in WinRT API calls (ApplicationData, Package.Current) #6223
area-ApplicationDataTopics related to ApplicationData APIs in the Microsoft.Windows.Storage namespacearea-PackageManagementMSIX deployment technology (eg PackageDeploymentManager)
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
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?
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?
Reacted by lgBlog, Manish Raj Yadav and Haraszti Gábor
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.
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.
area-ApplicationDataTopics related to ApplicationData APIs in the Microsoft.Windows.Storage namespacearea-PackageManagementMSIX deployment technology (eg PackageDeploymentManager)
Activity
DrusTheAxe commentedon Feb 22, 2026
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;.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 StorageFolderPerformance can further vary depending if this is called in an AppContainer vs MediumIL+
One optimization in the backlog is to add
.*Pathproperties equivalent to.*Folderbut return the path as a string. The implementation's not quite as linear as one might think, so.*Pathis expected to less cost to their equivalent.*Folderbut it's hard to guess the delta. But regardless, if you need the path as a string and not aStorageFolderthis should be a win.Again, 2 operations --
Package.Currentvs.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..InstalledLocationlikewise incurs the cost to create aStorageFolderobject out of a path string, but.*Pathproperties are already available here e.g. .InstalledPath vs .InstalledLocation. As a general rule, if you don't need aStorageFolderobject, always favor.*Pathover*.Location.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?
ekalchev commentedon Feb 22, 2026
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?
DrusTheAxe commentedon Mar 8, 2026
There is no perfier alternative today to
ApplicationData. WinAppSDK'sMicrosoft.Windows.Storage.ApplicationDatatoday is powered byWindows.Storage.ApplicationDataso it won't have any better performance. Something I hope to see improve in time, but not today.If you don't need a
StorageFolderPackage.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.ApiInformationhas no alternative that I know of, other than the classic instantiate-the-object and trapERROR_CLASSDB_NOT_REG,E_NOINTERFACE, etc as the not-found case. Ye' olde Beg-Forgiveness (vs Ask-Permission) sort of model.duckheadsoftware commentedon Aug 2, 2026
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.
DrusTheAxe commentedon Sep 27, 2026
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
does...
and even with all the C#-ness overhead it does all that in <150ms
DrusTheAxe commentedon Sep 27, 2026
ApplicationData: Optimize *Path properties #6731 optimizes ApplicationData methods:
duckheadsoftware commentedon Sep 27, 2026
30ms is less than 150ms.