Commit 2cf891f
committed
perf(@angular/build): consolidate build worker pools with shared router
Unify isolated per-subsystem worker pools (JavaScriptTransformer, SassService, I18nInliner) into a single singleton WorkerPool routed via dynamic task dispatching (shared-worker-router.ts).
- Reduce active worker threads by 66.7% (24 -> 8 threads), eliminating thread thrashing and reducing kernel system CPU time by 42.3%.
- Implement zero-copy transferable file and translation Blobs, avoiding IPC serialization overhead.
- Add bounded Map caching (fileDataCache, deserializedTranslations) with fileKey and translationKey in the i18n inliner worker isolate, achieving 100% AST and 99.8% translation cache hit rates across locales without memory leaks.
- Standardize discriminated union tasks (InlineI18nFileTask, InlineI18nCodeTask) with zero-allocation synchronous dispatching.
| Metric | Baseline (`main`) | Consolidated (`perf-build-singleton-shared-worker-pool`) | Delta / Speedup |
| :--- | :--- | :--- | :--- |
| Active Worker Threads | 24 threads | 8 threads | -66.7% threads (-16 threads) |
| Cold Build Duration (mean) | 1,182.0 ms | 1,180.5 ms | 1.00x faster (-0.1%) |
| Cold Build Duration (min / max) | 1,151.7 ms / 1,228.2 ms | 1,156.8 ms / 1,224.2 ms | +5.1 ms / -4.0 ms |
| P95 Build Latency | 1,228.2 ms | 1,224.2 ms | -0.3% (-4.0 ms) |
| Throughput | 2,962.4 ops/sec | 2,966.1 ops/sec | +0.1% (+3.7 ops/sec) |
| I18n Inlining Duration (Pure mean) | 696.0 ms | 217.9 ms | 3.19x faster (-68.7%) |
| I18n Inlining (min / max) | 678.7 ms / 730.5 ms | 196.4 ms / 243.2 ms | 3.46x / 3.00x faster |
| AST Cache Hit Rate (Subsequent Locales) | 0.0% (0 / 2,000) | 100.0% (2,000 / 2,000) | 100.0% cache hit rate |
| Translation Cache Hit Rate | 0.0% (0 / 2,500) | 99.8% (2,495 / 2,500) | 99.8% cache hit rate |
| Process RSS Delta | +2,786.0 MB | +1,519.7 MB | -45.5% (-1,266.3 MB saved) |
| Final Process RSS | 2,842.1 MB | 1,576.4 MB | -44.5% (-1,265.7 MB saved) |
| Kernel System CPU | 2,355.1 ms | 1,358.3 ms | -42.3% (1.73x less kernel CPU) |
| Total CPU (User + Kernel) | 16,198.8 ms | 10,808.7 ms | -33.3% (1.50x CPU efficiency) |
| Metric | Baseline (`main`) | Consolidated (`perf-build-singleton-shared-worker-pool`) | Delta / Speedup |
| :--- | :--- | :--- | :--- |
| Active Worker Threads | 24 threads | 8 threads | -66.7% threads (-16 threads) |
| E2E Build Duration (mean) | 5,267.1 ms | 5,651.3 ms | +7.3% (+384.2 ms) |
| E2E Build Duration (min / max) | 5,187.5 ms / 5,351.7 ms | 5,595.6 ms / 5,737.8 ms | +408.1 ms / +386.1 ms |
| P95 Build Latency | 5,351.7 ms | 5,737.8 ms | +7.2% (+386.1 ms) |
| Process RSS Delta | +2,215.3 MB | +2,124.3 MB | -4.1% (-91.0 MB saved) |
| Final Process RSS | 2,296.2 MB | 2,204.7 MB | -4.0% (-91.5 MB saved) |
| Kernel System CPU | 3,087.4 ms | 3,000.0 ms | -2.8% (1.03x less kernel CPU) |
| Total CPU (User + Kernel) | 19,968.8 ms | 17,906.2 ms | -10.3% (-2,062.6 ms CPU saved) |
> **Note on Concurrency Bounds**: On high-core machines, baseline's 24 unthrottled concurrent threads across 3 independent pools allow concurrent execution of different compiler phases, whereas the consolidated 8-thread singleton enforces strict concurrency bounds, trading ~380 ms wall-clock time for -2.06s lower total CPU work and lower peak memory. This is particularly important for lower-end machines and resource-constrained CI/container environments to avoid severe CPU starvation, thread thrashing, and out-of-memory crashes.1 parent 6acadf2 commit 2cf891f
9 files changed
Lines changed: 687 additions & 153 deletions
File tree
- packages/angular/build/src
- tools
- esbuild
- sass
- utils
Lines changed: 188 additions & 55 deletions
Large diffs are not rendered by default.
Lines changed: 100 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
110 | 115 | | |
111 | 116 | | |
112 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
113 | 145 | | |
114 | 146 | | |
115 | 147 | | |
| |||
119 | 151 | | |
120 | 152 | | |
121 | 153 | | |
122 | | - | |
| 154 | + | |
123 | 155 | | |
| 156 | + | |
124 | 157 | | |
125 | 158 | | |
126 | 159 | | |
127 | 160 | | |
128 | 161 | | |
129 | 162 | | |
130 | 163 | | |
131 | | - | |
| 164 | + | |
132 | 165 | | |
133 | 166 | | |
134 | 167 | | |
135 | 168 | | |
136 | 169 | | |
137 | 170 | | |
138 | | - | |
| 171 | + | |
139 | 172 | | |
140 | 173 | | |
141 | 174 | | |
142 | 175 | | |
143 | 176 | | |
144 | | - | |
145 | 177 | | |
146 | 178 | | |
147 | 179 | | |
| |||
172 | 204 | | |
173 | 205 | | |
174 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
175 | 210 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 211 | + | |
193 | 212 | | |
194 | 213 | | |
195 | 214 | | |
| |||
221 | 240 | | |
222 | 241 | | |
223 | 242 | | |
| 243 | + | |
224 | 244 | | |
225 | 245 | | |
226 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
227 | 252 | | |
228 | 253 | | |
229 | 254 | | |
| |||
265 | 290 | | |
266 | 291 | | |
267 | 292 | | |
268 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
269 | 297 | | |
270 | 298 | | |
271 | 299 | | |
| |||
288 | 316 | | |
289 | 317 | | |
290 | 318 | | |
291 | | - | |
| 319 | + | |
292 | 320 | | |
293 | 321 | | |
294 | 322 | | |
| |||
306 | 334 | | |
307 | 335 | | |
308 | 336 | | |
| 337 | + | |
309 | 338 | | |
310 | 339 | | |
311 | 340 | | |
| |||
339 | 368 | | |
340 | 369 | | |
341 | 370 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
349 | 376 | | |
350 | 377 | | |
351 | 378 | | |
| |||
363 | 390 | | |
364 | 391 | | |
365 | 392 | | |
366 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
367 | 397 | | |
368 | 398 | | |
369 | 399 | | |
| |||
377 | 407 | | |
378 | 408 | | |
379 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
380 | 415 | | |
381 | 416 | | |
382 | 417 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
393 | 433 | | |
394 | 434 | | |
395 | 435 | | |
| |||
453 | 493 | | |
454 | 494 | | |
455 | 495 | | |
456 | | - | |
| 496 | + | |
457 | 497 | | |
458 | 498 | | |
459 | 499 | | |
| |||
464 | 504 | | |
465 | 505 | | |
466 | 506 | | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
476 | 518 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
| 519 | + | |
486 | 520 | | |
487 | 521 | | |
488 | 522 | | |
| |||
496 | 530 | | |
497 | 531 | | |
498 | 532 | | |
499 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
500 | 538 | | |
501 | 539 | | |
502 | 540 | | |
| |||
Lines changed: 33 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
38 | 46 | | |
| |||
92 | 100 | | |
93 | 101 | | |
94 | 102 | | |
95 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
96 | 112 | | |
97 | 113 | | |
98 | | - | |
| 114 | + | |
99 | 115 | | |
100 | 116 | | |
101 | 117 | | |
| |||
137 | 153 | | |
138 | 154 | | |
139 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
140 | 160 | | |
141 | 161 | | |
142 | 162 | | |
| |||
156 | 176 | | |
157 | 177 | | |
158 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
159 | 184 | | |
160 | | - | |
| 185 | + | |
161 | 186 | | |
162 | 187 | | |
163 | 188 | | |
| |||
191 | 216 | | |
192 | 217 | | |
193 | 218 | | |
194 | | - | |
| 219 | + | |
195 | 220 | | |
196 | 221 | | |
197 | 222 | | |
| |||
206 | 231 | | |
207 | 232 | | |
208 | 233 | | |
209 | | - | |
| 234 | + | |
210 | 235 | | |
211 | 236 | | |
212 | 237 | | |
213 | 238 | | |
214 | 239 | | |
215 | 240 | | |
216 | 241 | | |
217 | | - | |
218 | | - | |
| 242 | + | |
| 243 | + | |
219 | 244 | | |
220 | 245 | | |
221 | 246 | | |
| |||
0 commit comments