Skip to content

Use lazy initialization for members in CodeFixService #78484

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

Merged
merged 1 commit into from
May 8, 2025

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented May 7, 2025

Defer expensive member initialization in the CodeFixService constructor.

The Roslyn speedometer test shows this ctor as taking ~28ms during first C# file open while on the main thread. Instead, we can make a couple members lazy and have them initialized when needed (which happens much later, if at all, and on a bg thread)

*** Before change ***
image

*** After change ***
image

Will add more details in speedometer results come back with improvements
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 7, 2025
@ToddGrun ToddGrun changed the title *** WIP: Use lazy initialization for members in CodeFixService Use lazy initialization for members in CodeFixService May 8, 2025
@ToddGrun ToddGrun marked this pull request as ready for review May 8, 2025 17:00
@ToddGrun ToddGrun requested a review from a team as a code owner May 8, 2025 17:00
@ToddGrun ToddGrun merged commit 5e99a9f into main May 8, 2025
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 8, 2025
333fred added a commit to 333fred/roslyn that referenced this pull request May 8, 2025
* upstream/main: (415 commits)
  Use lazy initialization for members in CodeFixService (dotnet#78484)
  Targeted perf changes to CommandLineParser (dotnet#78446)
  Exclude VS.ExternalAPIs.Roslyn.Package from source-build
  Add syntax highlighting of ignored directives (dotnet#78458)
  Fix unexpected conditional state in nullable analysis of conditional access (dotnet#78439)
  Update RoslynAnalyzers to use Roslyns version
  Fix source-build by renaming Assets folder to assets
  Unlist M.CA.AnalyzerUtilities as an expected DevDivInsertion dependency
  Use a project reference for M.CA.AnalyzerUtilities
  Rectify status of dictionary expressions (dotnet#78497)
  Remove unused field
  Remove unused field
  Remove using
  Fix check
  Update eng/config/PublishData.json
  Make internal
  Remove now unused methods from IWorkspaceProjectContext (dotnet#78479)
  Reduce allocations during SourceGeneration (dotnet#78403)
  Update Roslyn.sln
  Merge EditorFeatures.Wpf entirely into EditorFeatures
  ...
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 VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants