perf(@angular/build): skip semantic affected-file walk when type checking is disabled#33585
perf(@angular/build): skip semantic affected-file walk when type checking is disabled#33585mattlewis92 wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…king is disabled When type checking is disabled (`NG_BUILD_TYPE_CHECK=0`), the AOT build still ran a full semantic type-check as a side effect of computing the affected-files set, then discarded the result. `useTypeChecking` already suppresses the *consumption* of semantic diagnostics via the compiler-plugin `diagnoseFiles` mask, but the *production* -- the `findAffectedFiles` -> `getSemanticDiagnosticsOfNextAffectedFile` walk -- was never gated, so disabling type checking still paid for a full semantic pass whose results were never read. The affected set has three consumers: Angular template diagnostics (behind the `semantic` flag, already suppressed when type checking is off), the single-file vs whole-program diagnostics optimization (also diagnostics only), and the emit gate in `emitAffectedFiles()`. The emit gate only matters in the slow TypeScript emit path where cross-file types can change a file's JS; in the isolatedModules fast path emit is per-file/type-erased, so an empty set is safe. Gate the walk so it only runs when type checking is on OR the slow emit path is used, and skip it in the (type-check-off + fast-path) combination.
There was a problem hiding this comment.
Code Review
This pull request optimizes the AOT compilation process by skipping the semantic 'affected files' walk when type checking is disabled, as its results are only consumed for diagnostics which are already suppressed in that mode. A new end-to-end test has been added to verify that the emitted JavaScript remains byte-for-byte identical when type checking is toggled. I have no feedback to provide as there were no review comments.
14cae74 to
561d9ec
Compare
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When type checking is disabled (
NG_BUILD_TYPE_CHECK=0), the AOT build still ran a full semantic type-check as a side effect of computing the affected-files set, then discarded the result.useTypeCheckingalready suppresses the consumption of semantic diagnostics via the compiler-plugindiagnoseFilesmask, but the production -- thefindAffectedFiles->getSemanticDiagnosticsOfNextAffectedFilewalk -- was never gated, so disabling type checking still paid for a full semantic pass whose results were never read.Issue Number: N/A
What is the new behavior?
Our application is so large that we build it in CI with the
NG_BUILD_TYPE_CHECK=0flag set, and run typechecking separately viangc -p apps/{projectName}/tsconfig.app.json --noEmitas a parallel jobOur CI build times dropped by ~100s after applying this change! Alongside the patch added in #33526 our build times dropped from ~9.5m to ~5.5m 🚀
Does this PR introduce a breaking change?
Other information