perf(compiler-cli): skip analysis in incremental builds for files without Angular behavior (#42562)
In an incremental rebuild, the compiler attempts to reuse as much analysis data from a prior compilation as possible to avoid doing the analysis work again. For source files without Angular behavior however, no analysis data would be recorded such that the source file had to be reanalyzed each rebuild, even if it has not changed. This commit avoids the analysis of such source files by registering these files as not containing any Angular behavior; allowing subsequent rebuilds to avoid the analysis work. PR Close #42562
This commit is contained in:
parent
a502279592
commit
5fb23eccea
|
@ -82,6 +82,12 @@ export class TraitCompiler implements ProgramTypeCheckAdapter {
|
|||
*/
|
||||
protected fileToClasses = new Map<ts.SourceFile, Set<ClassDeclaration>>();
|
||||
|
||||
/**
|
||||
* Tracks which source files have been analyzed but did not contain any traits. This set allows
|
||||
* the compiler to skip analyzing these files in an incremental rebuild.
|
||||
*/
|
||||
protected filesWithoutTraits = new Set<ts.SourceFile>();
|
||||
|
||||
private reexportMap = new Map<string, Map<string, [string, string]>>();
|
||||
|
||||
private handlersByName =
|
||||
|
@ -121,12 +127,17 @@ export class TraitCompiler implements ProgramTypeCheckAdapter {
|
|||
|
||||
const priorWork = this.incrementalBuild.priorAnalysisFor(sf);
|
||||
if (priorWork !== null) {
|
||||
for (const priorRecord of priorWork) {
|
||||
this.adopt(priorRecord);
|
||||
}
|
||||
|
||||
this.perf.eventCount(PerfEvent.SourceFileReuseAnalysis);
|
||||
this.perf.eventCount(PerfEvent.TraitReuseAnalysis, priorWork.length);
|
||||
|
||||
if (priorWork.length > 0) {
|
||||
for (const priorRecord of priorWork) {
|
||||
this.adopt(priorRecord);
|
||||
}
|
||||
|
||||
this.perf.eventCount(PerfEvent.TraitReuseAnalysis, priorWork.length);
|
||||
} else {
|
||||
this.filesWithoutTraits.add(sf);
|
||||
}
|
||||
|
||||
// Skip the rest of analysis, as this file's prior traits are being reused.
|
||||
return;
|
||||
|
@ -176,6 +187,9 @@ export class TraitCompiler implements ProgramTypeCheckAdapter {
|
|||
}
|
||||
result.set(sf, records);
|
||||
}
|
||||
for (const sf of this.filesWithoutTraits) {
|
||||
result.set(sf, []);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue