Repository navigation
refactor(@angular/build): cap default i18n inlining concurrency to 8 - #34107
Conversation
Translation inlining and sourcemap remapping are CPU- and memory-intensive operations. When Piscina is initialized without explicit maxThreads, it defaults to floor(cpus * 1.5), spawning 18 to 48 worker threads on high-core machines. This excessive concurrency causes severe thread oversubscription, memory allocator lock contention, and high-core performance degradation under Promise.all barriers. This change introduces maxInlinerWorkers in environment options defaulting to min(8, availableParallelism()) while preserving explicit overrides via NG_BUILD_MAX_WORKERS. Concurrency passed to I18nInliner in the application builder is bounded to maxInlinerWorkers, capping standalone workers and shared worker pools while honoring shared pool thread limits when lower.
There was a problem hiding this comment.
Code Review
This pull request introduces a new maxInlinerWorkers configuration to limit the maximum number of worker threads used for i18n translation inlining to a default cap of 8 (or the available parallelism, whichever is lower), unless overridden by the NG_BUILD_MAX_WORKERS environment variable. This change helps prevent thread oversubscription and memory allocator lock contention during CPU- and memory-intensive inlining operations. Additionally, comprehensive unit tests have been added to verify the behavior of maxInlinerWorkers under various environment configurations. There are no review comments, so I have no feedback to provide.
|
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. |
Translation inlining and sourcemap remapping are CPU- and memory-intensive operations. When Piscina is initialized without explicit
maxThreads, it defaults to floor(cpus * 1.5), spawning 18 to 48 worker threads on high-core machines. This excessive concurrency causes severe thread oversubscription, memory allocator lock contention, and high-core performance degradation underPromise.allbarriers.This change introduces
maxInlinerWorkersin environment options defaulting tomin(8, availableParallelism())while preserving explicit overrides viaNG_BUILD_MAX_WORKERS. Concurrency passed toI18nInlinerin the application builder is bounded tomaxInlinerWorkers, capping standalone workers and shared worker pools while honoring shared pool thread limits when lower.