Skip to content

Avoid compilation stalls when source files are deleted - #86286

Merged
dibarbet merged 6 commits into
dotnet:mainfrom
dibarbet:dibarbet-source-deletion-stalls
Nov 3, 2026
Merged

dibarbet merged 6 commits into
dotnet:mainfrom
dibarbet:dibarbet-source-deletion-stalls

Conversation

@dibarbet

@dibarbet dibarbet commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Resolves #86236

Deletion notifications can invalidate document text before a project reload removes the documents. Applying those pending text updates can load missing files and stall compilation while the text loader retries.

UpdateOrRemoveDocumentsAction merges consecutive pending source-document updates and removals. It retains the original project state, the final project state, and the affected document IDs. Surviving documents use their final syntax trees. Removed documents have their original trees removed without loading replacement text. Other translation kinds prevent merging, and the text loader's retry behavior remains unchanged.

Earlier in-process language-server project-loading verification reduced the semantic-model wait after deleting 20 files from about 20.5 seconds to about 0.6 ms for individual deletions and 14.9 ms for directory deletion. These were individual measurements, not benchmark averages. Those server-specific tests are not retained in the final PR.

Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
dibarbet and others added 4 commits November 2, 2026 11:58
Restore the original text-loader retry policy and avoid loading obsolete document states during compilation updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep focused SolutionTests coverage, clarify test names and scenario blocks, and remove the server-path test additions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Split changed-then-removed and interleaved updates into focused tests. Assert final syntax trees and obsolete loader counts without symbol queries or GC.KeepAlive.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep method names unchanged and move the issue link from the product comment to regression test WorkItem attributes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@dibarbet
dibarbet marked this pull request as ready for review November 2, 2026 21:48
@dibarbet
dibarbet requested a review from a team as a code owner November 2, 2026 21:48
Copilot AI balanced review requested due to automatic review settings November 2, 2026 21:48
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the changes merging pending source-document updates and removals.

No open issues 🎉

What changed in this PR

Addresses deletion-related compilation stalls in Roslyn’s workspace layer by merging pending source-document updates and removals, avoiding reads of obsolete text.

Changes:

  • Uses original syntax trees and final document states to apply merged updates and removals.
  • Preserves other translation kinds as merge boundaries, leaving TextLoader retry behavior unchanged.
  • Adds regression tests for removed documents, interleaved updates, and merge boundaries.
File Description
src/​Workspaces/​CoreTest/​SolutionTests/​SolutionTests.cs Adds loader-count and syntax-tree assertions for merged changes and boundaries.
src/​Workspaces/​Core/​Portable/​Workspace/​Solution/​SolutionCompilationState.TranslationAction_Actions.cs Unifies update and removal actions and merges affected document IDs.
src/​Workspaces/​Core/​Portable/​Workspace/​Solution/​SolutionCompilationState.cs Routes source-document updates and removals through the unified action.

Review effort: Balanced

@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 approach!

Rename the action to UpdateOrRemoveDocumentsAction, remove the deletion-specific merge comment, and use the same setup comment in each regression test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 22:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the change that skips obsolete document text updates before pending removals.

No open issues 🎉

Review effort: Balanced

@dibarbet
dibarbet enabled auto-merge November 2, 2026 22:39
@dibarbet
dibarbet merged commit 69eab35 into dotnet:main Nov 3, 2026
23 checks passed
@dibarbet
dibarbet deleted the dibarbet-source-deletion-stalls branch November 3, 2026 00:04
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Nov 3, 2026
@akhera99 akhera99 modified the milestones: Next, 18.14 Nov 20, 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.

Language server: deleting many source files stalls every request that needs the project's compilation, about 1 s per deleted file

4 participants