-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Very slow build - can't build project #54293
Comments
@mokshinpv, thanks for reporting this issue. Currently, the repro project fails with:
|
Hi, @cston, I think it should work, I downloaded project now and Antlr4 package was downloaded correctly from Nuget. Libraries from csproj file: <ItemGroup>
<PackageReference Include="Antlr4" Version="4.6.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Antlr4.Runtime" Version="4.6.6" />
</ItemGroup> |
Thanks @mokshinpv, I was able to build successfully after all. Are you seeing the compile performance issue when building with I compared build times for the project using the following:
For me, the build times were similar between the two versions, with 17.6.12 perhaps slightly faster. |
Hi, @cston.
Problem with both.
No, I only changed net7.0 to net8.0 in all csproj files. I think the problem is in some analyzers. Here is screenshot of used analyzers: Maybe do you know how to determine analyzers which cause problem with build? |
If you execute |
I have downloaded the sample you provided and compared clean builds between TargetFramework net7.0 / SDK 7.0.100 and TargetFramework net8.0 / SDK 8.0.201. The former builds in ~7 seconds, the latter in ~10 seconds. So there's some slowdown but not that significant. In the screenshot you posted I see RoutePatternAnalyzer takes a ridiculous amount of time. That analyzer does not even run in the small demo you posted, so we cannot investigate the problem without a better repro. But I see there's already an issue tracking performance problems with the analyzer: #53899 |
Hi, here is better repro. |
Thanks @mokshinpv, I can repro that. Clean 7.0.100/net7.0 build took 19 seconds; clean 8.0.201/net8.0 build took 1833 seconds (half an hour), 9.0.100-preview.3.24129.12 build was also taking long time (I didn't wait for it to finish). Note: adding this to dotnet_diagnostic.ASP0017.severity = none
dotnet_diagnostic.ASP0018.severity = none Here's comparison between net7 and net8 builds: |
The problem are probably strings generated by Antl4 like this: I've created a simplified repro with a few strings like that copied over and the analyzer takes 8 seconds: https://github.com/jjonescz/RoslynIssue72148 |
With the simplified repro from @jjonescz, it looks like 46% of the time is in |
Moving to the |
@JamesNK, it looks like |
Is that a problem? The code here: Lines 142 to 206 in 276e3fe
Is copied from Roslyn: |
If |
I've recreated the slow performance in a test: #54479 I looked into this for a couple of hours - and I stepped through code in the aspnetcore repo and Roslyn repo - and to be honest I don't understand why Roslyn's AbstractRegexDiagnosticAnalyzer.AnalyzeToken is fast and RoutePatternAnalyzer.AnalyzeToken is slow. I copied the code for the route analyzer from the regex analyzer. The only modifications I made were to replace missing public APIs. They both call |
I'm going to see if I can optimize walking up the nested string concat tree by remembering the last analyzed string. For example, if "c" in the example below doesn't have a classification then "d" must not have one either: var s = "a" + "b" + "c" + "d"; |
It looks like CSharpRegexDiagnosticAnalyzer has similar perf. In an expression |
Version Used:
8.0.200
Visual Studio 2022, 17.9.0
Steps to Reproduce:
After upgrading to .NET 8 I can't build my project.
Build doesn't finish (maybe infinite loop).
This project contains classes which are generated by Antlr4.
These classes are very large so maybe this causes problems.
I created small project with same problem:
academitslearn.zip
Here build finishes but it takes about 10 seconds.
In previous versions build was immediate.
Expected Behavior:
Build finishes and build is fast.
Actual Behavior:
Build not finishes for real project.
Build is very slow for small project.
The text was updated successfully, but these errors were encountered: