Overview:
Razor IDynamicFileInfoProvider output is fed into SourceGenerators which breaks C# incrementality and significantly impacts performance.
Version Used: All
Steps to Reproduce:
- Create a Blazor server application
- 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:

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
Overview:
Razor IDynamicFileInfoProvider output is fed into SourceGenerators which breaks C# incrementality and significantly impacts performance.
Version Used: All
Steps to Reproduce:
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:
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