perf(@angular/build): implement sliding-window batching and worker translation eviction - #33913
Open
clydin wants to merge 3 commits into
Open
perf(@angular/build): implement sliding-window batching and worker translation eviction#33913clydin wants to merge 3 commits into
clydin wants to merge 3 commits into
Conversation
…-batch inlining When processing files where all remaining locales fit into a single batch, the file will only be transformed once across all worker threads. Retaining the parsed AST and source code in the worker's long-term `fileDataCache` leads to monotonic memory growth across multi-file builds without providing any cache reuse. This change marks single-batch requests as `ephemeral`, allowing the worker to extract localization metadata and perform inlining within the execution frame without caching the file data long-term. The parsed AST and code are then naturally garbage-collected when the batch action completes.
clydin
marked this pull request as ready for review
August 24, 2026 21:15
There was a problem hiding this comment.
Code Review
This pull request introduces a sliding window mechanism to process locales in batches, capping peak worker memory, and adds an ephemeral flag to avoid caching file data long-term in the worker. The reviewer identified a significant CPU performance regression caused by the ephemeral flag when the number of locales exceeds the window size, as it forces the worker to repeatedly re-load and re-parse the same files. The reviewer recommends removing the ephemeral flag entirely and always caching the file data in the worker.
…anslation eviction In enterprise Angular applications with a high number of locales (e.g. 20–50+), deserializing translation dictionaries into native JavaScript objects across all worker threads simultaneously can lead to multi-gigabyte resident memory footprints in V8 worker heaps. This change introduces sliding-window locale batching and lock-free translation eviction: - `I18nInliner.inlineAll` processes locales in sliding windows of up to 8 locales each (`DEFAULT_LOCALE_WINDOW_SIZE`), capping peak memory while retaining maximum multi-locale batching throughput. - Worker tasks receive an `activeLocales` array on each batch request. Workers automatically purge any cached translation dictionaries in `deserializedTranslations` that are not part of the active window when transitioning across window boundaries.
clydin
force-pushed
the
perf/i18n-inliner-sliding-window-eviction
branch
from
August 24, 2026 21:42
379a108 to
625ee76
Compare
…liner
Updates I18nInliner to instantiate and use a namespaced Cache<TransformedFileResult> instance (cacheStore.createCache('transforms')) instead of directly invoking lower-level CacheStore methods (get/set).
Using the Cache abstraction ensures standard namespace partitioning within the angular-i18n persistent cache store, automatic in-flight promise management, and proper get/put promise semantics.
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.
In enterprise Angular applications with a high number of locales (e.g. 20–50+), deserializing translation dictionaries into native JavaScript objects across all worker threads simultaneously can lead to multi-gigabyte resident memory footprints in V8 worker heaps.
This change introduces sliding-window locale batching and lock-free translation eviction:
I18nInliner.inlineAllprocesses locales in sliding windows of up to 8 locales each (DEFAULT_LOCALE_WINDOW_SIZE), capping peak memory while retaining maximum multi-locale batching throughput.activeLocalesarray on each batch request. Workers automatically purge any cached translation dictionaries indeserializedTranslationsthat are not part of the active window when transitioning across window boundaries.