Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing in Razor files breaks C# incrementality resulting in high CPU & memory usage #59818

Closed
NTaylorMullen opened this issue Feb 28, 2022 · 6 comments · Fixed by #60531
Closed

Comments

@NTaylorMullen
Copy link
Contributor

Overview:
Razor IDynamicFileInfoProvider output is fed into SourceGenerators which breaks C# incrementality and significantly impacts performance.

Version Used: All

Steps to Reproduce:

  1. Create a Blazor server application
  2. Open Index.razor

Expected Behavior:
Generated output from Index.razor is not fed into Json SourceGenerators

Actual Behavior:
Generated output from Index.razor is fed into Json SourceGenerators

Additional Notes:
@sharwell and I were investigating customer reports of high CPU utilization in Razor scenarios. Turns out Razor files (they emit larger C# files) are always fed into the Json, Logging & any other source generator. This in turn results in a lot of extra CPU churn for Razor projects. After digging into some traces we can see HEAVY allocations in the Roslyn service hub process from the realization of red trees from the Razor files:

image

One implementation note we should think of is that we also have a counter issue where the Regex generators in .NET 7 do not run on Razor output resulting in the new Regex .NET 7 capabilities missing.

/cc @jasonmalinowski

@NTaylorMullen
Copy link
Contributor Author

@jcouv
Copy link
Member

jcouv commented Mar 2, 2022

Assigning to @chsienki to triage.

@jcouv
Copy link
Member

jcouv commented Mar 11, 2022

From discussion with @chsienki, the issue is that IDynamicFiles generated by Razor are visible to other source generators.
Some options:

  1. migrating legacy to Razor to source generators (unlikely in short-term)
  2. add some kind of filtering

@jcouv jcouv added this to the 17.2 milestone Mar 11, 2022
@jcouv jcouv added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 11, 2022
jasonmalinowski added a commit to jasonmalinowski/roslyn that referenced this issue Apr 2, 2022
This is a tactical hack which aims to address some of the CPU overhead
that we were seeing in dotnet#59818.

Closes dotnet#59818
jasonmalinowski added a commit to jasonmalinowski/roslyn that referenced this issue Apr 4, 2022
This is a tactical hack which aims to address some of the CPU overhead
that we were seeing in dotnet#59818.

Closes dotnet#59818
jasonmalinowski added a commit to jasonmalinowski/roslyn that referenced this issue Apr 9, 2022
This is a tactical hack which aims to address some of the CPU overhead
that we were seeing in dotnet#59818.

Closes dotnet#59818
@jasonmalinowski
Copy link
Member

This made it in for 17.2 Preview 4.

@Mike-E-angelo
Copy link

Thank you all very much for all your diligent and amazing work out there. It is greatly appreciated and respected. 🙏

@sharwell sharwell modified the milestones: 17.2, 17.2.P4 May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants