Repository navigation
perf(@angular/build): implement sliding-window batching and worker translation eviction - #33913
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.
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.
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 PR was merged into the repository. The changes were merged into the following branches:
|
|
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. |
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.