Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Jan 25, 2025

Followup to #76917

Primary change is making a new helper structure to capture many parameters taht are passed along to so many methods in these codepaths.

ToddGrun and others added 30 commits January 23, 2025 15:10
In the scrolling speedometer test, the Roslyn CodeAnalysis process shows about 25% of CPU spent in this method. Of that, a surprising amount of it (11.2%) is spent in ImmutableSegmentedDictionary.TryGetValue. Debugging through this code, it appears this is because that is called O(m x n) times where m is the number of nodes to analyze and n is the number of items in groupedActions.GroupedActionsByAnalyzer.

Instead, add a hook into GroupedAnalyzerActions to allow a mapping of kind -> analyzers. This can be used by executeNodeActionsByKind to get a much quicker way to determine whether the analyzer can contribute for the node in question.

Only publishing this early so Cyrus can take a peek, as I still need to do a bit of debugging around these changes. Once Cyrus and I think the changes have merit, I will create a test insertion and publish the speedometer results once those are available. Only if all that goes well will I promote this PR out of draft mode.
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review February 4, 2025 22:06
SyntaxNode node,
ISymbol containingSymbol,
SemanticModel semanticModel,
ExecutionData executionData,
Copy link
Member Author

Choose a reason for hiding this comment

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

this subsumes the common 4 pieces of data passed to all these methods.

node, containingSymbol, semanticModel, AnalyzerOptions, addDiagnostic,
isSupportedDiagnostic, filterSpan, isGeneratedCode, cancellationToken);
node, executionData.DeclaredSymbol, executionData.SemanticModel, AnalyzerOptions, addDiagnostic,
isSupportedDiagnostic, executionData.FilterSpan, executionData.IsGeneratedCode, cancellationToken);
Copy link
Member Author

Choose a reason for hiding this comment

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

note: i could push the ExecutionData struct into these context objects to make them smaller as well if that's desired.

@jcouv jcouv self-assigned this Feb 5, 2025
cancellationToken);
}

private readonly record struct ExecutionData(
Copy link
Member

Choose a reason for hiding this comment

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

The compiler's use of records is very restricted. It doesn't seem like we're making use of Equals on this new type, so it should just be a regular struct.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure. i can do that. though it seems very verbose. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, it needs to be even more verbose ;-) We also don't do primary constructor captures.
This should have been flagged by an analyzer: dotnet/roslyn-analyzers#7138
Tagging @333fred to confirm

Copy link
Member Author

@CyrusNajmabadi CyrusNajmabadi Feb 6, 2025

Choose a reason for hiding this comment

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

what is the value in that verbosity? like... at least with records i can see not wanting the IL/metadata. But really this seems to be adding noise and hiding clear concepts in lots of code. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

note: the analyzer you are referencing disallows implicit capture. there is no implicit capture. it's all explicitly written to the explicit fields.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (iteration 59)

@CyrusNajmabadi CyrusNajmabadi requested a review from jcouv February 6, 2025 01:38
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 61)

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) February 6, 2025 02:02
@CyrusNajmabadi CyrusNajmabadi merged commit e83c680 into dotnet:main Feb 6, 2025
24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 6, 2025
@CyrusNajmabadi CyrusNajmabadi deleted the driverGenerics2 branch February 6, 2025 03:16
@akhera99 akhera99 modified the milestones: Next, 17.14 P2 Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants