Skip to content

Conversation

@drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Jun 23, 2025

Fixes #2707

Lifeng reported that calling GetActiveConfiguredProjectExports on the base class was taking 0.5 seconds of CPU while loading Roslyn.sln.

This change uses IActiveConfiguredValue<> to cache the instance, to improve performance while building dependencies trees across the solution during solution load.

The same optimisation is applied to ImportTreeProvider as well.

Microsoft Reviewers: Open in CodeFlow

Fixes dotnet#2707

Lifeng reported that calling `GetActiveConfiguredProjectExports` on the base class was taking 0.5 seconds of CPU while loading Roslyn.sln.

This change uses `IActiveConfiguredValue<>` to cache the instance, to improve performance while building dependencies trees across the solution during solution load.
The IDE suggests this.
This style is uncommon in this repo, so document that/why it's needed here.
This caches the configured value in the ImportTreeProvider, as recently done for the DependenciesTreeProvider.
@drewnoakes drewnoakes added the Tenet-Performance This issue affects the "Performance" tenet. label Jun 23, 2025
@drewnoakes drewnoakes requested a review from a team as a code owner June 23, 2025 03:07
@drewnoakes drewnoakes added Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references Feature-Import-Tree Performance-Scenario-Solution-Open This issue affects solution open performance. Performance-Scenario-General This issue affects performance in general. labels Jun 23, 2025
}
}

// NOTE this interface is needed to work around accessiblity issues when making MyConfiguredProjectExports non-private
Copy link
Member

Choose a reason for hiding this comment

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

could you be more specific in this comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly this one had me stumped. The compiler claimed there was a visibility issue (CS0060), and the issue couldn't be suppressed. Something to do with the base type being protected internal yet in a different assembly, maybe. I was confused enough to even view (and edit) the docs for that diagnostic. So, I don't have much more context to add here. If you remove the interface and try to export the concrete type, you'll see the issue.

@drewnoakes drewnoakes merged commit 6b4f781 into dotnet:main Jun 24, 2025
5 checks passed
@drewnoakes drewnoakes deleted the fix-2707-dep-tree-perf branch June 24, 2025 01:30
@dotnet-policy-service dotnet-policy-service bot added this to the 17.15 milestone Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references Feature-Import-Tree Performance-Scenario-General This issue affects performance in general. Performance-Scenario-Solution-Open This issue affects solution open performance. Tenet-Performance This issue affects the "Performance" tenet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perf: DependenciesTree UpdateTree logic (BuildTreeForSnapshotAsync) is way too expensive

2 participants