Commit a7ec3ee
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 36.5%.
- Pre-warm worker pool threads (minThreads: maxTransformWorkers, maxThreads: maxInlinerWorkers) with Piscina FixedQueue and 30s idle timeout, while lazily loading the i18n inliner worker handler on demand.
- 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 1.51x faster i18n inlining and 46.9% lower memory RSS delta.
- Monotonic sequence IDs for futex synchronizations, structured IPC error propagation, post-close lifecycle guards, sourcemap passthrough on untransformed files, and full SharedArrayBuffer cache key hashing.
| 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) | 1,543.6 ms | 1,063.9 ms | 1.45x faster (-31.1%) |
| Cold Build Duration (min / max) | 1,322.2 ms / 1,700.6 ms | 880.2 ms / 1,488.3 ms | -442.0 ms / -212.3 ms |
| P95 Build Latency | 1,700.6 ms | 1,488.3 ms | -12.5% (-212.3 ms faster) |
| Throughput | 2,287.4 ops/sec | 3,402.9 ops/sec | +48.8% (+1,115.5 ops/sec) |
| I18n Inlining Duration (Pure mean) | 1,135.2 ms | 751.7 ms | 1.51x faster (-33.8%) |
| Process RSS Delta | +2,020.4 MB | +1,073.7 MB | -46.9% (-946.7 MB saved) |
| Final Process RSS | 2,084.5 MB | 1,138.4 MB | -45.4% (-946.1 MB saved) |
| Kernel System CPU | 2,811.5 ms | 1,785.4 ms | -36.5% (1.57x less kernel CPU) |
| Total CPU (User + Kernel) | 12,634.5 ms | 7,824.4 ms | -38.1% (-4,810.1 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) |
| E2E Build Duration (mean) | 6,728.9 ms | 6,273.4 ms | -6.8% (-455.5 ms faster) |
| E2E Build Duration (min / max) | 6,492.6 ms / 7,016.1 ms | 6,100.9 ms / 6,541.7 ms | -391.7 ms / -474.4 ms |
| P95 Build Latency | 7,016.1 ms | 6,541.7 ms | -6.8% (-474.4 ms faster) |
| Process RSS Delta | +1,492.7 MB | +1,705.7 MB | +14.3% (+213.0 MB) |
| Kernel System CPU | 4,515.1 ms | 4,403.0 ms | -2.5% (-112.1 ms less kernel CPU) |
| Total CPU (User + Kernel) | 21,485.0 ms | 18,821.6 ms | -12.4% (-2,663.4 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,496.7 ms | 2,473.7 ms | -0.9% (-23.0 ms faster) |
| Cold Build Duration (min / max) | 2,227.3 ms / 2,869.8 ms | 2,278.7 ms / 2,748.2 ms | +51.4 ms / -121.6 ms |
| P95 Build Latency | 2,869.8 ms | 2,748.2 ms | -4.2% (-121.6 ms faster) |
| Process RSS Delta | +1,170.0 MB | +1,318.8 MB | +12.7% (pool pre-warming) |
| Kernel System CPU | 2,294.7 ms | 2,402.0 ms | +4.7% (+107.3 ms) |
| Total CPU (User + Kernel) | 9,805.8 ms | 9,908.2 ms | +1.0% (+102.4 ms) |1 parent feb41cc commit a7ec3ee
12 files changed
Lines changed: 781 additions & 174 deletions
File tree
- packages/angular/build/src
- tools
- i18n
- javascript-transformer
- utils
Lines changed: 156 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | | - | |
| 79 | + | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
104 | 135 | | |
105 | 136 | | |
106 | 137 | | |
| |||
110 | 141 | | |
111 | 142 | | |
112 | 143 | | |
113 | | - | |
| 144 | + | |
114 | 145 | | |
115 | 146 | | |
116 | 147 | | |
| |||
128 | 159 | | |
129 | 160 | | |
130 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
131 | 173 | | |
132 | 174 | | |
133 | 175 | | |
| |||
137 | 179 | | |
138 | 180 | | |
139 | 181 | | |
140 | | - | |
| 182 | + | |
141 | 183 | | |
142 | 184 | | |
143 | 185 | | |
144 | 186 | | |
145 | | - | |
| 187 | + | |
146 | 188 | | |
147 | 189 | | |
148 | 190 | | |
| |||
152 | 194 | | |
153 | 195 | | |
154 | 196 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
159 | 201 | | |
160 | | - | |
| 202 | + | |
161 | 203 | | |
| 204 | + | |
162 | 205 | | |
163 | | - | |
| 206 | + | |
164 | 207 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
174 | 219 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
178 | 230 | | |
179 | | - | |
180 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
181 | 238 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
187 | 246 | | |
188 | 247 | | |
189 | | - | |
| 248 | + | |
190 | 249 | | |
191 | 250 | | |
192 | 251 | | |
193 | 252 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
198 | 257 | | |
199 | 258 | | |
200 | 259 | | |
201 | 260 | | |
| 261 | + | |
202 | 262 | | |
203 | 263 | | |
204 | 264 | | |
205 | 265 | | |
206 | 266 | | |
207 | | - | |
| 267 | + | |
| 268 | + | |
208 | 269 | | |
209 | 270 | | |
210 | 271 | | |
211 | 272 | | |
212 | 273 | | |
213 | 274 | | |
214 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
215 | 278 | | |
216 | 279 | | |
217 | 280 | | |
218 | 281 | | |
219 | 282 | | |
220 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
221 | 297 | | |
222 | 298 | | |
223 | 299 | | |
| |||
240 | 316 | | |
241 | 317 | | |
242 | 318 | | |
243 | | - | |
244 | | - | |
245 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
246 | 323 | | |
247 | 324 | | |
248 | 325 | | |
249 | 326 | | |
250 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
251 | 338 | | |
252 | 339 | | |
253 | 340 | | |
| |||
263 | 350 | | |
264 | 351 | | |
265 | 352 | | |
| 353 | + | |
266 | 354 | | |
267 | | - | |
268 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
269 | 358 | | |
270 | 359 | | |
271 | 360 | | |
272 | 361 | | |
273 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
274 | 372 | | |
275 | 373 | | |
276 | 374 | | |
277 | 375 | | |
278 | 376 | | |
279 | | - | |
| 377 | + | |
280 | 378 | | |
281 | 379 | | |
282 | 380 | | |
| |||
300 | 398 | | |
301 | 399 | | |
302 | 400 | | |
303 | | - | |
| 401 | + | |
304 | 402 | | |
305 | 403 | | |
306 | 404 | | |
| |||
310 | 408 | | |
311 | 409 | | |
312 | 410 | | |
313 | | - | |
| 411 | + | |
314 | 412 | | |
315 | 413 | | |
316 | 414 | | |
| |||
532 | 630 | | |
533 | 631 | | |
534 | 632 | | |
535 | | - | |
| 633 | + | |
536 | 634 | | |
537 | 635 | | |
538 | 636 | | |
| |||
542 | 640 | | |
543 | 641 | | |
544 | 642 | | |
545 | | - | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
546 | 646 | | |
547 | 647 | | |
548 | 648 | | |
549 | 649 | | |
550 | | - | |
| 650 | + | |
551 | 651 | | |
552 | 652 | | |
553 | 653 | | |
0 commit comments