refactor(@angular/build): cap default i18n inlining concurrency to 8 - #34107
Merged
Merged
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.
alan-agius4
approved these changes
Sep 17, 2026
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.