perf(@angular/build): reduce watcher debounce latency for faster incremental rebuilds - #34048
Open
alan-agius4 wants to merge 1 commit into
Open
perf(@angular/build): reduce watcher debounce latency for faster incremental rebuilds#34048alan-agius4 wants to merge 1 commit into
alan-agius4 wants to merge 1 commit into
Conversation
alan-agius4
force-pushed
the
perf/watcher-debounce-tuning
branch
from
September 9, 2026 07:26
ef27fe2 to
59aea7b
Compare
alan-agius4
marked this pull request as ready for review
September 9, 2026 08:21
There was a problem hiding this comment.
Code Review
This pull request introduces a debouncing mechanism with a maximum wait time to the WatcherQueue class, ensuring that file changes are flushed within a specified timeframe. The review feedback highlights two valuable improvement opportunities: using a local variable to maintain TypeScript type narrowing for firstChangeTime across external function calls, and removing a redundant reset of firstChangeTime inside the setTimeout callback since it is already handled in the flush method.
…emental rebuilds Previously, the esbuild file watcher utilized a static 250 ms trailing debounce timer (scheduleFlush) after each filesystem change event. In incremental watch mode rebuilds where the actual compile and bundle step takes 150 ms to 220 ms, this 250 ms debounce delay accounted for over 50% of the developer-perceived turnaround time. To accelerate the developer edit-refresh feedback loop: - Replace the fixed 250 ms debounce in WatcherQueue with an adaptive debounce mechanism. - Use a 100 ms debounce delay to reliably coalesce rapid multi-file atomic saves and editor formatters while reducing debounce latency by 60% (150 ms faster). - Introduce a 250 ms maximum wait ceiling (maxWaitMs) to ensure rebuilds are not postponed indefinitely during continuous file events. In benchmarks on ng build --watch, single-file save turnaround dropped from 470–550 ms to ~250–320 ms (~45% reduction in latency), saving approximately 150 ms per save.
alan-agius4
force-pushed
the
perf/watcher-debounce-tuning
branch
from
September 9, 2026 08:27
59aea7b to
50b8f2e
Compare
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.
Previously, the esbuild file watcher utilized a static 250 ms trailing debounce timer (scheduleFlush) after each filesystem change event.
In incremental watch mode rebuilds where the actual compile and bundle step takes 150 ms to 220 ms, this 250 ms debounce delay accounted for over 50% of the developer-perceived turnaround time.
To accelerate the developer edit-refresh feedback loop:
In benchmarks on ng build --watch, single-file save turnaround dropped from 470–550 ms to ~250–320 ms (~45% reduction in latency), saving approximately 150 ms per save.