Skip to content

perf(@angular/build): avoid web worker channel overhead in library parallel compilation - #34422

Open
alan-agius4 wants to merge 2 commits into
angular:mainfrom
alan-agius4:perf/parallel-compilation-library-channel
Open

alan-agius4 wants to merge 2 commits into
angular:mainfrom
alan-agius4:perf/parallel-compilation-library-channel

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Skip creating and transferring webWorkerChannel (MessageChannel) and webWorkerSignal (SharedArrayBuffer) in ParallelCompilation.initialize() when buildType === 'library', as library builds do not bundle web workers via processWebWorker and previously left ports open until the next build if emitAffectedFiles() was skipped due to stylesheet errors. Also replace crypto.randomUUID() per component stylesheet request in parallel-worker.ts with an incrementing numeric request counter.

Benchmark

Metric main Branch Delta
Runs (ms) 12295, 12605, 12723 11892, 12407, 12127
Mean (ms) 12541 ms 12142 ms -3.18%
Min (ms) 12295 ms 11892 ms -3.28%

…rallel compilation

Skip creating and transferring `webWorkerChannel` (`MessageChannel`) and `webWorkerSignal` (`SharedArrayBuffer`) in `ParallelCompilation.initialize()` when `buildType === 'library'`, as library builds do not bundle web workers via `processWebWorker` and previously left ports open until the next build if `emitAffectedFiles()` was skipped due to stylesheet errors. Also replace `crypto.randomUUID()` per component stylesheet request in `parallel-worker.ts` with an incrementing numeric request counter.
@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Oct 20, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 20, 2026 09:20
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Oct 20, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review October 20, 2026 09:21

@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 optimizes parallel compilation by making the web worker channel optional, which avoids setting it up for library builds. It also replaces UUID generation with an incrementing numeric ID for stylesheet transformation requests to improve performance, and adds a new test suite to verify these changes. There are no review comments, so I have no feedback to provide.

@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 20, 2026
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 area: performance Issues related to performance target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant