Skip to content

perf(@angular/build): overlap library asset resolution with bundling and disk emission - #34424

Draft
alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:perf/library-build-action-io
Draft

alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:perf/library-build-action-io

Conversation

@alan-agius4

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

Copy link
Copy Markdown
Collaborator

Summary

  • Run collectedAssets ?? buildState.collectAssets(options, modifiedFiles) inside Promise.all alongside bundleEntryPoints and diagnosePromise, overlapping lstat and tinyglobby asset resolution with Rolldown's native Rust bundling threads (bundleAllEsm / bundleAllDts) and worker-thread diagnostics (diagnosePromise) while the main Node.js event loop and libuv threadpool are idle.
    • Starting collectAssets before compileLibrary previously contended with ParallelCompilation's 100+ stylesheetChannel IPC round-trips and esbuild/SassWorkerPool dispatches on the main thread and libuv threadpool.
  • Delete stale files with deleteFilesFromDisk before emitting new files with emitFilesToDisk so case-only renames or overlapping paths on case-insensitive filesystems never delete newly emitted files.
  • Check if (result.hasErrors) { return result; } before result.addWarnings(bundleOutput.warnings) to suppress secondary bundler warnings when TypeScript compilation has errors.
  • Include options.packageJsonPath in the disallowed dependency error message in verifyAllowedDependencies.

Benchmark

Metric main Branch Delta
Runs (ms) 11907, 11731, 12087, 12022, 11672 12064, 11605, 11921, 11540, 11679
Median (ms) 11907 ms 11679 ms -1.91%
Mean (ms) 11884 ms 11762 ms -1.03%
Min (ms) 11672 ms 11540 ms -1.13%

…e output mkdir calls

- Start `buildState.collectAssets(options, modifiedFiles)` before `compileLibrary` so asset globbing overlaps with TypeScript/Angular compilation, Rolldown bundling, and manifest generation.
- Execute `deleteFilesFromDisk` and `emitFilesToDisk` concurrently via `Promise.all` since deleted and emitted paths are disjoint.
- Cache ancestor directory promises created by `mkdir(..., { recursive: true })` in `emitFilesToDisk` so parent directories (such as `outputPath`) do not incur redundant `mkdir` syscalls when subdirectories (`fesm2022`, `types`) are created first.
- Return early when `result.hasErrors` is true before adding `bundleOutput.warnings` so secondary bundler warnings are not logged alongside compilation errors.
- Include `options.packageJsonPath` in the error message when `verifyAllowedDependencies` fails.
@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Oct 20, 2026
@alan-agius4 alan-agius4 added the target: minor This PR is targeted for the next minor release label Oct 20, 2026
@alan-agius4 alan-agius4 changed the title perf(@angular/build): overlap library asset resolution and deduplicate output mkdir calls perf(@angular/build): overlap library asset resolution with bundling and parallelize output I/O Oct 20, 2026
@alan-agius4 alan-agius4 changed the title perf(@angular/build): overlap library asset resolution with bundling and parallelize output I/O perf(@angular/build): overlap library asset resolution with bundling and disk emission Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build area: performance Issues related to performance 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