perf(builder): watch bounded source-tree roots instead of one watcher per file - #115
Draft
arifsisman wants to merge 1 commit into
Draft
Conversation
… per file Follow-up to native-federation#96. The widened watch list registered one fs watcher per tracked federation source — ~1,900 watchers on a real Nx workspace. Per-file watchers do not scale: macOS FSEvents replays and throttles under that many streams, and every platform pays a file descriptor per watcher. federationWatchPaths() collapses the tracked files into the few top-level workspace source trees that contain them (libs, apps, ...) and both builders watch those roots recursively instead. Because a directory watch surfaces every event under the root, relevance is now filtered where events arrive: only tracked federation sources, project-root files and linked-dir edits pass, and only when their mtime actually advanced (the native-federation#96 stale-event filter). Irrelevant events no longer reach the dirty buffer at all. Files outside the workspace, at the workspace root, or under dot dirs, node_modules and build outputs stay as single-file watches; nested candidates deduplicate to their parent tree. Covered by five new unit tests; validated on the same Nx + Angular 22 workspace as native-federation#96 (files=~1900 collapses to roots=2).
Contributor
Author
|
Note on the red Two advisories ( #116 fixes it via the existing |
Contributor
|
Might be superseded by #112 |
Contributor
|
I'd love to hear your feedback on how it performs: https://github.com/native-federation/angular-adapter/releases/tag/v22.1.0-RC1 |
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.
Follow-up to #96.
Problem
The widened watch list from #96 registers one fs watcher per tracked federation source — ~1,900 watchers on the same real Nx workspace the original fix was measured on. Per-file watchers don't scale:
syncNfFileWatcherpass re-diffs the full file list.Change
federationWatchPaths(files, workspaceRoot)collapses the tracked files into the few top-level workspace source trees that contain them (libs,apps, ...), and both builders watch those roots recursively instead. On the measured workspace:files=~1900collapses toroots=2(logged at verbose level).Because a directory watch surfaces every event under its root, relevance moves to where events arrive:
createDebouncedChangeWatcher, so irrelevant events never enterpendingPaths.Safety rails: files outside the workspace, at the workspace root itself, or under dot dirs /
node_modules/ build outputs stay as single-file watches; nested candidates deduplicate to their parent tree.Verification
federationWatchPaths(collapse, out-of-workspace, excluded top-levels, root-level file, parent/child dedup);typecheck,lint(0 errors, warning count unchanged) andvitest(16 files / 116 tests) pass.