-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix route analyzer performance with highly concatenated strings #54479
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
Conversation
@jjonescz, @CyrusNajmabadi, @cston Roslyn expert opinion on this fix would be great. |
src/Framework/AspNetCoreAnalyzers/test/RouteEmbeddedLanguage/RoutePatternAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
...oreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/RouteStringSyntaxDetector.cs
Outdated
Show resolved
Hide resolved
...oreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/RouteStringSyntaxDetector.cs
Outdated
Show resolved
Hide resolved
...oreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/RouteStringSyntaxDetector.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/test/RouteEmbeddedLanguage/RoutePatternAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/test/RouteEmbeddedLanguage/RoutePatternAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/test/RouteEmbeddedLanguage/RoutePatternAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/Infrastructure/RouteUsageCache.cs
Outdated
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/RoutePatternAnalyzer.cs
Outdated
Show resolved
Hide resolved
...oreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/RouteStringSyntaxDetector.cs
Outdated
Show resolved
Hide resolved
I've greatly simplified this PR. The new workaround is to avoid calling Detection behavior doesn't 100% emulate embedded language classification by Roslyn, but I've found some odd quirks when mixing multiple lang comments in a string concat tree from Roslyn anyway. The analyzer behavior here is good enough for normal usage. It's the best balance I've found between good behavior, good performance, and minimal code change. |
...oreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/RouteStringSyntaxDetector.cs
Outdated
Show resolved
Hide resolved
@JamesNK i just went with dotnet/roslyn#72620 as a simple approach. |
Perfect, I like it. Trying to match Roslyn behavior while getting good perf was wrapping this PR up in knots. Great that Roslyn just simplified, and this PR can copy it. Performance with this change is good - 0.09s after compared to 5s before |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
… string concatenations
…outePatternAnalyzerTests.cs Co-authored-by: Martin Costello <martin@martincostello.com>
ccc7afe
to
c00323c
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/aspnetcore/actions/runs/8429842063 |
Fixes #54293
Fixes #53899
Route analyzer introduced in .NET 8 is causing very long build times if some projects. Highly concatenated strings caused a lot of time to be spent in
HasLanguageComment
.The PR:
0.2 seconds0.05 secondsThis PR will likely be backported to 8.0.