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

Cache ShouldAnalyzeTree results for better performance #8411

Closed

Conversation

sebastien-marichal
Copy link
Contributor

@sebastien-marichal sebastien-marichal commented Nov 27, 2023

Fixes #8406

Solution using ConcurrentDirctionary within the AnalysisContext.

On oqtane framework, before changes:
image

After changes:
image

From RegisterNodeAction point of view:
Before:
image
After:
image

Copy link

sonarcloud bot commented Nov 27, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@@ -47,6 +47,9 @@ public abstract class SonarAnalysisContextBase<TContext> : SonarAnalysisContextB
public SonarAnalysisContext AnalysisContext { get; }
public TContext Context { get; }

private readonly ConcurrentDictionary<SyntaxTree, bool> shouldAnalyzeTreeCache = new();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open another PR, where the ConcurrentDictionary<SyntaxTree, bool> is used the same way as lastShouldAnalyze in https://github.com/SonarSource/sonar-dotnet/pull/8407/files

  • Caches the result of ShouldAnalyzeTree && LegacyIsRegisteredActionEnabled && ShouldAnalyzeRazorFile
  • Is scoped by the capture in the CompilationStart
  • Is scoped to RegisterNodeAction only

That way, we can compare the results between lastShouldAnalyze and the concurrent dict.

@sebastien-marichal
Copy link
Contributor Author

Closing this PR in favor of #8414.

@sebastien-marichal sebastien-marichal deleted the sebastien/shouldanalyzertree-dictionary branch March 6, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache RegisterNodeAction checks result per SyntaxTree
2 participants