Skip to content

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

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
alan-agius4:perf/parallel-compilation-library-channel
Oct 22, 2026
Merged

alan-agius4 merged 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%

@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
…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.
@alan-agius4
alan-agius4 force-pushed the perf/parallel-compilation-library-channel branch from 39bb07e to 0780e9b Compare October 22, 2026 09:48
@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 Oct 22, 2026
@alan-agius4
alan-agius4 merged commit 7f4de14 into angular:main Oct 22, 2026
39 of 40 checks passed
@alan-agius4
alan-agius4 deleted the perf/parallel-compilation-library-channel branch October 22, 2026 15:01
@alan-agius4

Copy link
Copy Markdown
Collaborator 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 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.

2 participants