fix(core): disable output tracking watcher on Windows - #36566
Draft
sdjayna wants to merge 2 commits into
Draft
Conversation
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
1 task
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.
Current Behavior
The Nx daemon starts two workspace-wide watchers: a source watcher and an output-tracking watcher. On Windows, both enumerate eligible directories and register them non-recursively.
notifyretains a directory HANDLE and completion-semaphore HANDLE for every registration.For normal source directories, this duplicates registration cost: both watchers allocate a directory HANDLE and completion semaphore. Git-ignored directories are excluded by the source watcher but still registered by the broad output watcher.
The public reproduction uses Git-ignored directories specifically to isolate the output watcher's two-HANDLE slope. The PR removes that watcher across the workspace; it is not a Git-ignore-specific fix.
Expected Behavior
Windows should not pay a second workspace-wide per-directory HANDLE and memory cost for an output-tracking optimization. Cache correctness must be preserved through conservative misses, and source watching must remain unchanged.
After the fix:
Before / After Acceptance
The before values are measured on stock Nx 23.1.1. The after values are acceptance targets, not patched results yet.
false)Raw public measurements:
The regressions are nearly perfectly linear: HANDLE R² ≈ 1.0, private-memory R² 0.99999, and graph-command R² 0.99969. The fixture is Git-ignored, so this primarily isolates the broad output watcher. The memory slope is consistent with
notify's 16 KB per-watch buffer plus overhead, but is not presented as byte-level attribution.A separate large-workspace field observation reached 161,876 handles and approximately 2.48 GB. It motivated the investigation; the public 131,072-directory run independently exceeds its handle count and reaches the same multi-gigabyte process range.
What This PR Changes
disableOutputsTracking()fallback.falseeven for a previously recorded matching hash.Testing
Completed locally:
Required with a dedicated PR release:
Risk and Mitigation
The trade-off is performance, not correctness: Windows may perform additional output restoration/copy work because output tracking returns conservative misses. The source watcher remains active, and no file-change event used for project-graph correctness is removed.
If the cache-copy cost is material, a future Windows output tracker should watch only known output roots or use a bounded backend. It should not return to a second workspace-wide per-directory watcher.
Related Issue(s)
Fixes #36563
This draft requests a dedicated PR release for measured Windows HANDLE, memory and cache-replay before/after results.