Repository navigation
perf(@angular/build): reduce watcher debounce latency for faster incremental rebuilds - #34048
Conversation
ef27fe2 to
59aea7b
Compare
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.
59aea7b to
50b8f2e
Compare
…er incremental rebuilds
9047e9f to
92b9a2f
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.