avoid computing a full shape for indirectly invalidated files (#44090)

* add shape updates to baselines

* avoid computing a full shape for indirectly invalidated files

using file version as shape is enough to keep build info valid
and it's much cheaper
This commit is contained in:
Tobias Koppers
2021-06-22 19:33:54 +02:00
committed by GitHub
parent e9a51b4010
commit 22637a232b
313 changed files with 5074 additions and 380 deletions

View File

@@ -478,6 +478,7 @@ namespace ts {
// we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file
// This ensures that we dont later during incremental builds considering wrong signature.
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
BuilderState.updateShapeSignature(
state,
program,
@@ -485,7 +486,8 @@ namespace ts {
Debug.checkDefined(state.currentAffectedFilesSignatures),
cancellationToken,
computeHash,
state.currentAffectedFilesExportedModulesMap
state.currentAffectedFilesExportedModulesMap,
/* useFileVersionAsSignature */ true
);
// If not dts emit, nothing more to do
if (getEmitDeclarations(state.compilerOptions)) {

View File

@@ -398,7 +398,7 @@ namespace ts {
/**
* Returns if the shape of the signature has changed since last emit
*/
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ManyToManyPathMap) {
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ManyToManyPathMap, useFileVersionAsSignature: boolean = state.useFileVersionAsSignature) {
Debug.assert(!!sourceFile);
Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
@@ -412,7 +412,7 @@ namespace ts {
const prevSignature = info.signature;
let latestSignature: string | undefined;
if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) {
if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
const emitOutput = getFileEmitOutput(
programOfThisState,
sourceFile,

View File

@@ -468,6 +468,7 @@ namespace ts.tscWatch {
if (!builderProgram) return;
if (builderProgram !== oldProgram?.[1]) {
const state = builderProgram.getState();
const internalState = state as unknown as BuilderState;
if (state.semanticDiagnosticsPerFile?.size) {
baseline.push("Semantic diagnostics in builder refreshed for::");
for (const file of program.getSourceFiles()) {
@@ -479,6 +480,24 @@ namespace ts.tscWatch {
else {
baseline.push("No cached semantic diagnostics in the builder::");
}
if (internalState) {
baseline.push("");
if (internalState.hasCalledUpdateShapeSignature?.size) {
baseline.push("Shape signatures in builder refreshed for::");
internalState.hasCalledUpdateShapeSignature.forEach((path: Path) => {
const info = state.fileInfos.get(path);
if(info?.version === info?.signature || !info?.signature) {
baseline.push(path + " (used version)");
}
else {
baseline.push(path + " (computed .d.ts)");
}
});
}
else {
baseline.push("No shapes updated in the builder::");
}
}
baseline.push("");
if (!baselineDependencies) return;
baseline.push("Dependencies for::");