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
When StaticAssetDevelopmentRuntimeHandler.EnableSupport is enabled in the development environment, websites with many static resources may experience significant delays.
The delay occurs primarily during the first request due to an O(n^2) loop in the UpdateEndpoints process.
Each static resource endpoint builder invokes the AttachRuntimePatching method and then the FindOriginalAsset method to iterate through all descriptors.
If there are 10,000 static files(js/css/images) under the wwwroot folder, this leads to 10,000 x 10,000 iterations on the first request.
About 3000+ static files are in the wwwroot folder.
The app takes ~15 seconds to start.
04:22:55.053 to 04:23:10.005
StaticAssetDevelopmentTest>dotnet run
04:22:55.010 info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[62] User profile is available.
Using '.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.04:22:55.053 info: Program[0] Application start
04:23:10.005 info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:528504:23:10.005 info: Microsoft.Hosting.Lifetime[0] Application started.Press Ctrl+C to shut down.04:23:10.006info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development
After setting "ReloadStaticAssetsAtRuntime": false, There is no delay anymore.
StaticAssetDevelopmentTest>dotnet run
04:29:42.732 info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[62] User profile is available.
Using '.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.04:29:42.768 info: Program[0] Application start
04:29:42.859 info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:528504:29:42.859 info: Microsoft.Hosting.Lifetime[0] Application started.Press Ctrl+C to shut down.04:29:42.859info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development
When
StaticAssetDevelopmentRuntimeHandler.EnableSupport
is enabled in the development environment, websites with many static resources may experience significant delays.The delay occurs primarily during the first request due to an
O(n^2)
loop in theUpdateEndpoints
process.Each static resource endpoint builder invokes the
AttachRuntimePatching
method and then theFindOriginalAsset
method to iterate through all descriptors.If there are
10,000
static files(js/css/images
) under thewwwroot
folder, this leads to10,000 x 10,000
iterations on the first request.Thanks.
aspnetcore/src/StaticAssets/src/StaticAssetsEndpointRouteBuilderExtensions.cs
Lines 39 to 42 in af22eff
aspnetcore/src/StaticAssets/src/StaticAssetEndpointDataSource.cs
Lines 99 to 119 in af22eff
aspnetcore/src/StaticAssets/src/Development/StaticAssetDevelopmentRuntimeHandler.cs
Lines 29 to 38 in af22eff
aspnetcore/src/StaticAssets/src/Development/StaticAssetDevelopmentRuntimeHandler.cs
Lines 145 to 156 in af22eff
The text was updated successfully, but these errors were encountered: