Commit 382a280
committed
perf(@angular/build): consolidate build worker pools with shared router
Unify isolated per-subsystem worker pools (JavaScriptTransformer, I18nInliner) into a single singleton WorkerPool routed via dynamic task dispatching (shared-worker-router.ts).
- Reduce active worker threads by 50.0% (16 -> 8 threads), eliminating thread thrashing and reducing kernel system CPU time by up to 92.6%.
- Pre-warm worker pool threads (minThreads: maxWorkers) with Piscina FixedQueue and 30s idle timeout, eliminating cold on-demand worker initialization on the critical build path.
- Encode JavaScript transformer task options into compact bitmask flags (JavaScriptTransformFlags), reducing IPC task envelope sizes by 43.3% and eliminating object allocations.
- Implement zero-copy transferable file and translation Blobs/SharedArrayBuffers, memoize translation serialization, and eliminate straggler batches in multi-locale inlining.
- Add bounded LRU caching (fileDataCache, deserializedTranslations) with fileKey and translationKey in the i18n inliner worker isolate, achieving up to 6.45x faster i18n inlining without memory leaks.
- Monotonic sequence IDs for futex synchronizations, structured IPC error propagation, post-close lifecycle guards, sourcemap passthrough on untransformed files, full SharedArrayBuffer cache key hashing, inline stylesheet watch tracking, and bundler invalidation epoch guards.
| Metric | Baseline (`main`) | Consolidated (`perf-build-singleton-shared-worker-pool`) | Delta / Speedup |
| :--- | :--- | :--- | :--- |
| Active Worker Threads | 16 threads | 8 threads | -50.0% threads (-8 threads) |
| Cold Build Duration (mean) | 3,462.2 ms | 798.1 ms | 4.34x faster (-76.9%) |
| Cold Build Duration (min / max) | 3,370.7 ms / 3,566.6 ms | 777.6 ms / 809.4 ms | -2,593.1 ms / -2,757.2 ms |
| P95 Build Latency | 3,566.6 ms | 809.4 ms | -77.3% (-2,757.2 ms faster) |
| Throughput | 1,011.3 ops/sec | 4,386.3 ops/sec | +333.7% (+3,375.0 ops/sec) |
| I18n Inlining Duration (Pure mean) | 3,159.4 ms | 489.6 ms | 6.45x faster (-84.5%) |
| Process RSS Delta | +13,904.4 MB | +1,095.6 MB | -92.1% (-12,808.8 MB saved) |
| Final Process RSS | 13,974.8 MB | 1,166.2 MB | -91.7% (-12,808.6 MB saved) |
| Kernel System CPU | 15,057.7 ms | 1,121.6 ms | -92.6% (13.42x less kernel CPU) |
| Total CPU (User + Kernel) | 100,569.5 ms | 6,949.3 ms | -93.1% (14.47x CPU efficiency) |
| Metric | Baseline (`main`) | Consolidated (`perf-build-singleton-shared-worker-pool`) | Delta / Speedup |
| :--- | :--- | :--- | :--- |
| Active Worker Threads | 16 threads | 8 threads | -50.0% threads (-8 threads) |
| E2E Build Duration (mean) | 6,249.8 ms | 5,877.2 ms | -6.0% (-372.6 ms faster) |
| E2E Build Duration (min / max) | 6,200.9 ms / 6,291.2 ms | 5,824.0 ms / 5,968.8 ms | -376.9 ms / -322.4 ms |
| P95 Build Latency | 6,291.2 ms | 5,968.8 ms | -5.1% (-322.4 ms faster) |
| Process RSS Delta | +1,484.0 MB | +1,823.8 MB | +22.9% (+339.8 MB) |
| Kernel System CPU | 2,012.8 ms | 1,845.6 ms | -8.3% (1.09x less kernel CPU) |
| Total CPU (User + Kernel) | 18,267.7 ms | 15,781.7 ms | -13.6% (-2,485.9 ms CPU saved) |
| Metric | Baseline (`main`) | Consolidated (`perf-build-singleton-shared-worker-pool`) | Delta / Speedup |
| :--- | :--- | :--- | :--- |
| Active Worker Threads | 16 threads | 8 threads | -50.0% threads (-8 threads) |
| Cold Build Duration (mean) | 2,226.5 ms | 2,228.5 ms | +0.1% (+2.0 ms) |
| Cold Build Duration (min / max) | 2,181.8 ms / 2,270.5 ms | 2,206.7 ms / 2,259.5 ms | +24.9 ms / -11.0 ms |
| P95 Build Latency | 2,270.5 ms | 2,259.5 ms | -0.5% (-11.0 ms faster) |
| Process RSS Delta | +1,175.8 MB | +1,347.8 MB | +14.6% (pool pre-warming) |
| Kernel System CPU | 1,137.7 ms | 1,069.3 ms | -6.0% (1.06x less kernel CPU) |
| Total CPU (User + Kernel) | 8,853.5 ms | 8,529.1 ms | -3.7% (-324.4 ms CPU saved) |1 parent d11a663 commit 382a280
14 files changed
Lines changed: 801 additions & 190 deletions
File tree
- packages/angular/build/src
- tools/esbuild
- angular
- utils
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
| 232 | + | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
236 | 239 | | |
237 | 240 | | |
238 | 241 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | 144 | | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
504 | | - | |
| 504 | + | |
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
767 | | - | |
| 767 | + | |
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| |||
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | | - | |
132 | | - | |
| 132 | + | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| 206 | + | |
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
| |||
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | | - | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
286 | 288 | | |
287 | 289 | | |
288 | 290 | | |
289 | | - | |
290 | | - | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
292 | 295 | | |
293 | 296 | | |
294 | 297 | | |
| |||
551 | 554 | | |
552 | 555 | | |
553 | 556 | | |
| 557 | + | |
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
| |||
582 | 586 | | |
583 | 587 | | |
584 | 588 | | |
585 | | - | |
| 589 | + | |
586 | 590 | | |
587 | 591 | | |
588 | 592 | | |
| |||
0 commit comments