Title: perf(@angular/build): read rendered module length once per module in chunk optimizer by roman-garcia · Pull Request #34045 · angular/angular-cli · GitHub
Open Graph Title: perf(@angular/build): read rendered module length once per module in chunk optimizer by roman-garcia · Pull Request #34045 · angular/angular-cli
X Title: perf(@angular/build): read rendered module length once per module in chunk optimizer by roman-garcia · Pull Request #34045 · angular/angular-cli
Description: PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-commit-message-guidelines Tests for the changes have been added (for bug fixes / features) Docs have been added / updated (for bug fixes / features) No test added: the change is a pure performance fix with no behavioral difference. The generated metafile is byte-identical before and after (verified by replaying optimizeChunks on a dumped esbuild result and comparing the serialized metafile and initialFiles). Happy to add a spec if you can point me at a suitable harness for chunk-optimizer. PR Type What kind of change does this PR introduce? Bugfix Feature Code style update (formatting, local variables) Refactoring (no functional changes, no api changes) Build related changes CI related changes Documentation content changes Other... Please describe: performance What is the current behavior? Issue Number: #34044 In bundleOutputToEsbuildMetafile, renderedModule.renderedLength is read inside the loop over each module's original inputs. On rolldown's rendered module object that property is a lazy getter (bindingRenderedModule.code?.length) which transfers the entire module code from native memory on every access. Because each "module" in the chunk optimizer is a whole esbuild output chunk, a 17 MB main chunk with 3,588 inputs performs 3,588 copies of a 17 MB string (~62 GB). On the application in the linked issue this is ~157 s out of a ~161 s OPTIMIZE_CHUNKS phase, while the rolldown bundling itself takes ~3 s. Rolldown also emits a misleading [PLUGIN_TIMINGS] warning about the angular-bundle plugin as a side effect. What is the new behavior? The rendered length is read once per module before iterating its inputs. Measured on the same application and machine (production configuration, sourceMap: true): Before After DURATION[OPTIMIZE_CHUNKS] 179 s 4 s Total ng build 234 s 55 s Output files are byte-identical (same file list, same SHA-256 for every JS and CSS file). Does this PR introduce a breaking change? Yes No Other information A follow-up on the rolldown side could cache code in transformToRenderedModule, but this hoist removes the cost regardless of the rolldown version. The [PLUGIN_TIMINGS] warning still fires after the fix because rolldown compares plugin time against a near-zero link stage when the inputs are a few hundred pre-bundled chunks; passing checks: { pluginTimings: false } to rolldown() in the optimizer would silence it, but that is left out of this PR. 🤖 Generated with Claude Code
Open Graph Description: PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-comm...
X Description: PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-comm...
Opengraph URL: https://github.com/angular/angular-cli/pull/34045
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:88f060e4-3680-7b1a-82e8-4e635a2d95aa |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BE58:4279A:107E157:1631C32:6B011E57 |
| html-safe-nonce | 73838dbfd58e8f9638833630271f75b79b8ed5e9e8f4958fc3b6dd6ef483d2c3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTU4OjQyNzlBOjEwN0UxNTc6MTYzMUMzMjo2QjAxMUU1NyIsInZpc2l0b3JfaWQiOiI3NjIxMjg1MTUyMDM0OTg3NjA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 38b4e05273b54211fc98e4bc35cd82cf7f20cef2cf9335e3134f97d9f1eada41 |
| hovercard-subject-tag | pull_request:4475113080 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/angular/angular-cli/pull/34045/files |
| twitter:image | https://avatars.githubusercontent.com/u/19957832?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/19957832?s=400&v=4 |
| og:image:alt | PR Checklist Please check to confirm your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-comm... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width