Narrow generic conditional and indexed access return types when checking return statements
Fixes #33912. Fixes #33014.
Motivation
Sometimes we want to write functions whose return type is picked between different options, depending on the type of a parameter. For instance:
declare const record: Record<string, string>;
declare const array: string[];
function getObject(group) {
if (group === undefined) {
return record;
}
return array;
}
const arrayResult = getObject("group");
const recordResult = getObject(undefined);
If we want to precisely express this dependency between the return type and the type of nameOrId, we have a few options.
The first one is to use overloads:
declare const record: Record<string, string[]>;
declare const array: string[];
function getObject(group: undefined): Record<string, string[]>;
function getObject(group: string): string[];
function getObject(group: string | undefined): string[] | Record<string, string[]>;
function getObject(group: string | undefined): string[] | Record<string, string[]> {
if (group === undefined) {
return record;
}
return array;
}
const arrayResult = getObject("group");
const recordResult = getObject(undefined);
However, if you make a mistake in the implementation of the function and return the wrong type, TypeScript will not warn you. For instance, if instead you implement the function like this:
declare const record: Record<string, string[]>;
declare const array: string[];
function getObject(group: undefined): Record<string, string[]>;
function getObject(group: string): string[];
function getObject(group: string | undefined): string[] | Record<string, string[]>;
function getObject(group: string | undefined): string[] | Record<string, string[]> {
if (!group) { // An empty string is falsy
return record;
}
return array;
}
const badResult = getObject(""); // Type says this returns `string[]`, but actually it returns a record.
then your function implementation doesn't respect the overload signatures, but TypeScript will not error.
The alternative to overloads is to use conditional types, like so:
declare const record: Record<string, string[]>;
declare const array: string[];
function getObject<T extends string | undefined>(group: T):
T extends string ? string[] : T extends undefined ? Record<string, string[]> : never {
if (group === undefined) {
return record; // Error! Type 'Record<string, string[]>' is not assignable to type 'T extends string ? string[] : T extends undefined ? Record<string, string[]> : never'.
}
return array; // Error! Type 'string[]' is not assignable to type 'T extends string ? string[] : T extends undefined ? Record<string, string[]> : never'
}
const arrayResult = getObject("group");
const recordResult = getObject(undefined);
However, while everything works out for the callers of getObject, in the implementation TypeScript errors on the return statements, because it compares the type of the return expression to the annotated conditional return type, and Record<string, string[]> is not assignable to T extends undefined ? Record<string, string[]> : never.
Solution: conditional return type narrowing
For this PR, I propose a way of checking return statements that understands cases like above. The idea is that, for the function above:
function getObject<T extends string | undefined>(group: T):
T extends string ? string[] : T extends undefined ? Record<string, string[]> : never {
if (group === undefined) {
return record;
}
return array;
}
when checking the return statement return record, TS will know that group has type undefined. TS will also know that type parameter T corresponds exactly to the type of group. Combining those two pieces of information, TS will know that, inside that branch, the expected return type has to be Record<string, string[]> (or a supertype). Then, instead of checking return record's type against T extends string ? string[] : T extends undefined ? Record<string, string[]> : never, it will check return record's type against the Record<string, string[]> branch of the conditional, i.e. a narrowed version of the conditional type. Then there will be no error on the return statement. In the same manner, when checking the return statement return array, TS will know that group has type string, and that therefore it can check the type of the return statement against the string[] branch of the conditional return type.
For now, we can think of it like this: when we check return statement return record, we see that group has narrowed type undefined. Then, we plug that information back into the return type by instantiating T extends string ? string[] : T extends undefined ? Record<string, string[]> : never with T replaced by undefined.
Restrictions
Conditional types
Reasoning about conditional types is pretty tricky. In general, given a function f(...args): SomeConditionalType whose return type is some (generic) conditional type, we are not able to do the special check proposed above, because it wouldn't be safe.
We need to place some restrictions on what the conditional return type looks like in order for TS to safely analyze it.
We can safely analyze a conditional return type that has the shape T extends A ? AType : T extends B ? BType : never.
This means the conditional type needs to be distributive (i.e. its check type is a naked type parameter T) and have never as its false-most type, and it cannot have infer type parameters (e.g. it cannot be T extends [infer A] ? AType : T extends B ? BType : never).
Intuitively, we can think of this conditional type shape as reflecting the kind of code one would write in the implementation of such a function.
In addition to the previous restrictions on the conditional type, the extends types of the conditional (A and B above), have to be constituents of the type parameter's constraint (T above), like so:
function fun<T extends A | B>(param: T): T extends A ? AType : T extends B ? BType : never {
if (isA(param)) { ... }
else { ... }
}
This is because, to narrow the return type, we first need to narrow the type of param (more on that below). When we narrow the type of param, in a lot of scenarios, we will start from its type, T, or in this case its type constraint, A | B. Then, we will further narrow that type based on information from control flow analysis, e.g. to pick either A or B (see getNarrowableTypeForReference in checker.ts).
Therefore, in this typical case, narrowing param means we will end up with a type that is either A, B, or a subtype of those. In turn, when we plug this narrowed type back into the conditional return type, this means we will be able to pick a branch of the conditional type and resolve it. e.g. if the narrowed type of param is A, the conditional type will resolve to AType.
This restriction also reinforces that you want your return type to closely match the structure of your implementation.
Aside: why never
A common way of trying to write a conditional return type is like the following:
function stringOrNumber<T extends string | number>(param: T): T extends string ? string : number {
if (typeof param === "string") {
return "some string";
}
return 123;
}
const num = stringOrNumber(123);
const str = stringOrNumber("string");
declare let strOrNum: string | number;
const both = stringOrNumber(strOrNum);
This example works fine and it would be safe for TS to allow that function implementation. However, in general, it is not safe to allow this pattern of conditional return type. Consider this case:
function aStringOrANumber<T extends { a: string } | { a: undefined }>(param: T): T extends { a: string } ? string : number {
if (typeof param.a === "string") {
return "some string";
}
return 123;
}
const aNum = aStringOrANumber({ a: undefined });
const aStr = aStringOrANumber({ a: "" });
// Bad! Type says `number`, but actually should say `string | number`
const aNotBoth = aStringOrANumber({ a: strOrUndef });
The problem boils down to the fact that, when a conditional return type resolves to its false branch, we can't know if the check type is related or not to the extends type. For the example above, when we plug in { a: undefined } for T in T extends { a: string } ? string : number, then we fall into the false branch of the conditional, which is desired because { a: undefined } does not overlap { a: string }. However, when we plug in { a: string | undefined } for T in T extends { a: string } ? string : number, we fall into the false branch of the conditional, but this is not desired because { a: string | undefined } overlaps { a: string }, and therefore the return type could actually be string.
Resolving a conditional type to its false-most branch of a conditional type doesn't provide TS with enough information to safely determine what the return type should be, and because of that, narrowing a conditional return type requires the false-most branch of the conditional to be never.
Type parameter references
As hinted at above, to narrow a conditional return type, we first need to narrow a parameter, and we need to know that the type of that parameter uniquely corresponds to a type parameter. Revisiting our example:
function getObject<T extends string | undefined>(group: T):
T extends string ? string[] : T extends undefined ? Record<string, string[]> : never {
if (group === undefined) {
return record;
}
return array;
}
To narrow the return type T extends string ? string[] : T extends undefined ? Record<string, string[]> : never, we first narrow the type of group inside the if branch, and then we can use that information to reason about what type T could be replaced with. This only works because the declared type of group is exactly T, and also because there are no other parameters that use type T. So in the following cases, TS would not be able to narrow the return type, because there is no unique parameter to which T is linked:
function badGetObject1<T extends string | undefined>(group: T, someOtherParam: T):
T extends string ? string[] : T extends undefined ? Record<string, string[]> : never {
...
}
function badGetObject2<T extends string | undefined>(group: T, options: { a: number, b: T }):
T extends string ? string[] : T extends undefined ? Record<string, string[]> : never {
...
}
Indexed access types
The reasoning explained above for conditional types applies in a similar manner to indexed access types that look like this:
interface F {
"t": number,
"f": boolean,
}
function depLikeFun<T extends "t" | "f">(str: T): F[T] {
if (str === "t") {
return 1;
} else {
return true;
}
}
depLikeFun("t"); // has type number
depLikeFun("f"); // has type boolean
So cases like this, where the return type is an indexed access type with a type parameter index, are also supported by this PR. The thinking is similar: in the code above, when we are in the if (str === "t") { ... } branch, we know str has type "t", and we can plug that information back into the return type F[T] which resolves to type number, and similarly for the else branch.
Implementation
The implementation works roughly like this: When checking a return statement expression:
- We check if the type of the expression is assignable to the return type. If it is, good, nothing else needs to be done. This makes sure we don't introduce new errors to existing code.
- If the type of the expression is not assignable to the return type, we might need to narrow the return type and check again. We proceed to attempt narrowing the return type.
- We check if the return type has the right shape, i.e. it has a shape of either
SomeType[T]orT extends A ? AType : T extends B ? BType : never, and what parameters the type parameters are uniquely linked to, among other requirements. If any of those requirements is not met, we don't continue with narrowing. - For every type parameter that is uniquely linked to a parameter, we obtain its narrowed type.
- Say we have type parameter
Tthat is uniquely linked to parameterparam. To narrow the return type, we first need to obtain the narrowed type forparamat the return statement position. Because, in the source code, there might not be an occurrence ofparamat the return statement position, we create a synthetic reference toparamat that position and obtain its narrowed type via regular control-flow analysis. We then obtain a narrowed typeNforparam. (If we don't, we'll just ignore that type parameter).
- Say we have type parameter
- Once we have the narrowed type for each type parameter, we need to plug that information back into the return type. We do this by instantiating the return type with a substitution type. For instance, if the return type is
T extends A ? AType : T extends B ? BType : never,Tis linked toparam, andparamhas narrowed typeN, we will instantiate the return type withTreplaced byT & N(as a substitution type). - Once we obtain this narrowed return type, we get the type of the return expression, this time contextually checked by the narrowed return type, and then check if this type is assignable to the narrowed return type.
Conditional expression checking
To support conditional expression checking in return statements, this PR changes how we check a conditional expression in a return statement. Before this PR, when checking a return statement return cond ? exp1 : exp2, we obtain the type of the whole expression cond ? exp1 : exp2, and then compare that type to the return type. With this PR, we now separately check each branch: we first obtain the type of exp1, and compare that type to the return type, then obtain the type of exp2 and compare that type to the return type. This allows us to properly check a conditional expression when return type narrowing is needed.
This a breaking change, and the only change that affects existing code, but this change finds bugs. Analysis of extended tests changes: https://github.com/microsoft/TypeScript/pull/56941#issuecomment-2406411716. This change also slightly affects performance because we do more checks. Latest perf results here: https://github.com/microsoft/TypeScript/pull/56941#issuecomment-2403351320.
Performance results
This feature is opt-in. Currently, virtually no code has functions whose return types are conditional or indexed access types that satisfy the restrictions above, so no code goes down the new code path for narrowing return types. This means for existing code, there's no performance impact from the return type narrowing. The only current performance impact is from the conditional expression checking change (see a version of this PR without the change for conditional expressions: https://github.com/microsoft/TypeScript/pull/60268#issuecomment-2421064260).
Assessing the performance of the new code path is tricky, as there are no baselines. The existing alternative to conditional return types is to use overloads. In one scenario I tested, checking a function written with conditional return types with this PR took ~+16% check time compared to the same function using overloads and the main branch. However, that's for checking the function declaration. In a different scenario where I included a lot of function calls though, the version with conditional return types + this PR took ~-15% compared to overloads + main branch. So I'd say the performance is acceptable, especially considering you get stronger checks when using conditional return types, and also only a small number of functions in a codebase should be written using this feature.
Unsupported things
-
Inference: TS will not infer a conditional return type or an indexed access type for any function or expression. Inferring such a type is more complicated than checking, and inferring such a type could also be surprising for users. This is out of scope.
-
Contextually-typed anonymous functions:
type GetObjectCallback = <T extends string | undefined>(group: T) => T extends string ? string[] : T extends undefined ? Record<string, string[]> : never;
const getObjectBad1: GetObjectCallback =
(group) => { return group === undefined ? record : array }; // Error
declare function outerFun(callback: GetObjectCallback);
outerFun((group) => { return group === undefined ? record : array }); // Error
This is because, if your function does not have an explicitly annotated return type, we will infer one from the returns.
- Detection of link between parameter and type parameter in more complicated scenarios:
// All cases below are not recognized
// Type alias
type Id<X> = X;
function f2<T extends boolean>(arg: Id<T>): T extends true ? string : T extends false ? number : never {
if (arg) {
return "someString";
}
return 123;
}
// Property type
function f3<T extends boolean>(arg: { prop: T }): T extends true ? string : T extends false ? number : never {
if (arg.prop) {
return "someString";
}
return 123;
}
// Destructuring
function f4<T extends boolean>({ arg }: { arg: T }): T extends true ? string : T extends false ? number : never {
if (arg.prop) {
return "someString";
}
return 123;
}
// Combinations of the above, e.g.:
type Opts<X> = { prop: X };
function f5<T extends boolean>(arg: Opts<T>): T extends true ? string : T extends false ? number : never {
if (arg.prop) {
return "someString";
}
return 123;
}
This could be supported in the future.
@typescript-bot perf test this
Heya @gabritto, I've started to run the regular perf test suite on this PR at a3a54ce0582ac737deb91322a14003f92495794c. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
Compiler
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,492k (± 0.01%) | 0k | ~ | 0k | 0k | p=1.000 n=6+0 |
| Parse Time | 2.65s (± 0.19%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Bind Time | 0.82s (± 0.50%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Check Time | 8.15s (± 0.38%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Emit Time | 7.10s (± 0.27%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Total Time | 18.72s (± 0.23%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 192,495k (± 1.23%) | 0k | ~ | 0k | 0k | p=1.000 n=6+0 |
| Parse Time | 1.36s (± 0.60%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Bind Time | 0.72s (± 0.57%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Check Time | 9.27s (± 0.32%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Emit Time | 2.62s (± 0.57%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Total Time | 13.96s (± 0.24%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,403k (± 0.01%) | 348,466k (± 0.01%) | +1,064k (+ 0.31%) | 348,436k | 348,486k | p=0.005 n=6 |
| Parse Time | 2.46s (± 0.31%) | 2.47s (± 0.43%) | ~ | 2.45s | 2.48s | p=0.273 n=6 |
| Bind Time | 0.93s (± 0.68%) | 0.93s (± 0.00%) | ~ | 0.93s | 0.93s | p=1.000 n=6 |
| Check Time | 6.89s (± 0.18%) | 6.93s (± 0.67%) | ~ | 6.86s | 6.98s | p=0.145 n=6 |
| Emit Time | 4.05s (± 0.24%) | 4.06s (± 0.40%) | ~ | 4.03s | 4.08s | p=0.548 n=6 |
| Total Time | 14.33s (± 0.07%) | 14.38s (± 0.32%) | ~ | 14.31s | 14.43s | p=0.075 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,725k (± 0.01%) | 303,226k (± 0.01%) | +501k (+ 0.17%) | 303,204k | 303,255k | p=0.005 n=6 |
| Parse Time | 2.01s (± 0.83%) | 1.98s (± 0.59%) | -0.03s (- 1.41%) | 1.97s | 2.00s | p=0.019 n=6 |
| Bind Time | 1.00s (± 1.03%) | 1.01s (± 0.63%) | ~ | 1.00s | 1.02s | p=0.203 n=6 |
| Check Time | 6.30s (± 0.23%) | 6.40s (± 0.50%) | +0.10s (+ 1.53%) | 6.35s | 6.44s | p=0.005 n=6 |
| Emit Time | 3.58s (± 0.29%) | 3.58s (± 0.15%) | ~ | 3.58s | 3.59s | p=0.663 n=6 |
| Total Time | 12.90s (± 0.20%) | 12.97s (± 0.34%) | +0.08s (+ 0.58%) | 12.91s | 13.03s | p=0.014 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 506,836k (± 0.01%) | 507,361k (± 0.00%) | +525k (+ 0.10%) | 507,319k | 507,381k | p=0.005 n=6 |
| Parse Time | 2.58s (± 0.32%) | 2.60s (± 0.64%) | +0.02s (+ 0.97%) | 2.57s | 2.62s | p=0.024 n=6 |
| Bind Time | 1.00s (± 0.98%) | 0.99s (± 1.05%) | ~ | 0.97s | 1.00s | p=0.103 n=6 |
| Check Time | 16.91s (± 0.38%) | 17.03s (± 0.21%) | +0.12s (+ 0.71%) | 16.99s | 17.08s | p=0.006 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.49s (± 0.33%) | 20.62s (± 0.19%) | +0.13s (+ 0.63%) | 20.56s | 20.67s | p=0.006 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 512,847k (± 0.01%) | 0k | ~ | 0k | 0k | p=1.000 n=6+0 |
| Parse Time | 3.28s (± 0.27%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Bind Time | 1.53s (± 0.53%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Check Time | 2.81s (± 0.37%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Emit Time | 0.07s (± 5.69%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Total Time | 7.70s (± 0.15%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
tsserver
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-UnionsTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,351ms (± 0.88%) | 2,375ms (± 0.34%) | ~ | 2,360ms | 2,383ms | p=0.065 n=6 |
| Req 2 - geterr | 5,421ms (± 1.34%) | 1,803ms (± 1.40%) | 🟩-3,618ms (-66.74%) | 1,784ms | 1,837ms | p=0.005 n=6 |
| Req 3 - references | 326ms (± 1.14%) | 314ms (± 1.29%) | 🟩-12ms (- 3.74%) | 310ms | 319ms | p=0.004 n=6 |
| Req 4 - navto | 277ms (± 1.12%) | 266ms (± 0.70%) | 🟩-11ms (- 4.09%) | 263ms | 268ms | p=0.005 n=6 |
| Req 5 - completionInfo count | 1,356 (± 0.00%) | 1,356 (± 0.00%) | ~ | 1,356 | 1,356 | p=1.000 n=6 |
| Req 5 - completionInfo | 89ms (± 6.43%) | 78ms (± 7.05%) | 🟩-12ms (-13.08%) | 72ms | 84ms | p=0.030 n=6 |
| CompilerTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,487ms (± 1.18%) | 2,528ms (± 0.72%) | +41ms (+ 1.66%) | 2,494ms | 2,548ms | p=0.025 n=6 |
| Req 2 - geterr | 4,166ms (± 1.95%) | 1,035ms (± 0.18%) | 🟩-3,131ms (-75.15%) | 1,033ms | 1,037ms | p=0.005 n=6 |
| Req 3 - references | 342ms (± 1.56%) | 361ms (± 2.23%) | 🔻+20ms (+ 5.70%) | 345ms | 366ms | p=0.020 n=6 |
| Req 4 - navto | 285ms (± 1.16%) | 269ms (± 0.30%) | 🟩-16ms (- 5.61%) | 268ms | 270ms | p=0.004 n=6 |
| Req 5 - completionInfo count | 1,518 (± 0.00%) | 1,518 (± 0.00%) | ~ | 1,518 | 1,518 | p=1.000 n=6 |
| Req 5 - completionInfo | 83ms (± 8.37%) | 72ms (± 3.57%) | 🟩-11ms (-12.85%) | 70ms | 75ms | p=0.005 n=6 |
| xstateTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,603ms (± 0.76%) | 2,601ms (± 0.92%) | ~ | 2,566ms | 2,622ms | p=1.000 n=6 |
| Req 2 - geterr | 1,711ms (± 2.20%) | 911ms (± 1.48%) | 🟩-800ms (-46.78%) | 893ms | 931ms | p=0.005 n=6 |
| Req 3 - references | 110ms (± 9.24%) | 113ms (± 1.04%) | ~ | 111ms | 114ms | p=1.000 n=6 |
| Req 4 - navto | 365ms (± 0.22%) | 365ms (± 0.28%) | ~ | 364ms | 367ms | p=0.270 n=6 |
| Req 5 - completionInfo count | 2,073 (± 0.00%) | 2,073 (± 0.00%) | ~ | 2,073 | 2,073 | p=1.000 n=6 |
| Req 5 - completionInfo | 305ms (± 1.66%) | 304ms (± 1.24%) | ~ | 299ms | 308ms | p=0.872 n=6 |
- node (v18.15.0, x64)
- CompilerTSServer - node (v18.15.0, x64)
- Compiler-UnionsTSServer - node (v18.15.0, x64)
- xstateTSServer - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Startup
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| tsc-startup - node (v18.15.0, x64) | ||||||
| Execution time | 153.36ms (± 0.22%) | 153.79ms (± 0.19%) | +0.43ms (+ 0.28%) | 152.58ms | 157.13ms | p=0.000 n=600 |
| tsserver-startup - node (v18.15.0, x64) | ||||||
| Execution time | 228.40ms (± 0.17%) | 228.71ms (± 0.16%) | +0.32ms (+ 0.14%) | 227.49ms | 234.54ms | p=0.000 n=600 |
| tsserverlibrary-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.63ms (± 0.23%) | 230.86ms (± 0.18%) | +0.22ms (+ 0.10%) | 229.10ms | 238.80ms | p=0.000 n=600 |
| typescript-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.07ms (± 0.20%) | 230.08ms (± 0.17%) | ~ | 228.62ms | 233.45ms | p=0.316 n=600 |
- node (v18.15.0, x64)
- tsc-startup - node (v18.15.0, x64)
- tsserver-startup - node (v18.15.0, x64)
- tsserverlibrary-startup - node (v18.15.0, x64)
- typescript-startup - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test this
Heya @gabritto, I've started to run the regular perf test suite on this PR at 1b7489f3f8edaf9d803f7c015538fe644cf4e1d8. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
Compiler
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,465k (± 0.01%) | 296,141k (± 0.01%) | +676k (+ 0.23%) | 296,086k | 296,201k | p=0.005 n=6 |
| Parse Time | 2.64s (± 0.20%) | 2.64s (± 0.31%) | ~ | 2.63s | 2.65s | p=0.929 n=6 |
| Bind Time | 0.82s (± 0.50%) | 0.83s (± 0.66%) | +0.01s (+ 1.62%) | 0.83s | 0.84s | p=0.006 n=6 |
| Check Time | 8.15s (± 0.33%) | 8.28s (± 0.26%) | +0.12s (+ 1.49%) | 8.25s | 8.30s | p=0.005 n=6 |
| Emit Time | 7.11s (± 0.55%) | 7.16s (± 0.16%) | ~ | 7.15s | 7.18s | p=0.063 n=6 |
| Total Time | 18.73s (± 0.32%) | 18.91s (± 0.20%) | +0.18s (+ 0.96%) | 18.86s | 18.95s | p=0.005 n=6 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 196,416k (± 1.22%) | 195,042k (± 1.64%) | ~ | 192,116k | 198,001k | p=0.689 n=6 |
| Parse Time | 1.34s (± 1.99%) | 1.34s (± 1.15%) | ~ | 1.32s | 1.36s | p=1.000 n=6 |
| Bind Time | 0.72s (± 0.00%) | 0.76s (± 0.68%) | 🔻+0.04s (+ 5.09%) | 0.75s | 0.76s | p=0.002 n=6 |
| Check Time | 9.25s (± 0.66%) | 9.44s (± 0.53%) | +0.18s (+ 1.94%) | 9.38s | 9.49s | p=0.005 n=6 |
| Emit Time | 2.62s (± 0.63%) | 2.63s (± 1.52%) | ~ | 2.56s | 2.68s | p=0.223 n=6 |
| Total Time | 13.93s (± 0.66%) | 14.16s (± 0.69%) | +0.23s (+ 1.69%) | 14.03s | 14.26s | p=0.010 n=6 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,412k (± 0.00%) | 348,468k (± 0.00%) | +1,056k (+ 0.30%) | 348,453k | 348,480k | p=0.005 n=6 |
| Parse Time | 2.46s (± 0.31%) | 2.45s (± 0.60%) | ~ | 2.43s | 2.47s | p=0.117 n=6 |
| Bind Time | 0.93s (± 0.81%) | 0.93s (± 0.00%) | ~ | 0.93s | 0.93s | p=0.598 n=6 |
| Check Time | 6.90s (± 0.29%) | 6.92s (± 0.42%) | ~ | 6.89s | 6.97s | p=0.121 n=6 |
| Emit Time | 4.05s (± 0.43%) | 4.05s (± 0.25%) | ~ | 4.04s | 4.07s | p=0.803 n=6 |
| Total Time | 14.33s (± 0.25%) | 14.36s (± 0.35%) | ~ | 14.30s | 14.44s | p=0.261 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,721k (± 0.01%) | 303,200k (± 0.00%) | +479k (+ 0.16%) | 303,178k | 303,216k | p=0.005 n=6 |
| Parse Time | 1.99s (± 0.49%) | 2.01s (± 0.93%) | +0.02s (+ 0.92%) | 1.97s | 2.02s | p=0.048 n=6 |
| Bind Time | 1.01s (± 1.32%) | 1.01s (± 1.20%) | ~ | 1.00s | 1.03s | p=0.931 n=6 |
| Check Time | 6.30s (± 0.50%) | 6.40s (± 0.18%) | +0.09s (+ 1.51%) | 6.39s | 6.42s | p=0.005 n=6 |
| Emit Time | 3.57s (± 0.27%) | 3.59s (± 0.49%) | ~ | 3.57s | 3.62s | p=0.103 n=6 |
| Total Time | 12.87s (± 0.28%) | 12.99s (± 0.27%) | +0.13s (+ 0.97%) | 12.95s | 13.05s | p=0.005 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 506,806k (± 0.00%) | 507,390k (± 0.00%) | +584k (+ 0.12%) | 507,355k | 507,430k | p=0.005 n=6 |
| Parse Time | 2.58s (± 0.20%) | 2.59s (± 0.68%) | ~ | 2.56s | 2.61s | p=0.667 n=6 |
| Bind Time | 0.99s (± 1.52%) | 0.99s (± 1.04%) | ~ | 0.98s | 1.01s | p=0.323 n=6 |
| Check Time | 16.98s (± 0.31%) | 17.00s (± 0.27%) | ~ | 16.96s | 17.09s | p=0.369 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.55s (± 0.26%) | 20.58s (± 0.26%) | ~ | 20.53s | 20.68s | p=0.125 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 512,888k (± 0.01%) | 0k | ~ | 0k | 0k | p=1.000 n=6+0 |
| Parse Time | 3.28s (± 0.23%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Bind Time | 1.54s (± 0.41%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Check Time | 2.84s (± 0.26%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Emit Time | 0.07s (± 0.00%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
| Total Time | 7.74s (± 0.15%) | 0.00s | ~ | 0.00s | 0.00s | p=1.000 n=6+0 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
tsserver
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-UnionsTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,356ms (± 0.83%) | 2,373ms (± 0.60%) | ~ | 2,354ms | 2,387ms | p=0.109 n=6 |
| Req 2 - geterr | 5,469ms (± 1.34%) | 5,541ms (± 1.46%) | ~ | 5,470ms | 5,647ms | p=0.471 n=6 |
| Req 3 - references | 327ms (± 0.50%) | 323ms (± 0.51%) | -4ms (- 1.17%) | 320ms | 324ms | p=0.009 n=6 |
| Req 4 - navto | 276ms (± 1.20%) | 270ms (± 1.02%) | -6ms (- 2.11%) | 267ms | 275ms | p=0.023 n=6 |
| Req 5 - completionInfo count | 1,356 (± 0.00%) | 1,356 (± 0.00%) | ~ | 1,356 | 1,356 | p=1.000 n=6 |
| Req 5 - completionInfo | 90ms (± 4.44%) | 90ms (± 5.04%) | ~ | 83ms | 94ms | p=0.683 n=6 |
| CompilerTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,480ms (± 0.64%) | 2,512ms (± 0.48%) | +32ms (+ 1.30%) | 2,497ms | 2,524ms | p=0.010 n=6 |
| Req 2 - geterr | 4,138ms (± 1.78%) | 4,297ms (± 1.72%) | +160ms (+ 3.86%) | 4,189ms | 4,353ms | p=0.031 n=6 |
| Req 3 - references | 340ms (± 1.03%) | 337ms (± 0.95%) | -3ms (- 0.98%) | 335ms | 343ms | p=0.033 n=6 |
| Req 4 - navto | 285ms (± 0.29%) | 278ms (± 1.67%) | -7ms (- 2.46%) | 272ms | 282ms | p=0.004 n=6 |
| Req 5 - completionInfo count | 1,518 (± 0.00%) | 1,518 (± 0.00%) | ~ | 1,518 | 1,518 | p=1.000 n=6 |
| Req 5 - completionInfo | 84ms (± 6.21%) | 80ms (± 6.78%) | ~ | 76ms | 89ms | p=0.104 n=6 |
| xstateTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,615ms (± 0.20%) | 2,601ms (± 0.46%) | -14ms (- 0.54%) | 2,586ms | 2,617ms | p=0.025 n=6 |
| Req 2 - geterr | 1,732ms (± 0.81%) | 893ms (± 2.54%) | 🟩-839ms (-48.44%) | 866ms | 921ms | p=0.005 n=6 |
| Req 3 - references | 114ms (± 8.97%) | 145ms (±11.56%) | 🔻+31ms (+26.97%) | 120ms | 165ms | p=0.020 n=6 |
| Req 4 - navto | 365ms (± 0.41%) | 365ms (± 0.32%) | ~ | 364ms | 367ms | p=0.554 n=6 |
| Req 5 - completionInfo count | 2,073 (± 0.00%) | 2,073 (± 0.00%) | ~ | 2,073 | 2,073 | p=1.000 n=6 |
| Req 5 - completionInfo | 312ms (± 0.96%) | 305ms (± 1.33%) | -7ms (- 2.29%) | 299ms | 308ms | p=0.023 n=6 |
- node (v18.15.0, x64)
- CompilerTSServer - node (v18.15.0, x64)
- Compiler-UnionsTSServer - node (v18.15.0, x64)
- xstateTSServer - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Startup
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| tsc-startup - node (v18.15.0, x64) | ||||||
| Execution time | 153.10ms (± 0.20%) | 153.42ms (± 0.20%) | +0.32ms (+ 0.21%) | 152.11ms | 158.32ms | p=0.000 n=600 |
| tsserver-startup - node (v18.15.0, x64) | ||||||
| Execution time | 228.58ms (± 0.15%) | 228.84ms (± 0.15%) | +0.26ms (+ 0.12%) | 227.55ms | 232.32ms | p=0.000 n=600 |
| tsserverlibrary-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.09ms (± 0.19%) | 230.44ms (± 0.26%) | +0.35ms (+ 0.15%) | 228.76ms | 250.87ms | p=0.000 n=600 |
| typescript-startup - node (v18.15.0, x64) | ||||||
| Execution time | 229.93ms (± 0.19%) | 229.95ms (± 0.16%) | ~ | 228.30ms | 232.92ms | p=0.136 n=600 |
- node (v18.15.0, x64)
- tsc-startup - node (v18.15.0, x64)
- tsserver-startup - node (v18.15.0, x64)
- tsserverlibrary-startup - node (v18.15.0, x64)
- typescript-startup - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test this
Heya @gabritto, I've started to run the regular perf test suite on this PR at b9f9f4cecc4896129d96b58c7c9c27e0be3cc139. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
Compiler
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,467k (± 0.01%) | 295,769k (± 0.01%) | +302k (+ 0.10%) | 295,734k | 295,812k | p=0.005 n=6 |
| Parse Time | 2.65s (± 0.15%) | 2.65s (± 0.00%) | ~ | 2.65s | 2.65s | p=0.405 n=6 |
| Bind Time | 0.82s (± 0.00%) | 0.84s (± 0.97%) | +0.02s (+ 2.03%) | 0.83s | 0.85s | p=0.003 n=6 |
| Check Time | 8.16s (± 0.25%) | 8.24s (± 0.44%) | +0.08s (+ 0.98%) | 8.19s | 8.30s | p=0.006 n=6 |
| Emit Time | 7.10s (± 0.29%) | 7.16s (± 0.14%) | +0.05s (+ 0.75%) | 7.14s | 7.17s | p=0.005 n=6 |
| Total Time | 18.73s (± 0.09%) | 18.88s (± 0.22%) | +0.15s (+ 0.81%) | 18.82s | 18.95s | p=0.005 n=6 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 193,428k (± 1.54%) | 193,058k (± 1.23%) | ~ | 191,644k | 197,433k | p=0.230 n=6 |
| Parse Time | 1.36s (± 1.18%) | 1.35s (± 1.01%) | ~ | 1.32s | 1.36s | p=0.340 n=6 |
| Bind Time | 0.72s (± 0.57%) | 0.76s (± 0.99%) | 🔻+0.04s (+ 5.08%) | 0.75s | 0.77s | p=0.003 n=6 |
| Check Time | 9.25s (± 0.31%) | 9.32s (± 0.35%) | +0.07s (+ 0.76%) | 9.28s | 9.36s | p=0.010 n=6 |
| Emit Time | 2.61s (± 0.67%) | 2.63s (± 0.90%) | ~ | 2.60s | 2.67s | p=0.251 n=6 |
| Total Time | 13.94s (± 0.22%) | 14.05s (± 0.19%) | +0.11s (+ 0.81%) | 14.02s | 14.10s | p=0.005 n=6 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,401k (± 0.00%) | 348,377k (± 0.01%) | +976k (+ 0.28%) | 348,350k | 348,405k | p=0.005 n=6 |
| Parse Time | 2.46s (± 0.49%) | 2.46s (± 0.26%) | ~ | 2.45s | 2.47s | p=0.673 n=6 |
| Bind Time | 0.93s (± 0.44%) | 0.93s (± 0.44%) | ~ | 0.93s | 0.94s | p=0.218 n=6 |
| Check Time | 6.87s (± 0.20%) | 6.93s (± 0.59%) | +0.05s (+ 0.80%) | 6.89s | 6.99s | p=0.006 n=6 |
| Emit Time | 4.05s (± 0.33%) | 4.05s (± 0.20%) | ~ | 4.04s | 4.06s | p=0.402 n=6 |
| Total Time | 14.30s (± 0.11%) | 14.38s (± 0.29%) | +0.07s (+ 0.50%) | 14.34s | 14.43s | p=0.004 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,732k (± 0.01%) | 303,144k (± 0.01%) | +412k (+ 0.14%) | 303,113k | 303,177k | p=0.005 n=6 |
| Parse Time | 2.01s (± 0.63%) | 2.00s (± 0.88%) | ~ | 1.98s | 2.03s | p=0.162 n=6 |
| Bind Time | 1.00s (± 0.41%) | 1.00s (± 0.83%) | ~ | 1.00s | 1.02s | p=0.527 n=6 |
| Check Time | 6.29s (± 0.35%) | 6.32s (± 0.22%) | +0.03s (+ 0.50%) | 6.30s | 6.34s | p=0.019 n=6 |
| Emit Time | 3.57s (± 0.52%) | 3.60s (± 0.45%) | +0.03s (+ 0.84%) | 3.58s | 3.62s | p=0.023 n=6 |
| Total Time | 12.87s (± 0.25%) | 12.92s (± 0.24%) | +0.05s (+ 0.40%) | 12.88s | 12.96s | p=0.019 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 506,828k (± 0.01%) | 507,372k (± 0.00%) | +543k (+ 0.11%) | 507,341k | 507,390k | p=0.005 n=6 |
| Parse Time | 2.58s (± 0.45%) | 2.58s (± 0.32%) | ~ | 2.57s | 2.59s | p=0.315 n=6 |
| Bind Time | 0.98s (± 0.85%) | 0.99s (± 1.22%) | ~ | 0.98s | 1.01s | p=0.227 n=6 |
| Check Time | 16.93s (± 0.28%) | 17.00s (± 0.38%) | +0.07s (+ 0.41%) | 16.92s | 17.11s | p=0.043 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.49s (± 0.29%) | 20.57s (± 0.39%) | ~ | 20.47s | 20.70s | p=0.065 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 512,875k (± 0.01%) | 512,960k (± 0.02%) | ~ | 512,822k | 513,066k | p=0.065 n=6 |
| Parse Time | 3.27s (± 0.23%) | 3.27s (± 0.25%) | ~ | 3.26s | 3.28s | p=0.729 n=6 |
| Bind Time | 1.54s (± 0.53%) | 1.54s (± 0.41%) | ~ | 1.53s | 1.55s | p=0.432 n=6 |
| Check Time | 2.83s (± 0.43%) | 2.83s (± 0.62%) | ~ | 2.81s | 2.86s | p=0.332 n=6 |
| Emit Time | 0.07s (± 0.00%) | 0.07s (± 0.00%) | ~ | 0.07s | 0.07s | p=1.000 n=6 |
| Total Time | 7.71s (± 0.30%) | 7.72s (± 0.30%) | ~ | 7.70s | 7.76s | p=0.259 n=6 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
tsserver
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-UnionsTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,343ms (± 0.87%) | 2,377ms (± 0.59%) | +33ms (+ 1.42%) | 2,362ms | 2,401ms | p=0.045 n=6 |
| Req 2 - geterr | 5,418ms (± 1.53%) | 5,484ms (± 1.20%) | ~ | 5,408ms | 5,576ms | p=0.173 n=6 |
| Req 3 - references | 324ms (± 1.35%) | 326ms (± 0.43%) | ~ | 324ms | 328ms | p=0.258 n=6 |
| Req 4 - navto | 276ms (± 1.14%) | 270ms (± 1.19%) | -6ms (- 2.12%) | 267ms | 275ms | p=0.024 n=6 |
| Req 5 - completionInfo count | 1,356 (± 0.00%) | 1,356 (± 0.00%) | ~ | 1,356 | 1,356 | p=1.000 n=6 |
| Req 5 - completionInfo | 89ms (± 6.24%) | 92ms (± 3.25%) | ~ | 90ms | 96ms | p=0.373 n=6 |
| CompilerTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,493ms (± 1.33%) | 2,505ms (± 0.48%) | ~ | 2,492ms | 2,528ms | p=0.422 n=6 |
| Req 2 - geterr | 4,133ms (± 1.86%) | 4,205ms (± 1.80%) | ~ | 4,139ms | 4,307ms | p=0.128 n=6 |
| Req 3 - references | 338ms (± 1.36%) | 336ms (± 1.41%) | ~ | 331ms | 343ms | p=0.373 n=6 |
| Req 4 - navto | 285ms (± 0.29%) | 276ms (± 0.27%) | -8ms (- 2.93%) | 275ms | 277ms | p=0.004 n=6 |
| Req 5 - completionInfo count | 1,518 (± 0.00%) | 1,518 (± 0.00%) | ~ | 1,518 | 1,518 | p=1.000 n=6 |
| Req 5 - completionInfo | 85ms (± 6.61%) | 86ms (± 7.67%) | ~ | 77ms | 91ms | p=0.797 n=6 |
| xstateTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,599ms (± 0.81%) | 2,601ms (± 0.42%) | ~ | 2,587ms | 2,615ms | p=0.936 n=6 |
| Req 2 - geterr | 1,716ms (± 2.33%) | 1,720ms (± 2.33%) | ~ | 1,645ms | 1,754ms | p=1.000 n=6 |
| Req 3 - references | 118ms (± 6.60%) | 110ms (± 8.12%) | ~ | 101ms | 122ms | p=0.077 n=6 |
| Req 4 - navto | 364ms (± 1.09%) | 365ms (± 0.24%) | ~ | 364ms | 366ms | p=1.000 n=6 |
| Req 5 - completionInfo count | 2,073 (± 0.00%) | 2,073 (± 0.00%) | ~ | 2,073 | 2,073 | p=1.000 n=6 |
| Req 5 - completionInfo | 308ms (± 1.24%) | 309ms (± 1.87%) | ~ | 302ms | 318ms | p=0.871 n=6 |
- node (v18.15.0, x64)
- CompilerTSServer - node (v18.15.0, x64)
- Compiler-UnionsTSServer - node (v18.15.0, x64)
- xstateTSServer - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Startup
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| tsc-startup - node (v18.15.0, x64) | ||||||
| Execution time | 153.25ms (± 0.21%) | 153.67ms (± 0.19%) | +0.42ms (+ 0.27%) | 152.49ms | 156.54ms | p=0.000 n=600 |
| tsserver-startup - node (v18.15.0, x64) | ||||||
| Execution time | 228.40ms (± 0.18%) | 228.53ms (± 0.16%) | +0.13ms (+ 0.06%) | 227.30ms | 234.40ms | p=0.000 n=600 |
| tsserverlibrary-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.75ms (± 0.19%) | 230.97ms (± 0.17%) | +0.23ms (+ 0.10%) | 229.12ms | 233.78ms | p=0.000 n=600 |
| typescript-startup - node (v18.15.0, x64) | ||||||
| Execution time | 229.88ms (± 0.18%) | 229.89ms (± 0.18%) | ~ | 228.16ms | 236.15ms | p=0.560 n=600 |
- node (v18.15.0, x64)
- tsc-startup - node (v18.15.0, x64)
- tsserver-startup - node (v18.15.0, x64)
- tsserverlibrary-startup - node (v18.15.0, x64)
- typescript-startup - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test this
Heya @gabritto, I've started to run the regular perf test suite on this PR at b9f9f4cecc4896129d96b58c7c9c27e0be3cc139. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
Compiler
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,440k (± 0.01%) | 295,757k (± 0.00%) | +316k (+ 0.11%) | 295,747k | 295,771k | p=0.005 n=6 |
| Parse Time | 2.65s (± 0.15%) | 2.65s (± 0.34%) | ~ | 2.64s | 2.66s | p=0.787 n=6 |
| Bind Time | 0.82s (± 0.00%) | 0.84s (± 0.97%) | +0.02s (+ 2.03%) | 0.83s | 0.85s | p=0.003 n=6 |
| Check Time | 8.14s (± 0.23%) | 8.24s (± 0.37%) | +0.10s (+ 1.19%) | 8.20s | 8.28s | p=0.005 n=6 |
| Emit Time | 7.10s (± 0.13%) | 7.16s (± 0.19%) | +0.05s (+ 0.77%) | 7.14s | 7.18s | p=0.005 n=6 |
| Total Time | 18.71s (± 0.11%) | 18.88s (± 0.17%) | +0.18s (+ 0.94%) | 18.85s | 18.93s | p=0.005 n=6 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 193,458k (± 1.54%) | 192,659k (± 1.23%) | ~ | 191,676k | 197,488k | p=0.229 n=6 |
| Parse Time | 1.36s (± 0.93%) | 1.35s (± 0.94%) | ~ | 1.34s | 1.37s | p=0.187 n=6 |
| Bind Time | 0.72s (± 0.00%) | 0.76s (± 0.00%) | 🔻+0.04s (+ 5.56%) | 0.76s | 0.76s | p=0.001 n=6 |
| Check Time | 9.24s (± 0.22%) | 9.32s (± 0.27%) | +0.08s (+ 0.85%) | 9.28s | 9.35s | p=0.005 n=6 |
| Emit Time | 2.61s (± 0.54%) | 2.61s (± 0.62%) | ~ | 2.59s | 2.63s | p=0.744 n=6 |
| Total Time | 13.93s (± 0.14%) | 14.04s (± 0.32%) | +0.11s (+ 0.80%) | 13.97s | 14.08s | p=0.005 n=6 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,402k (± 0.00%) | 348,389k (± 0.01%) | +986k (+ 0.28%) | 348,362k | 348,415k | p=0.005 n=6 |
| Parse Time | 2.46s (± 0.21%) | 2.47s (± 0.50%) | ~ | 2.45s | 2.48s | p=0.210 n=6 |
| Bind Time | 0.92s (± 0.56%) | 0.93s (± 0.00%) | +0.01s (+ 0.72%) | 0.93s | 0.93s | p=0.025 n=6 |
| Check Time | 6.89s (± 0.61%) | 6.93s (± 0.35%) | ~ | 6.91s | 6.98s | p=0.106 n=6 |
| Emit Time | 4.04s (± 0.26%) | 4.06s (± 0.34%) | +0.02s (+ 0.54%) | 4.05s | 4.08s | p=0.022 n=6 |
| Total Time | 14.32s (± 0.28%) | 14.40s (± 0.22%) | +0.08s (+ 0.56%) | 14.35s | 14.44s | p=0.010 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,729k (± 0.01%) | 303,141k (± 0.01%) | +412k (+ 0.14%) | 303,110k | 303,155k | p=0.005 n=6 |
| Parse Time | 2.00s (± 0.80%) | 2.00s (± 0.93%) | ~ | 1.98s | 2.03s | p=0.621 n=6 |
| Bind Time | 1.00s (± 1.36%) | 1.00s (± 2.75%) | ~ | 0.95s | 1.03s | p=0.801 n=6 |
| Check Time | 6.30s (± 0.19%) | 6.33s (± 0.49%) | ~ | 6.29s | 6.37s | p=0.072 n=6 |
| Emit Time | 3.59s (± 0.49%) | 3.60s (± 0.32%) | ~ | 3.59s | 3.62s | p=0.142 n=6 |
| Total Time | 12.89s (± 0.27%) | 12.93s (± 0.34%) | ~ | 12.88s | 12.99s | p=0.104 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 506,834k (± 0.00%) | 507,377k (± 0.00%) | +543k (+ 0.11%) | 507,353k | 507,403k | p=0.005 n=6 |
| Parse Time | 2.59s (± 0.58%) | 2.58s (± 0.47%) | ~ | 2.57s | 2.60s | p=0.805 n=6 |
| Bind Time | 0.99s (± 0.76%) | 1.00s (± 1.04%) | ~ | 0.98s | 1.01s | p=0.351 n=6 |
| Check Time | 17.00s (± 0.43%) | 17.00s (± 0.19%) | ~ | 16.96s | 17.04s | p=0.809 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.58s (± 0.35%) | 20.58s (± 0.15%) | ~ | 20.55s | 20.62s | p=0.627 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 512,902k (± 0.01%) | 512,976k (± 0.01%) | ~ | 512,890k | 513,077k | p=0.066 n=6 |
| Parse Time | 3.28s (± 0.16%) | 3.28s (± 0.17%) | ~ | 3.27s | 3.28s | p=0.640 n=6 |
| Bind Time | 1.54s (± 0.27%) | 1.54s (± 0.34%) | ~ | 1.53s | 1.54s | p=0.595 n=6 |
| Check Time | 2.83s (± 0.84%) | 2.84s (± 0.43%) | ~ | 2.81s | 2.84s | p=0.683 n=6 |
| Emit Time | 0.07s (± 5.69%) | 0.07s (± 5.69%) | ~ | 0.07s | 0.08s | p=1.000 n=6 |
| Total Time | 7.72s (± 0.33%) | 7.72s (± 0.16%) | ~ | 7.70s | 7.74s | p=0.935 n=6 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
tsserver
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-UnionsTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,342ms (± 0.64%) | 2,377ms (± 0.63%) | +35ms (+ 1.48%) | 2,353ms | 2,395ms | p=0.008 n=6 |
| Req 2 - geterr | 5,448ms (± 1.33%) | 5,458ms (± 1.03%) | ~ | 5,418ms | 5,568ms | p=0.689 n=6 |
| Req 3 - references | 326ms (± 1.35%) | 326ms (± 1.15%) | ~ | 322ms | 332ms | p=0.871 n=6 |
| Req 4 - navto | 274ms (± 1.34%) | 269ms (± 0.96%) | ~ | 265ms | 272ms | p=0.056 n=6 |
| Req 5 - completionInfo count | 1,356 (± 0.00%) | 1,356 (± 0.00%) | ~ | 1,356 | 1,356 | p=1.000 n=6 |
| Req 5 - completionInfo | 92ms (± 4.50%) | 89ms (± 5.55%) | ~ | 85ms | 96ms | p=0.625 n=6 |
| CompilerTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,472ms (± 0.70%) | 2,519ms (± 0.63%) | +47ms (+ 1.90%) | 2,498ms | 2,543ms | p=0.005 n=6 |
| Req 2 - geterr | 4,184ms (± 1.88%) | 4,205ms (± 1.73%) | ~ | 4,153ms | 4,301ms | p=0.810 n=6 |
| Req 3 - references | 335ms (± 1.33%) | 336ms (± 1.54%) | ~ | 331ms | 343ms | p=0.809 n=6 |
| Req 4 - navto | 288ms (± 1.56%) | 277ms (± 0.29%) | 🟩-11ms (- 3.82%) | 275ms | 277ms | p=0.004 n=6 |
| Req 5 - completionInfo count | 1,518 (± 0.00%) | 1,518 (± 0.00%) | ~ | 1,518 | 1,518 | p=1.000 n=6 |
| Req 5 - completionInfo | 82ms (± 6.22%) | 86ms (± 7.52%) | ~ | 77ms | 90ms | p=0.451 n=6 |
| xstateTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,600ms (± 0.68%) | 2,602ms (± 0.81%) | ~ | 2,565ms | 2,628ms | p=0.810 n=6 |
| Req 2 - geterr | 1,718ms (± 2.14%) | 1,717ms (± 2.63%) | ~ | 1,641ms | 1,762ms | p=1.000 n=6 |
| Req 3 - references | 112ms (± 9.65%) | 109ms (±10.11%) | ~ | 101ms | 124ms | p=0.517 n=6 |
| Req 4 - navto | 365ms (± 0.17%) | 365ms (± 0.67%) | ~ | 360ms | 367ms | p=1.000 n=6 |
| Req 5 - completionInfo count | 2,073 (± 0.00%) | 2,073 (± 0.00%) | ~ | 2,073 | 2,073 | p=1.000 n=6 |
| Req 5 - completionInfo | 311ms (± 1.02%) | 307ms (± 2.51%) | ~ | 296ms | 316ms | p=0.517 n=6 |
- node (v18.15.0, x64)
- CompilerTSServer - node (v18.15.0, x64)
- Compiler-UnionsTSServer - node (v18.15.0, x64)
- xstateTSServer - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Startup
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| tsc-startup - node (v18.15.0, x64) | ||||||
| Execution time | 153.71ms (± 0.19%) | 153.96ms (± 0.21%) | +0.25ms (+ 0.16%) | 152.82ms | 158.43ms | p=0.000 n=600 |
| tsserver-startup - node (v18.15.0, x64) | ||||||
| Execution time | 229.04ms (± 0.16%) | 229.14ms (± 0.15%) | +0.10ms (+ 0.04%) | 227.86ms | 232.55ms | p=0.000 n=600 |
| tsserverlibrary-startup - node (v18.15.0, x64) | ||||||
| Execution time | 229.81ms (± 0.21%) | 230.34ms (± 0.19%) | +0.53ms (+ 0.23%) | 228.55ms | 236.86ms | p=0.000 n=600 |
| typescript-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.06ms (± 0.19%) | 230.13ms (± 0.20%) | ~ | 228.43ms | 237.22ms | p=0.166 n=600 |
- node (v18.15.0, x64)
- tsc-startup - node (v18.15.0, x64)
- tsserver-startup - node (v18.15.0, x64)
- tsserverlibrary-startup - node (v18.15.0, x64)
- typescript-startup - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test this
Heya @gabritto, I've started to run the regular perf test suite on this PR at f067878fb75724972fe8693ef622679dde55a0f4. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
Compiler
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,486k (± 0.01%) | 295,728k (± 0.01%) | +242k (+ 0.08%) | 295,705k | 295,751k | p=0.005 n=6 |
| Parse Time | 2.65s (± 0.00%) | 2.65s (± 0.24%) | ~ | 2.64s | 2.66s | p=1.000 n=6 |
| Bind Time | 0.82s (± 0.99%) | 0.83s (± 0.62%) | +0.01s (+ 1.21%) | 0.83s | 0.84s | p=0.033 n=6 |
| Check Time | 8.15s (± 0.30%) | 8.24s (± 0.26%) | +0.09s (+ 1.15%) | 8.22s | 8.27s | p=0.005 n=6 |
| Emit Time | 7.11s (± 0.11%) | 7.17s (± 0.38%) | +0.06s (+ 0.82%) | 7.13s | 7.20s | p=0.005 n=6 |
| Total Time | 18.72s (± 0.14%) | 18.88s (± 0.19%) | +0.16s (+ 0.87%) | 18.83s | 18.92s | p=0.005 n=6 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 191,503k (± 0.03%) | 191,667k (± 0.02%) | +164k (+ 0.09%) | 191,613k | 191,692k | p=0.005 n=6 |
| Parse Time | 1.35s (± 0.61%) | 1.35s (± 0.00%) | ~ | 1.35s | 1.35s | p=0.405 n=6 |
| Bind Time | 0.72s (± 0.00%) | 0.76s (± 0.00%) | 🔻+0.04s (+ 5.56%) | 0.76s | 0.76s | p=0.001 n=6 |
| Check Time | 9.28s (± 0.39%) | 9.30s (± 0.14%) | ~ | 9.28s | 9.31s | p=0.460 n=6 |
| Emit Time | 2.61s (± 0.56%) | 2.62s (± 0.62%) | ~ | 2.60s | 2.65s | p=0.162 n=6 |
| Total Time | 13.96s (± 0.33%) | 14.03s (± 0.18%) | +0.07s (+ 0.51%) | 14.00s | 14.07s | p=0.016 n=6 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,398k (± 0.01%) | 348,386k (± 0.01%) | +988k (+ 0.28%) | 348,357k | 348,406k | p=0.005 n=6 |
| Parse Time | 2.47s (± 0.33%) | 2.46s (± 0.43%) | ~ | 2.44s | 2.47s | p=0.078 n=6 |
| Bind Time | 0.93s (± 0.00%) | 0.93s (± 0.59%) | ~ | 0.93s | 0.94s | p=0.071 n=6 |
| Check Time | 6.86s (± 0.40%) | 6.94s (± 0.49%) | +0.07s (+ 1.07%) | 6.91s | 7.00s | p=0.005 n=6 |
| Emit Time | 4.06s (± 0.19%) | 4.06s (± 0.19%) | ~ | 4.05s | 4.07s | p=0.487 n=6 |
| Total Time | 14.32s (± 0.23%) | 14.39s (± 0.23%) | +0.07s (+ 0.49%) | 14.35s | 14.44s | p=0.008 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,742k (± 0.01%) | 303,142k (± 0.01%) | +401k (+ 0.13%) | 303,117k | 303,167k | p=0.005 n=6 |
| Parse Time | 2.00s (± 1.17%) | 2.00s (± 0.69%) | ~ | 1.99s | 2.02s | p=1.000 n=6 |
| Bind Time | 1.00s (± 0.00%) | 1.01s (± 1.03%) | +0.01s (+ 1.50%) | 1.00s | 1.03s | p=0.009 n=6 |
| Check Time | 6.28s (± 0.27%) | 6.32s (± 0.31%) | +0.04s (+ 0.66%) | 6.30s | 6.35s | p=0.006 n=6 |
| Emit Time | 3.59s (± 0.65%) | 3.59s (± 0.69%) | ~ | 3.57s | 3.64s | p=0.808 n=6 |
| Total Time | 12.87s (± 0.19%) | 12.94s (± 0.26%) | +0.07s (+ 0.53%) | 12.91s | 13.00s | p=0.008 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 506,829k (± 0.00%) | 507,385k (± 0.00%) | +556k (+ 0.11%) | 507,364k | 507,400k | p=0.005 n=6 |
| Parse Time | 2.58s (± 0.51%) | 2.59s (± 0.87%) | ~ | 2.57s | 2.62s | p=0.803 n=6 |
| Bind Time | 0.99s (± 1.18%) | 0.99s (± 1.96%) | ~ | 0.96s | 1.01s | p=0.870 n=6 |
| Check Time | 16.94s (± 0.37%) | 17.03s (± 0.28%) | +0.09s (+ 0.54%) | 16.96s | 17.09s | p=0.020 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.51s (± 0.25%) | 20.61s (± 0.22%) | +0.10s (+ 0.49%) | 20.53s | 20.65s | p=0.020 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 512,862k (± 0.01%) | 512,952k (± 0.02%) | ~ | 512,830k | 513,081k | p=0.128 n=6 |
| Parse Time | 3.27s (± 0.41%) | 3.28s (± 0.16%) | ~ | 3.27s | 3.28s | p=0.774 n=6 |
| Bind Time | 1.54s (± 0.36%) | 1.54s (± 0.54%) | ~ | 1.52s | 1.54s | p=0.855 n=6 |
| Check Time | 2.83s (± 0.59%) | 2.85s (± 0.53%) | ~ | 2.83s | 2.87s | p=0.059 n=6 |
| Emit Time | 0.07s (± 0.00%) | 0.07s (± 0.00%) | ~ | 0.07s | 0.07s | p=1.000 n=6 |
| Total Time | 7.71s (± 0.30%) | 7.73s (± 0.23%) | ~ | 7.70s | 7.75s | p=0.197 n=6 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
tsserver
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-UnionsTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,347ms (± 0.45%) | 2,371ms (± 0.60%) | +24ms (+ 1.02%) | 2,357ms | 2,392ms | p=0.013 n=6 |
| Req 2 - geterr | 5,393ms (± 1.07%) | 5,527ms (± 1.21%) | +133ms (+ 2.47%) | 5,433ms | 5,592ms | p=0.013 n=6 |
| Req 3 - references | 323ms (± 1.36%) | 327ms (± 1.13%) | ~ | 323ms | 332ms | p=0.125 n=6 |
| Req 4 - navto | 277ms (± 0.91%) | 267ms (± 1.18%) | 🟩-10ms (- 3.73%) | 264ms | 272ms | p=0.006 n=6 |
| Req 5 - completionInfo count | 1,356 (± 0.00%) | 1,356 (± 0.00%) | ~ | 1,356 | 1,356 | p=1.000 n=6 |
| Req 5 - completionInfo | 85ms (± 4.42%) | 91ms (± 4.30%) | 🔻+6ms (+ 7.03%) | 84ms | 95ms | p=0.042 n=6 |
| CompilerTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,492ms (± 1.33%) | 2,511ms (± 0.32%) | ~ | 2,498ms | 2,520ms | p=0.298 n=6 |
| Req 2 - geterr | 4,136ms (± 1.84%) | 4,260ms (± 1.75%) | +124ms (+ 2.99%) | 4,156ms | 4,321ms | p=0.030 n=6 |
| Req 3 - references | 340ms (± 1.17%) | 337ms (± 1.53%) | ~ | 332ms | 343ms | p=0.466 n=6 |
| Req 4 - navto | 285ms (± 1.01%) | 275ms (± 0.48%) | 🟩-10ms (- 3.56%) | 273ms | 277ms | p=0.005 n=6 |
| Req 5 - completionInfo count | 1,518 (± 0.00%) | 1,518 (± 0.00%) | ~ | 1,518 | 1,518 | p=1.000 n=6 |
| Req 5 - completionInfo | 86ms (± 5.36%) | 84ms (± 7.81%) | ~ | 78ms | 91ms | p=1.000 n=6 |
| xstateTSServer - node (v18.15.0, x64) | ||||||
| Req 1 - updateOpen | 2,602ms (± 0.34%) | 2,609ms (± 0.20%) | ~ | 2,602ms | 2,617ms | p=0.172 n=6 |
| Req 2 - geterr | 1,720ms (± 2.54%) | 1,693ms (± 2.00%) | ~ | 1,644ms | 1,732ms | p=0.378 n=6 |
| Req 3 - references | 116ms (± 9.28%) | 110ms (± 8.51%) | ~ | 103ms | 122ms | p=0.517 n=6 |
| Req 4 - navto | 365ms (± 0.14%) | 365ms (± 0.32%) | ~ | 364ms | 367ms | p=0.666 n=6 |
| Req 5 - completionInfo count | 2,073 (± 0.00%) | 2,073 (± 0.00%) | ~ | 2,073 | 2,073 | p=1.000 n=6 |
| Req 5 - completionInfo | 307ms (± 2.01%) | 307ms (± 1.44%) | ~ | 303ms | 315ms | p=0.687 n=6 |
- node (v18.15.0, x64)
- CompilerTSServer - node (v18.15.0, x64)
- Compiler-UnionsTSServer - node (v18.15.0, x64)
- xstateTSServer - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Startup
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| tsc-startup - node (v18.15.0, x64) | ||||||
| Execution time | 153.61ms (± 0.20%) | 153.98ms (± 0.20%) | +0.37ms (+ 0.24%) | 152.90ms | 157.84ms | p=0.000 n=600 |
| tsserver-startup - node (v18.15.0, x64) | ||||||
| Execution time | 228.38ms (± 0.14%) | 228.59ms (± 0.16%) | +0.21ms (+ 0.09%) | 227.40ms | 232.56ms | p=0.000 n=600 |
| tsserverlibrary-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.69ms (± 0.20%) | 230.97ms (± 0.18%) | +0.27ms (+ 0.12%) | 229.25ms | 238.59ms | p=0.000 n=600 |
| typescript-startup - node (v18.15.0, x64) | ||||||
| Execution time | 230.15ms (± 0.19%) | 230.36ms (± 0.17%) | +0.20ms (+ 0.09%) | 228.77ms | 235.17ms | p=0.000 n=600 |
- node (v18.15.0, x64)
- tsc-startup - node (v18.15.0, x64)
- tsserver-startup - node (v18.15.0, x64)
- tsserverlibrary-startup - node (v18.15.0, x64)
- typescript-startup - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test public
Heya @gabritto, I've started to run the public perf test suite on this PR at 45772c7eaae5a9fad8ba025c8c8f52c9aa92f33b. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| self-build-src - node (v20.5.1, x64) | ||||||
| Memory used | 2,573,776k (± 0.02%) | 2,657,691k (± 7.61%) | +83,916k (+ 3.26%) | 2,574,293k | 3,070,937k | p=0.008 n=6 |
| Parse Time | 5.00s (± 1.41%) | 5.06s (± 0.68%) | ~ | 5.01s | 5.10s | p=0.093 n=6 |
| Bind Time | 2.00s (± 0.84%) | 2.16s (± 0.91%) | 🔻+0.16s (+ 7.83%) | 2.14s | 2.19s | p=0.005 n=6 |
| Check Time | 32.12s (± 0.25%) | 32.55s (± 0.46%) | +0.43s (+ 1.33%) | 32.25s | 32.66s | p=0.005 n=6 |
| Emit Time | 2.85s (± 3.21%) | 2.78s (± 3.43%) | ~ | 2.67s | 2.88s | p=0.199 n=6 |
| Total Time | 41.98s (± 0.20%) | 42.56s (± 0.58%) | +0.58s (+ 1.39%) | 42.13s | 42.83s | p=0.005 n=6 |
| self-compiler - node (v20.5.1, x64) | ||||||
| Memory used | 418,717k (± 0.03%) | 419,928k (± 0.01%) | +1,211k (+ 0.29%) | 419,896k | 419,959k | p=0.005 n=6 |
| Parse Time | 2.88s (± 0.44%) | 2.89s (± 0.26%) | ~ | 2.88s | 2.90s | p=0.115 n=6 |
| Bind Time | 1.14s (± 0.74%) | 1.18s (± 0.44%) | +0.04s (+ 3.67%) | 1.17s | 1.18s | p=0.004 n=6 |
| Check Time | 14.08s (± 0.19%) | 14.36s (± 0.24%) | +0.27s (+ 1.93%) | 14.29s | 14.38s | p=0.005 n=6 |
| Emit Time | 1.05s (± 0.78%) | 1.05s (± 0.99%) | ~ | 1.04s | 1.06s | p=0.928 n=6 |
| Total Time | 19.14s (± 0.16%) | 19.47s (± 0.16%) | +0.32s (+ 1.70%) | 19.41s | 19.50s | p=0.005 n=6 |
| vscode - node (v20.5.1, x64) | ||||||
| Memory used | 2,827,954k (± 0.00%) | 2,830,890k (± 0.00%) | +2,936k (+ 0.10%) | 2,830,862k | 2,830,925k | p=0.005 n=6 |
| Parse Time | 10.73s (± 0.18%) | 10.73s (± 0.29%) | ~ | 10.67s | 10.76s | p=1.000 n=6 |
| Bind Time | 3.42s (± 0.31%) | 3.46s (± 0.60%) | +0.04s (+ 1.17%) | 3.44s | 3.49s | p=0.006 n=6 |
| Check Time | 56.02s (± 0.18%) | 56.41s (± 0.39%) | +0.39s (+ 0.70%) | 56.13s | 56.73s | p=0.008 n=6 |
| Emit Time | 16.20s (± 0.42%) | 16.29s (± 0.25%) | +0.09s (+ 0.58%) | 16.25s | 16.36s | p=0.023 n=6 |
| Total Time | 86.38s (± 0.17%) | 86.90s (± 0.28%) | +0.52s (+ 0.60%) | 86.57s | 87.28s | p=0.008 n=6 |
- node (v20.5.1, x64)
- self-build-src - node (v20.5.1, x64)
- self-compiler - node (v20.5.1, x64)
- vscode - node (v20.5.1, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test this faster @typescript-bot perf test this public
Heya @gabritto, I've started to run the tsc-only perf test suite on this PR at 5a9022fae11fa0ec04132bac18bd084baab3b1ae. You can monitor the build here.
Update: The results are in!
Heya @gabritto, I've started to run the public perf test suite on this PR at 5a9022fae11fa0ec04132bac18bd084baab3b1ae. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,507k (± 0.01%) | 295,714k (± 0.00%) | +206k (+ 0.07%) | 295,701k | 295,742k | p=0.005 n=6 |
| Parse Time | 2.66s (± 0.31%) | 2.65s (± 0.15%) | ~ | 2.64s | 2.65s | p=0.115 n=6 |
| Bind Time | 0.82s (± 0.50%) | 0.82s (± 0.63%) | ~ | 0.82s | 0.83s | p=0.595 n=6 |
| Check Time | 8.16s (± 0.20%) | 8.15s (± 0.31%) | ~ | 8.12s | 8.18s | p=0.465 n=6 |
| Emit Time | 7.11s (± 0.33%) | 7.10s (± 0.31%) | ~ | 7.07s | 7.13s | p=0.684 n=6 |
| Total Time | 18.74s (± 0.09%) | 18.72s (± 0.18%) | ~ | 18.68s | 18.77s | p=0.260 n=6 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 194,496k (± 1.67%) | 193,682k (± 1.61%) | ~ | 191,641k | 197,725k | p=0.378 n=6 |
| Parse Time | 1.35s (± 1.21%) | 1.35s (± 0.81%) | ~ | 1.33s | 1.36s | p=0.931 n=6 |
| Bind Time | 0.72s (± 0.00%) | 0.72s (± 0.00%) | ~ | 0.72s | 0.72s | p=1.000 n=6 |
| Check Time | 9.37s (± 0.33%) | 9.30s (± 0.25%) | -0.07s (- 0.75%) | 9.28s | 9.34s | p=0.010 n=6 |
| Emit Time | 2.63s (± 0.29%) | 2.59s (± 1.11%) | -0.03s (- 1.27%) | 2.55s | 2.62s | p=0.011 n=6 |
| Total Time | 14.07s (± 0.30%) | 13.97s (± 0.38%) | -0.11s (- 0.76%) | 13.90s | 14.03s | p=0.008 n=6 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,385k (± 0.01%) | 348,383k (± 0.01%) | +998k (+ 0.29%) | 348,357k | 348,413k | p=0.005 n=6 |
| Parse Time | 2.46s (± 0.33%) | 2.47s (± 0.50%) | ~ | 2.45s | 2.48s | p=0.730 n=6 |
| Bind Time | 0.92s (± 0.59%) | 0.93s (± 0.81%) | ~ | 0.92s | 0.94s | p=0.137 n=6 |
| Check Time | 6.86s (± 0.71%) | 6.89s (± 0.50%) | ~ | 6.84s | 6.94s | p=0.229 n=6 |
| Emit Time | 4.04s (± 0.38%) | 4.05s (± 0.62%) | ~ | 4.02s | 4.08s | p=0.625 n=6 |
| Total Time | 14.29s (± 0.23%) | 14.33s (± 0.30%) | ~ | 14.29s | 14.41s | p=0.090 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,782k (± 0.00%) | 303,165k (± 0.01%) | +383k (+ 0.13%) | 303,146k | 303,193k | p=0.005 n=6 |
| Parse Time | 2.00s (± 1.46%) | 2.00s (± 0.76%) | ~ | 1.98s | 2.02s | p=0.625 n=6 |
| Bind Time | 1.00s (± 0.54%) | 1.00s (± 0.98%) | ~ | 0.99s | 1.02s | p=0.322 n=6 |
| Check Time | 6.30s (± 0.46%) | 6.30s (± 0.38%) | ~ | 6.26s | 6.32s | p=0.935 n=6 |
| Emit Time | 3.58s (± 0.63%) | 3.59s (± 0.42%) | ~ | 3.57s | 3.61s | p=0.371 n=6 |
| Total Time | 12.89s (± 0.41%) | 12.89s (± 0.23%) | ~ | 12.84s | 12.92s | p=0.747 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 508,265k (± 0.00%) | 508,790k (± 0.00%) | +525k (+ 0.10%) | 508,766k | 508,818k | p=0.005 n=6 |
| Parse Time | 2.59s (± 0.45%) | 2.59s (± 0.80%) | ~ | 2.57s | 2.63s | p=0.934 n=6 |
| Bind Time | 0.99s (± 1.77%) | 0.98s (± 0.77%) | ~ | 0.97s | 0.99s | p=0.558 n=6 |
| Check Time | 17.05s (± 0.47%) | 17.09s (± 0.29%) | ~ | 17.01s | 17.15s | p=0.630 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.63s (± 0.41%) | 20.67s (± 0.20%) | ~ | 20.59s | 20.70s | p=0.630 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 512,951k (± 0.01%) | 513,023k (± 0.01%) | +72k (+ 0.01%) | 512,898k | 513,081k | p=0.045 n=6 |
| Parse Time | 3.27s (± 0.37%) | 3.28s (± 0.27%) | ~ | 3.27s | 3.29s | p=0.362 n=6 |
| Bind Time | 1.54s (± 0.53%) | 1.54s (± 0.34%) | ~ | 1.53s | 1.54s | p=0.929 n=6 |
| Check Time | 2.83s (± 0.36%) | 2.83s (± 0.27%) | ~ | 2.82s | 2.84s | p=0.491 n=6 |
| Emit Time | 0.07s (± 5.69%) | 0.07s (± 5.69%) | ~ | 0.07s | 0.08s | p=1.000 n=6 |
| Total Time | 7.72s (± 0.28%) | 7.72s (± 0.18%) | ~ | 7.70s | 7.73s | p=0.686 n=6 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@gabritto The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| mui-docs - node (v20.5.1, x64) | ||||||
| Memory used | 1,716,669k (± 0.00%) | 1,704,269k (± 0.00%) | -12,400k (- 0.72%) | 1,704,234k | 1,704,322k | p=0.005 n=6 |
| Parse Time | 6.72s (± 0.18%) | 6.73s (± 0.36%) | ~ | 6.70s | 6.76s | p=0.370 n=6 |
| Bind Time | 2.34s (± 6.77%) | 2.41s (± 1.11%) | ~ | 2.38s | 2.44s | p=0.625 n=6 |
| Check Time | 52.36s (± 0.80%) | 52.25s (± 0.54%) | ~ | 51.92s | 52.60s | p=0.575 n=6 |
| Emit Time | 0.15s (± 3.36%) | 0.15s (± 4.21%) | ~ | 0.14s | 0.16s | p=0.386 n=6 |
| Total Time | 61.58s (± 0.91%) | 61.53s (± 0.43%) | ~ | 61.20s | 61.82s | p=0.521 n=6 |
| self-build-src - node (v20.5.1, x64) | ||||||
| Memory used | 2,577,392k (± 0.02%) | 2,580,077k (± 0.02%) | +2,685k (+ 0.10%) | 2,579,439k | 2,580,766k | p=0.005 n=6 |
| Parse Time | 5.02s (± 0.57%) | 4.98s (± 1.02%) | -0.05s (- 0.93%) | 4.89s | 5.04s | p=0.037 n=6 |
| Bind Time | 1.97s (± 1.06%) | 1.99s (± 1.52%) | ~ | 1.94s | 2.03s | p=0.294 n=6 |
| Check Time | 32.18s (± 0.19%) | 32.20s (± 0.26%) | ~ | 32.12s | 32.36s | p=0.810 n=6 |
| Emit Time | 2.89s (± 2.76%) | 2.85s (± 3.14%) | ~ | 2.77s | 3.02s | p=0.378 n=6 |
| Total Time | 42.08s (± 0.25%) | 42.04s (± 0.42%) | ~ | 41.83s | 42.27s | p=0.575 n=6 |
| self-compiler - node (v20.5.1, x64) | ||||||
| Memory used | 419,245k (± 0.01%) | 420,401k (± 0.02%) | +1,156k (+ 0.28%) | 420,303k | 420,547k | p=0.005 n=6 |
| Parse Time | 2.88s (± 0.41%) | 2.89s (± 0.19%) | ~ | 2.88s | 2.89s | p=0.859 n=6 |
| Bind Time | 1.13s (± 0.00%) | 1.14s (± 0.36%) | +0.01s (+ 1.03%) | 1.14s | 1.15s | p=0.002 n=6 |
| Check Time | 14.14s (± 0.20%) | 14.19s (± 0.33%) | +0.06s (+ 0.40%) | 14.14s | 14.28s | p=0.025 n=6 |
| Emit Time | 1.05s (± 1.43%) | 1.04s (± 0.49%) | ~ | 1.04s | 1.05s | p=0.324 n=6 |
| Total Time | 19.20s (± 0.20%) | 19.26s (± 0.27%) | +0.06s (+ 0.33%) | 19.21s | 19.36s | p=0.037 n=6 |
| vscode - node (v20.5.1, x64) | ||||||
| Memory used | 2,835,096k (± 0.00%) | 2,837,860k (± 0.01%) | +2,764k (+ 0.10%) | 2,837,478k | 2,837,975k | p=0.005 n=6 |
| Parse Time | 10.72s (± 0.27%) | 10.73s (± 0.21%) | ~ | 10.71s | 10.77s | p=0.747 n=6 |
| Bind Time | 3.45s (± 0.48%) | 3.43s (± 0.35%) | ~ | 3.42s | 3.45s | p=0.078 n=6 |
| Check Time | 56.46s (± 0.30%) | 56.66s (± 0.31%) | ~ | 56.37s | 56.85s | p=0.109 n=6 |
| Emit Time | 16.15s (± 0.37%) | 16.84s (± 9.17%) | ~ | 16.07s | 19.99s | p=0.199 n=6 |
| Total Time | 86.77s (± 0.18%) | 87.66s (± 1.88%) | ~ | 86.76s | 91.01s | p=0.054 n=6 |
| webpack - node (v20.5.1, x64) | ||||||
| Memory used | 391,355k (± 0.01%) | 391,387k (± 0.01%) | ~ | 391,333k | 391,463k | p=0.423 n=6 |
| Parse Time | 3.31s (± 0.31%) | 3.32s (± 0.50%) | ~ | 3.30s | 3.34s | p=0.675 n=6 |
| Bind Time | 1.43s (± 0.96%) | 1.42s (± 0.53%) | ~ | 1.41s | 1.43s | p=0.611 n=6 |
| Check Time | 12.80s (± 0.30%) | 12.79s (± 0.27%) | ~ | 12.75s | 12.84s | p=0.746 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 17.54s (± 0.19%) | 17.53s (± 0.20%) | ~ | 17.47s | 17.57s | p=0.747 n=6 |
- node (v20.5.1, x64)
- mui-docs - node (v20.5.1, x64)
- self-build-src - node (v20.5.1, x64)
- self-compiler - node (v20.5.1, x64)
- vscode - node (v20.5.1, x64)
- webpack - node (v20.5.1, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
I did local perf testing of this branch vs main (commit 1982349339b9c1fd78c93195d572ffc6fd5041b0). I ran tsc on a project with 10 copies of a file with the code in https://github.com/microsoft/TypeScript/blob/c73638300f2e4621cb0538fd1123f8a2fdf9e5ab/tests/cases/compiler/dependentReturnType3.ts, which is adapted from existing functions in some github repos, by changing the functions to use generic conditional types as their return types, instead of overloads.
Results were:
Conditional return types: main vs PR
Comparison Report - main..gabritto/d2-detect| Metric | main | gabritto/d2-detect | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| condperfignore - node (v20.11.0, x64) | ||||||
| Memory used | 89,742k (± 0.00%) | 88,983k (± 0.00%) | -759k (- 0.85%) | 88,983k | 88,983k | p=0.000 n=10 |
| Parse Time | 0.92s (± 0.43%) | 0.91s (± 0.40%) | -0.01s (- 0.76%) | 0.91s | 0.92s | p=0.015 n=10 |
| Bind Time | 0.42s (± 0.53%) | 0.42s (± 0.00%) | ~ | 0.42s | 0.42s | p=0.368 n=10 |
| Check Time | 0.43s (± 0.84%) | 0.36s (± 0.00%) | 🟩-0.07s (-17.05%) | 0.36s | 0.36s | p=0.000 n=10 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=10 |
| Total Time | 1.78s (± 0.31%) | 1.70s (± 0.21%) | 🟩-0.09s (- 4.83%) | 1.69s | 1.70s | p=0.000 n=10 |
| Machine Name | CPC-gabri-8SHBT |
|---|---|
| Platform | linux 5.15.133.1-microsoft-standard-WSL2 |
| Architecture | x64 |
| Available Memory | 31 GB |
| Available Memory | 30 GB |
| CPUs | 16 × AMD EPYC 7763 64-Core Processor |
- node (v20.11.0, x64)
- condperfignore - node (v20.11.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | gabritto/d2-detect | 10 |
| Baseline | main | 10 |
Conditional return types: main without errors vs PR without errors (i.e. casting to `any` where an error would otherwise occur with `main`)
Comparison Report - main..gabritto/d2-detect| Metric | main | gabritto/d2-detect | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| condperf - node (v20.11.0, x64) | ||||||
| Memory used | 89,115k (± 0.00%) | 89,021k (± 0.00%) | -94k (- 0.11%) | 89,021k | 89,021k | p=0.000 n=10 |
| Parse Time | 0.93s (± 0.86%) | 0.91s (± 0.40%) | -0.01s (- 1.51%) | 0.91s | 0.92s | p=0.004 n=10 |
| Bind Time | 0.42s (± 0.86%) | 0.42s (± 0.00%) | -0.00s (- 0.94%) | 0.42s | 0.42s | p=0.034 n=10 |
| Check Time | 0.34s (± 1.11%) | 0.36s (± 0.62%) | 🔻+0.03s (+ 7.76%) | 0.36s | 0.37s | p=0.000 n=10 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=10 |
| Total Time | 1.69s (± 0.55%) | 1.69s (± 0.29%) | ~ | 1.69s | 1.71s | p=0.200 n=10 |
| Machine Name | CPC-gabri-8SHBT |
|---|---|
| Platform | linux 5.15.133.1-microsoft-standard-WSL2 |
| Architecture | x64 |
| Available Memory | 31 GB |
| Available Memory | 30 GB |
| CPUs | 16 × AMD EPYC 7763 64-Core Processor |
- node (v20.11.0, x64)
- condperf - node (v20.11.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | gabritto/d2-detect | 10 |
| Baseline | main | 10 |
I did two different kinds of perf testing. One was with the original content of the test mentioned above. In that scenario, my PR decreases check time by ~17%. This is because the test contains a bunch of examples that cause lots of errors (one at every return statement) with the main version of tsc, that are then @ts-ignored, but with my PR, the errors go away and the checker doesn't even generate them in the first place. So the decrease is because we're not generating the errors.
The other scenario was "run without errors", in which I added a cast to any on the return statement expressions. In that scenario, my PR increases check time by ~8%. With the cast to any, we no longer error on the return statements, so the check time increases because the PR version does extra work when checking return statements.
This isn't exactly a fair comparison, because with main we're basically not checking whether the return statement expression types are assignable to the return types, and with the PR, we are doing that.
Some remarks:
In the scenario with the casts to any, the PR does all the extra work of detecting which expression to use as basis for narrowing, and then narrowing the return type. But this work is of course pointless because the return statement expression is cast to any, and in both main and PR versions of tsc, we end up checking if any is assignable to the return type, which it is because any is assignable to anything.
So this scenario is the worst possible case for checker performance, because it does a bunch of extra work for no reason. Also, all of the functions in the test have a conditional type as its return type, and all of them trigger narrowing of that return type, so, again, this is the worst possible scenario in that regard.
On the other hand, detection works by visiting the flow nodes in the control flow graph and asking for the types of expressions in those nodes, and the functions in the test are not that long or have particularly lots of flow nodes, so the performance increase could be even larger for more complicated function bodies.
=================================================================
I also ran the same sort of perf test, this time comparing main tsc compiling on a version of the test that uses overload signatures instead of conditional return types, versus the PR compiling the version with conditional return types. The idea behind this is that, currently, one of the alternatives to using a conditional return type is to express the function type through overloads.
Overloads on main vs conditional return types on PR
Comparison Report - main..gabritto/d2-detect| Metric | main | gabritto/d2-detect | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| overloadperf - node (v20.11.0, x64) | ||||||
| Memory used | 89,694k (± 0.00%) | 88,985k (± 0.00%) | -709k (- 0.79%) | 88,985k | 88,985k | p=0.000 n=10 |
| Parse Time | 0.93s (± 0.24%) | 0.91s (± 0.37%) | -0.02s (- 1.72%) | 0.91s | 0.92s | p=0.000 n=10 |
| Bind Time | 0.41s (± 0.54%) | 0.42s (± 0.87%) | +0.01s (+ 1.71%) | 0.41s | 0.42s | p=0.004 n=10 |
| Check Time | 0.35s (± 1.03%) | 0.36s (± 0.94%) | +0.01s (+ 2.54%) | 0.36s | 0.37s | p=0.003 n=10 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=10 |
| Total Time | 1.69s (± 0.20%) | 1.69s (± 0.29%) | ~ | 1.69s | 1.71s | p=0.925 n=10 |
| Machine Name | CPC-gabri-8SHBT |
|---|---|
| Platform | linux 5.15.133.1-microsoft-standard-WSL2 |
| Architecture | x64 |
| Available Memory | 31 GB |
| Available Memory | 30 GB |
| CPUs | 16 × AMD EPYC 7763 64-Core Processor |
- node (v20.11.0, x64)
- overloadperf - node (v20.11.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | gabritto/d2-detect | 10 |
| Baseline | main | 10 |
This time, my PR has a ~3% check time increase compared to the version of the code that uses overloads and checked by main (note that parse time is different because we're comparing for running tsc on different inputs).
Still regarding perf, I did some profiling of my PR running on the same input as the perf test described above (the original version, with conditional return types and no casts to any). Looks like the PR roughly doubles the time spent on checkReturnStatementExpression (which doesn't exist on main but corresponds to checking the return statement expression + checking if the return statement expression's type is assignable to the function's return type). From that extra time the PR spends on that function, half of it is on detection of which expression to use as base for return type narrowing.
Update on perf tests:
There was an omission in the implementation that I tested in my previous comment: it didn't check if the return expression's type was already assignable to the original (unnarrowed) return type. I have added that check, which unfortunately means my PR does even more work now. I redid two of the same perf tests mentioned above:
main vs PR (test has `@ts-ignore` where main would error)
Comparison Report - main..gabritto/d2-detect| Metric | main | gabritto/d2-detect | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| condperfignore - node (v20.11.0, x64) | ||||||
| Memory used | 89,916k (± 0.00%) | 89,317k (± 0.00%) | -599k (- 0.67%) | 89,317k | 89,317k | p=0.000 n=10 |
| Parse Time | 0.93s (± 0.51%) | 0.92s (± 0.32%) | -0.01s (- 1.29%) | 0.91s | 0.92s | p=0.001 n=10 |
| Bind Time | 0.42s (± 0.53%) | 0.42s (± 0.70%) | ~ | 0.42s | 0.43s | p=0.583 n=10 |
| Check Time | 0.44s (± 0.78%) | 0.39s (± 0.57%) | 🟩-0.05s (-10.98%) | 0.38s | 0.39s | p=0.000 n=10 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=10 |
| Total Time | 1.79s (± 0.47%) | 1.73s (± 0.19%) | 🟩-0.06s (- 3.41%) | 1.72s | 1.74s | p=0.000 n=10 |
| Machine Name | CPC-gabri-8SHBT |
|---|---|
| Platform | linux 5.15.133.1-microsoft-standard-WSL2 |
| Architecture | x64 |
| Available Memory | 31 GB |
| Available Memory | 30 GB |
| CPUs | 16 × AMD EPYC 7763 64-Core Processor |
- node (v20.11.0, x64)
- condperfignore - node (v20.11.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | gabritto/d2-detect | 10 |
| Baseline | main | 10 |
main on test with overloads vs PR on test with conditional types
Comparison Report - main..gabritto/d2-detect| Metric | main | gabritto/d2-detect | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| overloadperf - node (v20.11.0, x64) | ||||||
| Memory used | 89,903k (± 0.00%) | 89,321k (± 0.00%) | -582k (- 0.65%) | 89,321k | 89,321k | p=0.000 n=10 |
| Parse Time | 0.94s (± 0.36%) | 0.91s (± 0.44%) | -0.03s (- 2.99%) | 0.90s | 0.92s | p=0.000 n=10 |
| Bind Time | 0.42s (± 0.86%) | 0.42s (± 0.53%) | ~ | 0.42s | 0.43s | p=0.144 n=10 |
| Check Time | 0.36s (± 0.62%) | 0.39s (± 0.57%) | 🔻+0.03s (+ 8.91%) | 0.39s | 0.40s | p=0.000 n=10 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=10 |
| Total Time | 1.72s (± 0.32%) | 1.72s (± 0.34%) | ~ | 1.71s | 1.74s | p=0.755 n=10 |
| Machine Name | CPC-gabri-8SHBT |
|---|---|
| Platform | linux 5.15.133.1-microsoft-standard-WSL2 |
| Architecture | x64 |
| Available Memory | 31 GB |
| Available Memory | 30 GB |
| CPUs | 16 × AMD EPYC 7763 64-Core Processor |
- node (v20.11.0, x64)
- overloadperf - node (v20.11.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | gabritto/d2-detect | 10 |
| Baseline | main | 10 |
@typescript-bot perf test this faster
Heya @gabritto, I've started to run the faster perf test suite on this PR at 1f45a76a5e89ef2dcef45583463d4bb582d94e5a. You can monitor the build here.
Update: The results are in!
@gabritto The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Angular - node (v18.15.0, x64) | ||||||
| Memory used | 295,675k (± 0.01%) | 295,881k (± 0.01%) | +206k (+ 0.07%) | 295,864k | 295,922k | p=0.005 n=6 |
| Parse Time | 2.67s (± 0.21%) | 2.66s (± 0.19%) | -0.01s (- 0.31%) | 2.65s | 2.66s | p=0.038 n=6 |
| Bind Time | 0.83s (± 0.99%) | 0.84s (± 1.17%) | ~ | 0.83s | 0.85s | p=0.065 n=6 |
| Check Time | 8.18s (± 0.26%) | 8.20s (± 0.14%) | ~ | 8.18s | 8.21s | p=0.168 n=6 |
| Emit Time | 7.07s (± 0.12%) | 7.10s (± 0.67%) | +0.03s (+ 0.40%) | 7.08s | 7.20s | p=0.040 n=6 |
| Total Time | 18.75s (± 0.06%) | 18.80s (± 0.22%) | +0.04s (+ 0.24%) | 18.77s | 18.88s | p=0.004 n=6 |
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Memory used | 193,488k (± 1.56%) | 194,091k (± 1.51%) | ~ | 191,653k | 197,792k | p=0.128 n=6 |
| Parse Time | 1.36s (± 0.55%) | 1.36s (± 0.86%) | ~ | 1.35s | 1.38s | p=0.734 n=6 |
| Bind Time | 0.72s (± 0.00%) | 0.72s (± 0.00%) | ~ | 0.72s | 0.72s | p=1.000 n=6 |
| Check Time | 9.33s (± 0.48%) | 9.33s (± 0.33%) | ~ | 9.30s | 9.38s | p=0.745 n=6 |
| Emit Time | 2.62s (± 0.29%) | 2.59s (± 1.37%) | -0.03s (- 1.27%) | 2.52s | 2.62s | p=0.017 n=6 |
| Total Time | 14.04s (± 0.30%) | 14.01s (± 0.40%) | ~ | 13.91s | 14.08s | p=0.296 n=6 |
| Monaco - node (v18.15.0, x64) | ||||||
| Memory used | 347,454k (± 0.00%) | 348,454k (± 0.01%) | +1,000k (+ 0.29%) | 348,429k | 348,504k | p=0.005 n=6 |
| Parse Time | 2.48s (± 0.57%) | 2.48s (± 0.49%) | ~ | 2.46s | 2.49s | p=0.743 n=6 |
| Bind Time | 0.93s (± 0.56%) | 0.92s (± 0.59%) | ~ | 0.92s | 0.93s | p=0.640 n=6 |
| Check Time | 6.91s (± 0.25%) | 6.95s (± 0.27%) | +0.04s (+ 0.58%) | 6.93s | 6.98s | p=0.007 n=6 |
| Emit Time | 4.06s (± 0.66%) | 4.06s (± 0.42%) | ~ | 4.04s | 4.09s | p=0.681 n=6 |
| Total Time | 14.37s (± 0.15%) | 14.41s (± 0.20%) | ~ | 14.37s | 14.45s | p=0.052 n=6 |
| TFS - node (v18.15.0, x64) | ||||||
| Memory used | 302,831k (± 0.01%) | 303,224k (± 0.01%) | +394k (+ 0.13%) | 303,193k | 303,256k | p=0.005 n=6 |
| Parse Time | 2.02s (± 0.44%) | 2.01s (± 0.63%) | ~ | 2.00s | 2.03s | p=0.161 n=6 |
| Bind Time | 1.01s (± 1.16%) | 1.00s (± 0.81%) | ~ | 1.00s | 1.02s | p=0.340 n=6 |
| Check Time | 6.32s (± 0.38%) | 6.32s (± 0.19%) | ~ | 6.30s | 6.33s | p=0.681 n=6 |
| Emit Time | 3.59s (± 0.63%) | 3.59s (± 0.42%) | ~ | 3.58s | 3.62s | p=1.000 n=6 |
| Total Time | 12.94s (± 0.30%) | 12.92s (± 0.22%) | ~ | 12.88s | 12.96s | p=0.628 n=6 |
| material-ui - node (v18.15.0, x64) | ||||||
| Memory used | 511,310k (± 0.00%) | 511,803k (± 0.01%) | +493k (+ 0.10%) | 511,769k | 511,845k | p=0.005 n=6 |
| Parse Time | 2.64s (± 0.74%) | 2.65s (± 0.63%) | ~ | 2.62s | 2.67s | p=0.681 n=6 |
| Bind Time | 0.99s (± 1.56%) | 0.99s (± 0.90%) | ~ | 0.98s | 1.00s | p=0.672 n=6 |
| Check Time | 17.22s (± 0.32%) | 17.21s (± 0.22%) | ~ | 17.14s | 17.24s | p=0.294 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 20.86s (± 0.33%) | 20.85s (± 0.24%) | ~ | 20.76s | 20.90s | p=1.000 n=6 |
| mui-docs - node (v18.15.0, x64) | ||||||
| Memory used | 1,694,782k (± 0.00%) | 1,682,296k (± 0.00%) | -12,486k (- 0.74%) | 1,682,237k | 1,682,358k | p=0.005 n=6 |
| Parse Time | 6.52s (± 0.21%) | 6.53s (± 0.48%) | ~ | 6.51s | 6.58s | p=0.806 n=6 |
| Bind Time | 2.36s (± 0.38%) | 2.37s (± 0.62%) | ~ | 2.35s | 2.39s | p=0.363 n=6 |
| Check Time | 55.25s (± 0.26%) | 55.06s (± 0.63%) | ~ | 54.55s | 55.59s | p=0.260 n=6 |
| Emit Time | 0.16s (± 0.00%) | 0.16s (± 0.00%) | ~ | 0.16s | 0.16s | p=1.000 n=6 |
| Total Time | 64.30s (± 0.22%) | 64.11s (± 0.51%) | ~ | 63.68s | 64.64s | p=0.297 n=6 |
| self-build-src - node (v18.15.0, x64) | ||||||
| Memory used | 2,413,331k (± 0.03%) | 2,415,414k (± 0.02%) | +2,084k (+ 0.09%) | 2,414,714k | 2,415,862k | p=0.005 n=6 |
| Parse Time | 4.92s (± 0.36%) | 4.97s (± 0.62%) | +0.04s (+ 0.88%) | 4.92s | 5.00s | p=0.044 n=6 |
| Bind Time | 1.86s (± 1.04%) | 1.88s (± 0.45%) | ~ | 1.86s | 1.88s | p=0.094 n=6 |
| Check Time | 33.53s (± 0.27%) | 33.51s (± 0.36%) | ~ | 33.35s | 33.69s | p=1.000 n=6 |
| Emit Time | 2.70s (± 1.24%) | 2.72s (± 2.21%) | ~ | 2.62s | 2.77s | p=0.297 n=6 |
| Total Time | 43.03s (± 0.20%) | 43.10s (± 0.33%) | ~ | 42.95s | 43.35s | p=0.471 n=6 |
| self-compiler - node (v18.15.0, x64) | ||||||
| Memory used | 419,732k (± 0.01%) | 420,840k (± 0.01%) | +1,108k (+ 0.26%) | 420,796k | 420,878k | p=0.005 n=6 |
| Parse Time | 2.77s (± 3.10%) | 2.79s (± 2.95%) | ~ | 2.62s | 2.83s | p=1.000 n=6 |
| Bind Time | 1.13s (± 7.00%) | 1.10s (± 5.27%) | ~ | 1.07s | 1.22s | p=0.654 n=6 |
| Check Time | 15.15s (± 0.43%) | 15.22s (± 0.37%) | ~ | 15.11s | 15.27s | p=0.126 n=6 |
| Emit Time | 1.15s (± 0.95%) | 1.14s (± 1.51%) | ~ | 1.12s | 1.16s | p=0.222 n=6 |
| Total Time | 20.20s (± 0.36%) | 20.24s (± 0.45%) | ~ | 20.07s | 20.33s | p=0.374 n=6 |
| vscode - node (v18.15.0, x64) | ||||||
| Memory used | 2,808,540k (± 0.00%) | 2,811,289k (± 0.00%) | +2,749k (+ 0.10%) | 2,811,257k | 2,811,335k | p=0.005 n=6 |
| Parse Time | 10.62s (± 0.50%) | 10.63s (± 0.19%) | ~ | 10.61s | 10.66s | p=0.465 n=6 |
| Bind Time | 3.39s (± 0.55%) | 3.39s (± 0.34%) | ~ | 3.38s | 3.41s | p=0.621 n=6 |
| Check Time | 59.86s (± 0.60%) | 60.29s (± 0.22%) | +0.43s (+ 0.72%) | 60.11s | 60.44s | p=0.031 n=6 |
| Emit Time | 16.16s (± 1.42%) | 16.11s (± 0.46%) | ~ | 16.05s | 16.26s | p=0.469 n=6 |
| Total Time | 90.03s (± 0.51%) | 90.42s (± 0.22%) | ~ | 90.20s | 90.72s | p=0.298 n=6 |
| webpack - node (v18.15.0, x64) | ||||||
| Memory used | 392,583k (± 0.01%) | 392,612k (± 0.01%) | ~ | 392,536k | 392,660k | p=0.297 n=6 |
| Parse Time | 3.05s (± 0.71%) | 3.04s (± 0.50%) | ~ | 3.03s | 3.07s | p=1.000 n=6 |
| Bind Time | 1.40s (± 0.84%) | 1.39s (± 0.99%) | ~ | 1.38s | 1.42s | p=0.546 n=6 |
| Check Time | 13.92s (± 0.43%) | 14.01s (± 0.27%) | +0.09s (+ 0.62%) | 13.97s | 14.07s | p=0.015 n=6 |
| Emit Time | 0.00s (± 0.00%) | 0.00s (± 0.00%) | ~ | 0.00s | 0.00s | p=1.000 n=6 |
| Total Time | 18.36s (± 0.30%) | 18.45s (± 0.26%) | +0.08s (+ 0.44%) | 18.39s | 18.51s | p=0.037 n=6 |
| xstate - node (v18.15.0, x64) | ||||||
| Memory used | 513,418k (± 0.00%) | 513,391k (± 0.01%) | ~ | 513,326k | 513,466k | p=0.470 n=6 |
| Parse Time | 3.28s (± 0.50%) | 3.27s (± 0.30%) | ~ | 3.26s | 3.28s | p=0.934 n=6 |
| Bind Time | 1.55s (± 0.67%) | 1.54s (± 0.27%) | ~ | 1.53s | 1.54s | p=0.101 n=6 |
| Check Time | 2.85s (± 0.48%) | 2.85s (± 0.76%) | ~ | 2.83s | 2.88s | p=0.742 n=6 |
| Emit Time | 0.08s (± 4.99%) | 0.07s (± 5.69%) | 🟩-0.01s (-12.24%) | 0.07s | 0.08s | p=0.008 n=6 |
| Total Time | 7.75s (± 0.28%) | 7.74s (± 0.32%) | ~ | 7.71s | 7.77s | p=0.629 n=6 |
- node (v18.15.0, x64)
- Angular - node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- Monaco - node (v18.15.0, x64)
- TFS - node (v18.15.0, x64)
- material-ui - node (v18.15.0, x64)
- mui-docs - node (v18.15.0, x64)
- self-build-src - node (v18.15.0, x64)
- self-compiler - node (v18.15.0, x64)
- vscode - node (v18.15.0, x64)
- webpack - node (v18.15.0, x64)
- xstate - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@typescript-bot perf test this faster