Skip to content

refactor(@angular/build): add fast path for untranslated messages in i18n inliner worker - #34214

Merged
clydin merged 2 commits into
angular:mainfrom
clydin:perf-inliner-untranslated-fastpath
Sep 30, 2026
Merged

clydin merged 2 commits into
angular:mainfrom
clydin:perf-inliner-untranslated-fastpath

Conversation

@clydin

@clydin clydin commented Sep 30, 2026

Copy link
Copy Markdown
Member

When inlining a locale without translations (such as the source locale or when a translation dictionary is undefined), calls to translateMessage() previously invoked ɵtranslate() with an empty dictionary. This caused @angular/localize to throw a MissingTranslationError for every single $localize message site in the application, catching it to retrieve the original message parts from the parsed message.

Throwing and catching thousands of Error instances incurs significant V8 stack trace capturing and exception handling overhead.

translateMessage() now provides an early fast path when translations is undefined: it directly calls ɵparseMessage(messageParts, substitutions) to parse and strip metadata/placeholder markers without throwing or catching exceptions.

…i18n inliner worker

When inlining a locale without translations (such as the source locale or
when a translation dictionary is undefined), calls to translateMessage()
previously invoked ɵtranslate() with an empty dictionary. This caused
@angular/localize to throw a MissingTranslationError for every single
$localize message site in the application, catching it to retrieve the
original message parts from the parsed message.

Throwing and catching thousands of Error instances incurs significant V8
stack trace capturing and exception handling overhead.

translateMessage() now provides an early fast path when translations
is undefined: it directly calls ɵparseMessage(messageParts, substitutions)
to parse and strip metadata/placeholder markers without throwing or catching
exceptions.

@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 fast path for untranslated locales in the i18n inliner, allowing messages to be processed without triggering translation logic when no translation dictionary is provided. This is achieved by using ɵparseMessage to strip metadata and placeholders directly. I have included the reviewer's suggestion to further optimize this path by bypassing parsing for simple messages that do not contain metadata markers.

Comment thread packages/angular/build/src/tools/i18n/i18n-inliner-worker.ts
@clydin clydin added the target: patch This PR is targeted for the next patch release label Sep 30, 2026
Adds a new benchmark scenario modeling a very large application workload:
- 800 chunks total (~150 MB JS): 1 main bundle (6 MB) + 250 small chunks (40 KB)
  + 549 feature chunks (245 KB).
- 8 locales, 5,000 translations, sourcemaps ON.

This exercises worker thread pool queue capacity, task dispatch throughput,
IPC messaging, and memory reclamation across hundreds of files in parallel.
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 30, 2026
@clydin
clydin requested a review from alan-agius4 September 30, 2026 18:26
@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 30, 2026
@clydin
clydin merged commit 8c273b0 into angular:main Sep 30, 2026
41 checks passed
@clydin

clydin commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

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

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: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants