FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

perf(@angular/build): optimize allocations and worker memory lifecycle in i18n inliner by clydin · Pull Request #33964 · angular/angular-cli · GitHub

perf(@angular/build): optimize allocations and worker memory lifecycle in i18n inliner - #33964

Open
clydin wants to merge 6 commits into
angular:mainfrom
clydin:perf/i18n-inliner-micro-optimizations
Open

perf(@angular/build): optimize allocations and worker memory lifecycle in i18n inliner#33964
clydin wants to merge 6 commits into
angular:mainfrom
clydin:perf/i18n-inliner-micro-optimizations

Conversation

clydin commented Aug 28, 2026

Copy link
Copy Markdown
Member

This PR introduces a series of focused optimizations to reduce heap allocations, streamline cache pipeline resolution, and ensure clean worker memory lifecycle in the I18nInliner.

clydin added 5 commits August 28, 2026 12:18
…er worker

Previously, callSite.expressions.map((_, index) => index) was evaluated
on every $localize call site for every locale inside inlineLocalize.
In bundles with hundreds of call sites processed across multiple locales in
a batch, this resulted in thousands of redundant small array allocations.

expressionIndexes is now precomputed once during AST extraction in
extractLocalizeMetadata and stored on LocalizeCallSite, eliminating
per-locale index array allocations in the worker transformation loop.
…tch loop

Instantiate codeBlob and mapBlob once per file outside the batch loop
instead of re-creating new Blob instances on each batch slice. Blobs are
immutable, read-only binary handles and can be safely shared across
multiple worker batch tasks concurrently.
…nliner

Streamline the asynchronous cache resolution in inlineAll by removing
the intermediate CacheCheckItem interface and array mapping allocations.
Results are now assigned directly to fileResultsByLocale on hit or pushed
to uncachedByFile on miss. When no persistent cache is configured, a fast
path directly queues uncached files without promise or hash overhead.
…ing in i18n inliner

Introduce generation tracking in I18nInliner and worker batch tasks to
guarantee long-term worker caches (fileDataCache and deserializedTranslations)
are wiped whenever a new inlining pass or rebuild begins (e.g. watch mode
or shared worker pools).
…n i18n inliner worker

Consolidate the 3 chained string replacement passes (unescaping double quotes,
escaping backticks, and escaping ${ delimiters) into a single regex pass in
escapeTemplatePart. This eliminates 3 intermediate string allocations and
reduces 3 regex scans to 1 on every translated template literal part.
clydin added the target: minor This PR is targeted for the next minor release label Aug 28, 2026
clydin marked this pull request as ready for review August 28, 2026 18:03

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request introduces a generation counter to clear long-term worker caches across multiple runs of the i18n inliner, ensuring correctness in watch mode. It also refactors template literal escaping into a single-pass helper function and optimizes cache-checking logic. Feedback on the changes highlights that the new asynchronous cache-checking logic introduces non-determinism in the order of uncached file entries due to varying cache lookup resolution times. A deterministic approach using per-file Promise.all is suggested to ensure build reproducibility and ease debugging.

…he checks

Resolve asynchronous cache checks on a per-file basis using Promise.all
to ensure windowLocales ordering is preserved within uncachedByFile
regardless of disk I/O resolution timing. Also avoids pre-populating
and deleting empty arrays in uncachedByFile.
clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 28, 2026
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

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL