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

Populate the CurrentBlockAnalysisData's _reachingWrites when creating an OperationTreeAnalysis. #73244

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Apr 26, 2024

Populate the CurrentBlockAnalysisData's _reachingWrites when creating an OperationTreeAnalysis.

This is similar to what FlowGraphAnalysisData does upon inspecting a new block.

Inspection of the lightbulb speedometer test demonstrated that a significant portion of CPU (~8%) in our OOP was spent in AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer. Looking at the code a bit indicated that the expensive calls to create/invoke the ControlFlowGraph weren't being short-circuited properly in the trivial cases I tried locally.

When a read operation is encountered, the code looks at all writes that are still unread. For each of these, it updates the map to indicate that the write has now been read. However, this wasn't working for parameters as the _reachingWrites collection didn't account for them.

As the image below indicates, of the 8% of CPU over 7% is accountable to the CFG. With that short-circuited more commonly now, we should save quite a bit of CPU during execution of this analyzer.

image

… an OperationTreeAnalysis.

This is similar to what FlowGraphAnalysisData does upon inspecting a new block.

Inspection of the lightbulb speedometer test demonstrated that a significant portion of CPU (~8%) in our OOP was spent in AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer. Looking at the code a bit indicated that the expensive calls to create/invoke the ControlFlowGraph weren't being short-circuited properly in the trivial cases I tried locally.

When a read operation is encountered, the code looks at all writes that are still unread. For each of these, it upates the map to indicate that the write has now been read. However, this wasn't working for parameters as the _reachingWrites collection didn't account for them.
@ToddGrun ToddGrun requested a review from a team as a code owner April 26, 2024 14:15
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 26, 2024
@CyrusNajmabadi
Copy link
Member

@mavasani

Copy link
Member

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

Thanks!

@ToddGrun
Copy link
Contributor Author

Going to close this PR without merging. I'm very glad there are good tests in this area, as I've had a pretty difficult time understanding exactly how the CFG and the SymbolUsageAnalysis call to prevent the need to call into work together. I feel like these changes and some more I have locally are generally good, but they end up breaking behaviors that were otherwise masked. Without an extremely good understanding of this area, making performance improvements to this area doesn't seem like a good idea.

@ToddGrun ToddGrun closed this Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE 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.

None yet

3 participants