Skip to content

refactor(compiler-cli): reduce preprocessor incremental fingerprinting overhead - #71976

Open
atscott wants to merge 1 commit into
angular:mainfrom
atscott:perf/ngp-incremental-fingerprinting
Open

atscott wants to merge 1 commit into
angular:mainfrom
atscott:perf/ngp-incremental-fingerprinting

Conversation

@atscott

@atscott atscott commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

This change reduces JS serialization and hashing overhead during incremental HybridCompiler runs.

When compiling components with large dependency metadata, HybridCompiler.computeBoundFingerprint previously ran JSON.stringify and JS string hashing over the full AnalysisResult (including resolvedDeclarations), and computed that fingerprint twice per component file across prepareChunk and processFile.

What changed:

  • Derive Hash on AnalysisResult and its nested wire structs in Rust ng-analyze (switching deferredImports block maps from HashMap to BTreeMap for deterministic ordering) and attach a DefaultHasher digest as an optional fingerprint field during FileData::to_wire. HybridCompiler.computeBoundFingerprint uses that digest rather than serializing large AnalysisResult objects in JS, and remoteScopeInputs skips serializing eagerlyUsedDeclarations for classes that are not remotely scoped.
  • Record analysisResult on FileAnalysis during template binding in prepareFileAnalysisForBinding and populateBoundData, and reuse FileAnalysis.boundFingerprint in processFile when analysisResult, sourceContent, and boundFingerprint match.

@angular-robot angular-robot Bot added area: performance Issues related to performance area: compiler Issues related to `ngc`, Angular's template compiler labels Nov 11, 2026
@ngbot ngbot Bot added this to the Backlog milestone Nov 11, 2026
@atscott
atscott force-pushed the perf/ngp-incremental-fingerprinting branch 2 times, most recently from 5337381 to 5174eb2 Compare November 11, 2026 23:32
@atscott atscott changed the title perf(compiler-cli): reduce preprocessor incremental fingerprinting overhead refactor(compiler-cli): reduce preprocessor incremental fingerprinting overhead Nov 11, 2026
@atscott
atscott force-pushed the perf/ngp-incremental-fingerprinting branch from 5174eb2 to a460e6c Compare November 11, 2026 23:55
@atscott
atscott requested a review from clydin November 12, 2026 00:01
@atscott atscott added the target: rc This PR is targeted for the next release-candidate label Nov 12, 2026
@atscott
atscott force-pushed the perf/ngp-incremental-fingerprinting branch from a460e6c to 184bce5 Compare November 12, 2026 00:07
@atscott
atscott marked this pull request as ready for review November 12, 2026 00:09
@atscott
atscott force-pushed the perf/ngp-incremental-fingerprinting branch from 184bce5 to 0c6775f Compare November 12, 2026 00:51
…g overhead

Derive `Hash` on `AnalysisResult` and its nested wire structs (switching
object-form `deferredImports` block maps from `HashMap` to `BTreeMap`
for deterministic iteration across metadata and `deferredBlocks`) and
hash each result in `FileData::to_wire` using `DefaultHasher` into an
optional `fingerprint` field. On the TypeScript side,
`HybridCompiler.computeBoundFingerprint` uses `result.fingerprint` when
available instead of running `JSON.stringify` and JS hashing over large
`resolvedDeclarations` graphs, and `remoteScopeInputs` skips serializing
`eagerlyUsedDeclarations` for classes that are not remotely scoped.

Record `analysisResult` on `FileAnalysis` during template binding in
`prepareFileAnalysisForBinding` and `populateBoundData`, and reuse
`FileAnalysis.boundFingerprint` in `processFile` when `analysisResult`,
`sourceContent`, and `boundFingerprint` match.
@atscott
atscott force-pushed the perf/ngp-incremental-fingerprinting branch from 0c6775f to 4cd01dc Compare November 12, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler area: performance Issues related to performance target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant