configuration: batch initial policy definitions - #334790
Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit intoSep 6, 2026
Merged
Conversation
Submit regular and excluded policy definitions together so native policy initialization creates one watcher instead of rebuilding it for a second batch. This also shortens the main-thread interval that delays startup file callbacks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
Ulugbek Abdullaev (ulugbekna)
approved these changes
Sep 6, 2026
Dmitriy Vasyura (dmitrivMS)
deleted the
agents/batch-policy-initialization
branch
September 6, 2026 20:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Root cause
While profiling Agents Window startup, the main process appeared to spend 40-50 ms reading state, loading settings, and creating required directories. Direct
fs/promisesmeasurements against the same signed-in profile showed that the actual operations are fast:storage.jsonsettings.jsonmkdir({ recursive: true })The callbacks were delayed together because
PolicyConfiguration.initialize()submitted definitions in two sequential groups:AbstractPolicyServicemerges each changed group and invokes the native implementation.NativePolicyServicetherefore imported/updated the policy watcher for the first group, then disposed and recreated it for the second group before startup I/O callbacks could run.This change combines both key sets before resolving and submitting policy definitions. The resulting policy model is unchanged, but native watcher initialization happens once.
Instrumented startup impact
Three warmed packaged launches per variant, using the same Windows x64 Insiders runtime and signed-in isolated profile:
The callback improvements overlap; they are not additive. They show that removing the redundant watcher update frees the main event loop sooner.
The remaining combined policy segment spends approximately 27 ms importing
@vscode/policy-watcherand 6 ms creating the watcher. #334769 independently targets the packaged ESM resolution work in that import.End-to-end A/B
The first 30 alternating paired launches measured spawn to renderer
code/didStartWorkbench:A second 30-pair batch had a system disturbance around pairs 42-47. Across all 60 pairs, excluding five pairs where either launch exceeded 1,450 ms:
The end-to-end result is directional, not statistically significant. The deterministic result is one fewer native watcher build and an 8-12 ms reduction in the blocking initialization segment.
Compatibility
The previous initialization called
update()twice before registering policy-change listeners. The new initialization calls it once with the union of the same configuration keys. Existing behavior remains covered for:Validation
npm run transpile-clientPolicyConfigurationsuite: 23 passinggit diff --check