Skip to content

Commit a39f001

Browse files
authored
fixup! test(@angular/build): add library builder scaling benchmark suite
Recorded reuslts for the Iteration 1 baseline sweep against the native libray builder, indicating that the new native library builder scales gracefully - far far better than ng-packagr. No U-shape curve detected.
1 parent c822f4f commit a39f001

1 file changed

Lines changed: 55 additions & 5 deletions

File tree

‎scripts/benchmarks/library-builder/README.md‎

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Library Builds Scaling Benchmark
22

3-
This benchmark measures build time metrics for Angular libraries.
3+
This benchmark suites measures build time metrics for Angular libraries.
44

55
## Context
66

@@ -14,22 +14,25 @@ This benchmark suite is designed to quantify performance impacts and ensure scal
1414

1515
### Previous Benchmarks
1616

17-
For context, when running a similar benchmark suite directly against `ng-packagr`, it hinted at a "U-curve" in build times,
17+
For context, when running a comparable benchmark suite directly against `ng-packagr`, it hinted at a "U-curve" in build times,
1818
where build time per entry point in `ng-packagr` drops until entry point N (with N varying in the range 200..500).
1919
This shape indicates an initial overhead as a possible explanation for a small number of entry points.
2020
However, we discovered that `ng-packagr` build time per entry point increases
2121
as the number of entry points scale past a certain N (in the test runs N=200+).
2222

2323
[Landing Angular CLI's native `@angular/build:library` builder](https://github.com/angular/angular-cli/pull/34106#issuecomment-5744311681),
24-
indicated very favourable performance metrics for the new library builder that can be explained by number of
25-
architectural changes in the library build pipeline:
24+
indicated very favourable performance metrics for the new library builder that can be explained by a number of
25+
architectural changes in the design of the library build pipeline:
2626

2727
- Shared Stylesheet Bundling
2828
- Public API Invalidation via Declaration Hashing
2929
- Dedicated Worker Pool for Production Builds
3030
- Single Pass Output Emission
3131
- Direct Async Pipeline
3232

33+
The benchmark design of this suite is built to not only verify the previous results,
34+
but also to confirm or contradict the architectural choices in the library builder pipeline.
35+
3336
### Goals
3437

3538
This benchmark suite runs explorative research on the performance of library builds in Angular CLI.
@@ -108,7 +111,54 @@ pnpm admin benchmark library-builder --layout=flat --count=500
108111

109112
## Benchmark Results
110113

111-
_(To be filled in once a sweep has been run and reviewed. Out of scope for this iteration.)_
114+
Each entry below is one benchmark run, with its own summary and conclusions.
115+
116+
### 2026-10-12: Iteration 1 baseline sweep (native library builder, flat & deep)
117+
118+
First full run of the default sweep against `@angular/build:library` only — no `ng-packagr` A/B comparison yet (still Future Work).
119+
Fixtures use inline HTML templates only, no stylesheets.
120+
Default `--count` sweep, `--iterations=3`, both layouts.
121+
Environment: 4-core / 16 GiB sandbox, NVMe SSD.
122+
Raw log: `tmp/benchmark-run-1791795379.log` (gitignored; not included in this commit).
123+
124+
#### Flat layout (inline templates only)
125+
126+
| Entries | Median | ms/entry |
127+
| ------: | -----: | -------: |
128+
| 10 | 3.25s | 324.63 |
129+
| 20 | 3.28s | 164.14 |
130+
| 50 | 3.33s | 66.61 |
131+
| 100 | 3.75s | 37.53 |
132+
| 200 | 4.31s | 21.56 |
133+
| 300 | 4.90s | 16.35 |
134+
| 400 | 5.51s | 13.78 |
135+
| 500 | 6.18s | 12.36 |
136+
| 1000 | 10.29s | 10.29 |
137+
| 2000 | 19.47s | 9.74 |
138+
139+
#### Deep layout (inline templates only)
140+
141+
| Entries | Median | ms/entry |
142+
| ------: | -----: | -------: |
143+
| 16 | 3.27s | 204.47 |
144+
| 32 | 3.30s | 103.16 |
145+
| 64 | 3.57s | 55.74 |
146+
| 128 | 4.20s | 32.84 |
147+
| 256 | 4.70s | 18.36 |
148+
| 512 | 6.31s | 12.32 |
149+
| 1024 | 10.25s | 10.01 |
150+
| 2048 | 21.67s | 10.58 |
151+
152+
**Conclusion:** per-entry build time decreases monotonically across both layouts and flattens out
153+
around 9.6-10.6ms/entry at the largest sizes tested -- no U-shaped climb-back-up at any tested
154+
size (up to 2000/2048 entries), unlike the pattern reported for `ng-packagr` past N≈200-500. Flat
155+
and deep track each other closely at comparable entry-point scale, suggesting the directory
156+
layout itself isn't a meaningful cost driver for the native builder, just raw entry-point count.
157+
`deep`'s depth-11 run (2048 entries) showed slightly higher run-to-run variance (20.78s-22.46s)
158+
than `flat`'s 2000-entry run (19.46s-19.63s) -- possibly directory-tree-walk overhead at depth,
159+
but not a regression, and not yet investigated further.
160+
161+
All 60 builds (10 sizes x 3 iterations x 2 layouts) completed with `status: "ok"`; zero failures.
112162

113163
## Future Work
114164

0 commit comments

Comments
 (0)