Repository navigation
perf(@angular/build): implement SharedArrayBuffer translation dictionaries for zero-copy worker access - #33919
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a zero-copy translation sharing mechanism using SharedArrayBuffer to optimize i18n inlining. It adds an encoder to serialize translation dictionaries into a contiguous buffer and a reader that queries translations using binary search, wrapped in a Proxy. Feedback on the changes includes addressing a potential ReferenceError when checking instanceof SharedArrayBuffer in environments where it is undefined, and fixing the Proxy implementation to fall back to standard prototype methods (like toString and valueOf) to prevent runtime crashes.
…aries for zero-copy worker access Translation catalogs are encoded into a contiguous SharedArrayBuffer containing a binary header, sorted index table with lexicographical string keys, and UTF-8 string pool via encodeTranslationToBuffer. Lookups perform zero-copy binary search over shared memory pages with on-demand string decoding through a Proxy wrapper compatible with @angular/localize. I18nInliner and worker tasks prefer SharedArrayBuffer over V8 serialized Blobs for windowed locale translation passing, eliminating Structured Clone heap duplication across worker threads. Serialized Blobs are retained as a fallback for environments such as WebContainers that do not support SharedArrayBuffer.
daada8c to
2413b6a
Compare
|
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. |
Translation catalogs are encoded into a contiguous SharedArrayBuffer containing a binary header, sorted index table with lexicographical string keys, and UTF-8 string pool via encodeTranslationToBuffer. Lookups perform zero-copy binary search over shared memory pages with on-demand string decoding through a Proxy wrapper compatible with @angular/localize.
I18nInliner and worker tasks prefer SharedArrayBuffer over V8 serialized Blobs for windowed locale translation passing, eliminating Structured Clone heap duplication across worker threads. Serialized Blobs are retained as a fallback for environments such as WebContainers that do not support SharedArrayBuffer.