Suggested perf improvements in DataFlowAnalysis#54126
Open
Alex-Sob wants to merge 6 commits intodotnet:mainfrom
Open
Suggested perf improvements in DataFlowAnalysis#54126Alex-Sob wants to merge 6 commits intodotnet:mainfrom
Alex-Sob wants to merge 6 commits intodotnet:mainfrom
Conversation
This was referenced Apr 28, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a few suggested performance improvements in
DataFlowAnalysis:.Any()call onPooledSortedSet<T>isEnumerable.Anyextension method call, that type does not have its ownAnymethod like some types do, e.g.ArrayBuilder<T>. AsEnumerable.Anyperforms type checks, it should be better to check.Count.I believe there's a standard CA1860 rule for those kind of cases. As it's included in
Minimumanalysis mode, I also prepared PR Use AnalysisMode=minimum in Microsoft.CodeAnalysis.NetAnalyzers and fix errors (perf rules) #50367 to start catching these errors.There are a few issues with the part of code in
RunCoremethod:.Whereallocating an enumerable.Wherecreates closure.Whereis enumerated multiple times.I'd suggest to re-write that part with a simple loop to avoid these issues.
Regarding multiple enumeration, there's a standard CA1851 rule, I believe it was added in .NET 7.
The delegate passed to
.Anycall inHasUnprocessedPredecessorBlockalso creates closure.