Skip to content

Reduce allocations in TextBufferFactoryCloneService.Clone#82777

Merged
ToddGrun merged 2 commits into
dotnet:mainfrom
ToddGrun:dev/toddgrun/ReduceAllocationsInTextBufferCloneService.Clone
Mar 17, 2026
Merged

Reduce allocations in TextBufferFactoryCloneService.Clone#82777
ToddGrun merged 2 commits into
dotnet:mainfrom
ToddGrun:dev/toddgrun/ReduceAllocationsInTextBufferCloneService.Clone

Conversation

@ToddGrun

@ToddGrun ToddGrun commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Builds on #82462

Found another location in roslyn that was potentially creating a text buffer through realization of the full text of a source text. Instead, use the SourceTextReader similar to what was done in the previous PR. This shows a nice reduction in allocations in the lightbulb speedometer test, particularly LOH allocations.

*** Before ***
image

*** After ***
image

Microsoft Reviewers: Open in CodeFlow

Builds on dotnet#82462

Found another location in roslyn that was potentially creating a text buffer through realization of the full text of a source text. Instead, use the SourceTextReader similar to what was done in the previous PR.
@ToddGrun ToddGrun requested a review from a team as a code owner March 15, 2026 19:08
@ToddGrun

Copy link
Copy Markdown
Contributor Author

/pr-val

@github-actions

Copy link
Copy Markdown
Contributor

View PR Validation Run triggered by @ToddGrun

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82777
  • Commit SHA: 65a071f80a302e692e41fd7194ecdcf8e6f19009
  • Source Branch: dev/toddgrun/ReduceAllocationsInTextBufferCloneService.Clone
  • Target Branch: main
  • Build ID: 13559419

@ToddGrun

Copy link
Copy Markdown
Contributor Author

/pr-val

@github-actions

Copy link
Copy Markdown
Contributor

View PR Validation Run triggered by @ToddGrun

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82777
  • Commit SHA: 65a071f80a302e692e41fd7194ecdcf8e6f19009
  • Source Branch: dev/toddgrun/ReduceAllocationsInTextBufferCloneService.Clone
  • Target Branch: main
  • Build ID: 13559485

@ToddGrun

Copy link
Copy Markdown
Contributor Author

/pr-val

@github-actions

Copy link
Copy Markdown
Contributor

View PR Validation Run triggered by @ToddGrun

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82777
  • Commit SHA: 843b09ed7ebb3731241b6d924f19abc4eddcdb1a
  • Source Branch: dev/toddgrun/ReduceAllocationsInTextBufferCloneService.Clone
  • Target Branch: main
  • Build ID: 13559625

@ToddGrun

Copy link
Copy Markdown
Contributor Author

@dotnet/roslyn-ide ptal

@jasonmalinowski jasonmalinowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice find!

@ToddGrun ToddGrun merged commit d2d357d into dotnet:main Mar 17, 2026
25 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Mar 17, 2026
@jjonescz jjonescz modified the milestones: Next, 18.6 Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants