Commit 9d7138e
committed
perf(@angular/build): read rendered module length once per module in chunk optimizer
When converting the chunk optimizer output into an esbuild-compatible metafile, the
rendered length of each module was read inside the loop over the module's original
inputs. The `renderedLength` property of a rolldown rendered module is a lazy getter
that transfers the full module code from native memory on every access. Since each
module in this pass is an entire esbuild output chunk, a main chunk of 17 MB with
3,588 inputs resulted in roughly 62 GB of string copies and around 150 seconds spent in
`bundleOutputToEsbuildMetafile`, while the rolldown bundling itself took 3 seconds.
Read the rendered length once per module before iterating its inputs. The generated
metafile is unchanged. On the affected application the `OPTIMIZE_CHUNKS` phase drops
from 179 seconds to 4 seconds and the total production build from 234 to 55 seconds.
Fixes #340441 parent 6b20983 commit 9d7138e
1 file changed
Lines changed: 6 additions & 1 deletion
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
119 | 124 | | |
120 | | - | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| |||
0 commit comments