AspNet Core 3.1 Razor compilation extremely slow (dozen of minutes) for a view with big static html table
See original GitHub issueI’ve updated an asp.net core 2.2 mvc website to core 3.1 and found razor compilation extremely slow. I’m talking dozen of minutes! After a couple of hours I’ve found the problem: I had a 5Mb razor view with a big static html table containing 9300 rows. I know this may not be a common scenario but the performance degradation - comparing to netcore 2.2 - is not acceptable and certainly deserves improvement.
I was able to reproduce just creating a new asp.net core 3.1 mvc project and adding the html table to the Home/Index.cshtml
- ASP.NET Core version: 3.1
- Visual Studio 2019 version 16.4.1
dotnet --info
output:
.NET Core SDK (reflecting any global.json): Version: 3.1.100 Commit: cd82f021f4
Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.100\
Host (useful for support): Version: 3.1.0 Commit: 65f04fb6db
.NET Core SDKs installed: 2.2.402 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (8 by maintainers)
Top GitHub Comments
Hi @mkArtakMSFT here is a page load time - 18ms when razor is compiled. And I add single whitespace in the razor page and refresh, it takes around 10s in most cases. Some cases I have seen much higher. Trying to figure out how to send you a repro project.
In 2.2 it was definitely not noticeable like this, but do not have the time taken there recorded.
@agrinei, thanks for the report. You can unblock yourself in the mean time by doing one of the following,
Option 1
Move the large static table to a separate .html file and then do,
Option 2
Move the contents inside a script tag and embed it as a string,