Skip to content

refactor(@angular/build): cap default i18n inlining concurrency to 8 - #34107

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:perf/cap-i18n-inliner-concurrency
Sep 17, 2026
Merged

clydin merged 1 commit into
angular:mainfrom
clydin:perf/cap-i18n-inliner-concurrency

Conversation

@clydin

@clydin clydin commented Sep 17, 2026

Copy link
Copy Markdown
Member

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.

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.
@clydin clydin added the target: rc This PR is targeted for the next release-candidate label Sep 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 17, 2026
@clydin
clydin requested a review from alan-agius4 September 17, 2026 14:25
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 17, 2026
@clydin
clydin merged commit 93c118e into angular:main Sep 17, 2026
70 of 71 checks passed
@clydin

clydin commented Sep 17, 2026

Copy link
Copy Markdown
Member Author

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the perf/cap-i18n-inliner-concurrency branch September 17, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants