perf(language-service): progressive project initialization #66966
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: perf(language-service): progressive project initialization
Description
Replaces the blocking
project.refreshDiagnostics()during project initialization with a progressive background approach. Instead of sending all diagnostic refresh events at once, open files are now processed in configurable chunks with event loop yields between them, keeping the IDE responsive during Angular project startup.Problem
When a project finishes loading (
ProjectLoadingFinishEvent), the language server calls:The
project.refreshDiagnostics()call sends aProjectsUpdatedInBackgroundEventwhich triggers diagnostic computation for all open files. While the existingsendPendingDiagnosticsalready yields between individual files, the initial event processing can still cause a burst of work that degrades IDE responsiveness during startup.Solution
Replaced
project.refreshDiagnostics()with a newinitializeProjectProgressively()method that:setImmediateP()Cancellation Integration
Progressive initialization integrates with the existing diagnostics system:
triggerDiagnostics()is called (file opened/changed), any ongoing progressive init is cancelled viaprogressiveInitCancelledflagdiagnosticsTimeoutcancellation logicChanges
vscode-ng-language-service/server/src/session.tsprogressiveInitCancelledfield,initializeProjectProgressively()method, cancellation intriggerDiagnostics(), replacedproject.refreshDiagnostics()inenableLanguageServiceForProject()Impact
Testing
//packages/language-service/...//vscode-ng-language-service/integration/lsp:test//vscode-ng-language-service/server/src/tests:testBreaking Changes
None. This is an internal optimization that doesn't change observable behavior.
Related
Complements:
AI Disclosure
This PR was developed using Claude Opus 4 AI assistant under human orchestration and review by @kbrilla.
Integration
See #66967 for integration with Pull-Based Diagnostics, which optimizes progressive init to use
workspace/diagnostic/refreshinstead of computing and pushing diagnostics when the client supports pull-based diagnostics.