Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f462576

Browse filesBrowse files
committed
Re-do tracing initialization and tests around calls
Make `tracing` either `undefined` or the same namespace as before. Switching all calls to `tracing?.___` means that there is no cost for a call or the arguments when tracing is not used. Comparing two runs without tracing (27 runs, drop 5+5, avg rest) I get: master: 42.59s user 1.00s system 165% cpu 26.372 total changed: 42.01s user 0.982 system 165% cpu 26.039 total (Makes it all private, so no api changes.)
1 parent 7de5d0b commit f462576
Copy full SHA for f462576

12 files changed

+107-114Lines changed: 107 additions & 114 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/binder.ts‎

Copy file name to clipboardExpand all lines: src/compiler/binder.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ namespace ts {
174174
const binder = createBinder();
175175

176176
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
177-
tracing.push(tracing.Phase.Bind, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
177+
tracing?.push(tracing.Phase.Bind, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
178178
performance.mark("beforeBind");
179179
perfLogger.logStartBindFile("" + file.fileName);
180180
binder(file, options);
181181
perfLogger.logStopBindFile();
182182
performance.mark("afterBind");
183183
performance.measure("Bind", "beforeBind", "afterBind");
184-
tracing.pop();
184+
tracing?.pop();
185185
}
186186

187187
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+20-20Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13338,7 +13338,7 @@ namespace ts {
1333813338
// caps union types at 1000 unique object types.
1333913339
const estimatedCount = (count / (len - i)) * len;
1334013340
if (estimatedCount > 1000000) {
13341-
tracing.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map(t => t.id) });
13341+
tracing?.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map(t => t.id) });
1334213342
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
1334313343
return false;
1334413344
}
@@ -13817,7 +13817,7 @@ namespace ts {
1381713817
function checkCrossProductUnion(types: readonly Type[]) {
1381813818
const size = getCrossProductUnionSize(types);
1381913819
if (size >= 100000) {
13820-
tracing.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(t => t.id), size });
13820+
tracing?.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(t => t.id), size });
1382113821
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
1382213822
return false;
1382313823
}
@@ -15751,7 +15751,7 @@ namespace ts {
1575115751
// We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing
1575215752
// with a combination of infinite generic types that perpetually generate new type identities. We stop
1575315753
// the recursion here by yielding the error type.
15754-
tracing.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
15754+
tracing?.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
1575515755
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
1575615756
return errorType;
1575715757
}
@@ -16881,7 +16881,7 @@ namespace ts {
1688116881
reportIncompatibleStack();
1688216882
}
1688316883
if (overflow) {
16884-
tracing.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth });
16884+
tracing?.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth });
1688516885
const diag = error(errorNode || currentNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
1688616886
if (errorOutputContainer) {
1688716887
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -17368,7 +17368,7 @@ namespace ts {
1736817368
}
1736917369

1737017370
function traceUnionsOrIntersectionsTooLarge(source: Type, target: Type): void {
17371-
if (!tracing.isTracing()) {
17371+
if (!tracing) {
1737217372
return;
1737317373
}
1737417374

@@ -17730,7 +17730,7 @@ namespace ts {
1773017730
}
1773117731

1773217732
if (expandingFlags === ExpandingFlags.Both) {
17733-
tracing.instant(tracing.Phase.CheckTypes, "recursiveTypeRelatedTo_DepthLimit", {
17733+
tracing?.instant(tracing.Phase.CheckTypes, "recursiveTypeRelatedTo_DepthLimit", {
1773417734
sourceId: source.id,
1773517735
sourceIdStack: sourceStack.map(t => t.id),
1773617736
targetId: target.id,
@@ -17767,9 +17767,9 @@ namespace ts {
1776717767
}
1776817768

1776917769
function structuredTypeRelatedTo(source: Type, target: Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary {
17770-
tracing.push(tracing.Phase.CheckTypes, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
17770+
tracing?.push(tracing.Phase.CheckTypes, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
1777117771
const result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
17772-
tracing.pop();
17772+
tracing?.pop();
1777317773
return result;
1777417774
}
1777517775

@@ -18294,7 +18294,7 @@ namespace ts {
1829418294
numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
1829518295
if (numCombinations > 25) {
1829618296
// We've reached the complexity limit.
18297-
tracing.instant(tracing.Phase.CheckTypes, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations });
18297+
tracing?.instant(tracing.Phase.CheckTypes, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations });
1829818298
return Ternary.False;
1829918299
}
1830018300
}
@@ -19073,7 +19073,7 @@ namespace ts {
1907319073
function getVariancesWorker<TCache extends { variances?: VarianceFlags[] }>(typeParameters: readonly TypeParameter[] = emptyArray, cache: TCache, createMarkerType: (input: TCache, param: TypeParameter, marker: Type) => Type): VarianceFlags[] {
1907419074
let variances = cache.variances;
1907519075
if (!variances) {
19076-
tracing.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: (cache as any).id ?? (cache as any).declaredType?.id ?? -1 });
19076+
tracing?.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: (cache as any).id ?? (cache as any).declaredType?.id ?? -1 });
1907719077
// The emptyArray singleton is used to signal a recursive invocation.
1907819078
cache.variances = emptyArray;
1907919079
variances = [];
@@ -19108,7 +19108,7 @@ namespace ts {
1910819108
variances.push(variance);
1910919109
}
1911019110
cache.variances = variances;
19111-
tracing.pop();
19111+
tracing?.pop();
1911219112
}
1911319113
return variances;
1911419114
}
@@ -22199,7 +22199,7 @@ namespace ts {
2219922199
if (flowDepth === 2000) {
2220022200
// We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error
2220122201
// and disable further control flow analysis in the containing function or module body.
22202-
tracing.instant(tracing.Phase.CheckTypes, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
22202+
tracing?.instant(tracing.Phase.CheckTypes, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
2220322203
flowAnalysisDisabled = true;
2220422204
reportFlowControlError(reference);
2220522205
return errorType;
@@ -31673,7 +31673,7 @@ namespace ts {
3167331673
}
3167431674

3167531675
function checkExpression(node: Expression | QualifiedName, checkMode?: CheckMode, forceTuple?: boolean): Type {
31676-
tracing.push(tracing.Phase.Check, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
31676+
tracing?.push(tracing.Phase.Check, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
3167731677
const saveCurrentNode = currentNode;
3167831678
currentNode = node;
3167931679
instantiationCount = 0;
@@ -31683,7 +31683,7 @@ namespace ts {
3168331683
checkConstEnumAccess(node, type);
3168431684
}
3168531685
currentNode = saveCurrentNode;
31686-
tracing.pop();
31686+
tracing?.pop();
3168731687
return type;
3168831688
}
3168931689

@@ -34489,10 +34489,10 @@ namespace ts {
3448934489
}
3449034490

3449134491
function checkVariableDeclaration(node: VariableDeclaration) {
34492-
tracing.push(tracing.Phase.Check, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
34492+
tracing?.push(tracing.Phase.Check, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
3449334493
checkGrammarVariableDeclaration(node);
3449434494
checkVariableLikeDeclaration(node);
34495-
tracing.pop();
34495+
tracing?.pop();
3449634496
}
3449734497

3449834498
function checkBindingElement(node: BindingElement) {
@@ -37570,7 +37570,7 @@ namespace ts {
3757037570
}
3757137571

3757237572
function checkDeferredNode(node: Node) {
37573-
tracing.push(tracing.Phase.Check, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
37573+
tracing?.push(tracing.Phase.Check, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
3757437574
const saveCurrentNode = currentNode;
3757537575
currentNode = node;
3757637576
instantiationCount = 0;
@@ -37606,16 +37606,16 @@ namespace ts {
3760637606
break;
3760737607
}
3760837608
currentNode = saveCurrentNode;
37609-
tracing.pop();
37609+
tracing?.pop();
3761037610
}
3761137611

3761237612
function checkSourceFile(node: SourceFile) {
37613-
tracing.push(tracing.Phase.Check, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
37613+
tracing?.push(tracing.Phase.Check, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
3761437614
performance.mark("beforeCheck");
3761537615
checkSourceFileWorker(node);
3761637616
performance.mark("afterCheck");
3761737617
performance.measure("Check", "beforeCheck", "afterCheck");
37618-
tracing.pop();
37618+
tracing?.pop();
3761937619
}
3762037620

3762137621
function unusedIsError(kind: UnusedKind, isAmbient: boolean): boolean {
Collapse file

‎src/compiler/emitter.ts‎

Copy file name to clipboardExpand all lines: src/compiler/emitter.ts
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,17 @@ namespace ts {
340340
sourceFiles: sourceFileOrBundle.sourceFiles.map(file => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
341341
};
342342
}
343-
tracing.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
343+
tracing?.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
344344
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
345-
tracing.pop();
345+
tracing?.pop();
346346

347-
tracing.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
347+
tracing?.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
348348
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
349-
tracing.pop();
349+
tracing?.pop();
350350

351-
tracing.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
351+
tracing?.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
352352
emitBuildInfo(bundleBuildInfo, buildInfoPath);
353-
tracing.pop();
353+
tracing?.pop();
354354

355355
if (!emitSkipped && emittedFilesList) {
356356
if (!emitOnlyDtsFiles) {
Collapse file

‎src/compiler/parser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ namespace ts {
607607
}
608608

609609
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile {
610-
tracing.push(tracing.Phase.Parse, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
610+
tracing?.push(tracing.Phase.Parse, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
611611
performance.mark("beforeParse");
612612
let result: SourceFile;
613613

@@ -622,7 +622,7 @@ namespace ts {
622622

623623
performance.mark("afterParse");
624624
performance.measure("Parse", "beforeParse", "afterParse");
625-
tracing.pop();
625+
tracing?.pop();
626626
return result;
627627
}
628628

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.