Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyze control flow effects of lambdas passed as arguments #58729

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

ahejlsberg
Copy link
Member

@ahejlsberg ahejlsberg commented May 31, 2024

This PR introduces a new immediate modifier that can be applied to callback parameters to indicate that control flow analysis should assume that function expressions or arrow functions (in the following called lambda expressions) passed as arguments in a function call may be invoked synchronously during that call. For example:

declare function mystery(immediate cb: () => void): void;

let x: string | number = "OK";
x;  // string
mystery(() => {
    x = 10;
});
x;  // string | number
if (x === 10) {  // Error without 'immediate' modifier
}

Without the immediate modifier, control flow analysis will assume that the lambda expression is never invoked synchronously and thus will consider the type of x to be string following the call. With the immediate modifier, control flow analysis assumes that the lambda expression may have been invoked synchronously and thus considers the type of x to be string | number following the call.

It an error to apply the immediate modifier to anything but a parameter with a type that permits functions. Async arrow functions, async function expressions, and generator function expressions are always assumed to be deferred, regardless of whether their corresponding parameter includes an immediate modifier.

In JavaScript files, an immediate callback parameter can be declared using an /** @immediate */ JSDoc annotation:

/**
 * @param {() => void} cb
 */
function callNow(/** @immediate */ cb) { ... }

Since the immediate modifier is considered an error by earlier versions of TypeScript, it isn't possible to add immediate modifiers to frameworks and libraries without also requiring the latest version of the compiler. The compiler therefore also recognizes /** @immediate */ JSDoc comments in TypeScript files such that they can be used in cases where backwards compatibility matters. However, use of immediate modifiers is recommended whenever possible.

NOTE: This PR initially changed control flow analysis to assume possibly-immediately-called semantics by default and implemented a deferred modifier to indicate never-immediately-called semantics. While technically more sound (absent knowledge of whether or when a callback is called, it is safest and most conservative to assume it may have been called), this turned out to require too much remediation in existing code. The PR now preserves the default never-immediately-called semantics and allows code to opt into possibly-immediately-called analysis using the immediate modifier.

Fixes #11498.
Fixes #15380.
Fixes #57880.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 31, 2024
@ahejlsberg
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 31, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started 👀 Results
user test this ✅ Started 👀 Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user tests with tsc comparing main and refs/pull/58729/merge:

Something interesting changed - please have a look.

Details

enhanced-resolve

/mnt/ts_downloads/_/m/enhanced-resolve/tsconfig.json

  • [MISSING] error TS2339: Property 'replace' does not exist on type 'never'.
    • /mnt/ts_downloads/_/m/enhanced-resolve/node_modules/enhanced-resolve/lib/concord.js(149,24)
    • /mnt/ts_downloads/_/m/enhanced-resolve/node_modules/enhanced-resolve/lib/concord.js(188,17)

pyright

/mnt/ts_downloads/_/m/pyright/build.sh

  • [NEW] error TS18048: 'cacheEntry' is possibly 'undefined'.
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(951,25)
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(1064,41)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/analyzer/codeFlowEngine.ts(951,25)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/analyzer/codeFlowEngine.ts(1064,41)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(951,25)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(1064,41)

uglify-js

/mnt/ts_downloads/_/m/uglify-js/tsconfig.json

  • [MISSING] error TS18048: 'ldef' is possibly 'undefined'.
    • /mnt/ts_downloads/_/m/uglify-js/node_modules/uglify-js/lib/compress.js(6753,56)

webpack

tsconfig.types.json

xterm.js

src/tsconfig-library-base.json

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,243 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 192,920k (± 0.75%) 192,999k (± 0.75%) +79k (+ 0.04%) 192,402k 195,952k p=0.045 n=6
Parse Time 1.95s (± 0.96%) 1.95s (± 0.53%) ~ 1.94s 1.97s p=0.317 n=6
Bind Time 1.08s (± 0.70%) 1.10s (± 0.74%) +0.02s (+ 2.00%) 1.09s 1.11s p=0.007 n=6
Check Time 14.05s (± 0.46%) 14.15s (± 0.52%) +0.10s (+ 0.70%) 14.05s 14.27s p=0.037 n=6
Emit Time 4.07s (± 1.00%) 4.06s (± 0.53%) ~ 4.03s 4.09s p=0.223 n=6
Total Time 21.14s (± 0.18%) 21.26s (± 0.32%) +0.12s (+ 0.54%) 21.17s 21.37s p=0.010 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 9 🔻+4 (+80.00%) ~ ~ p=0.001 n=6
Symbols 944,109 944,283 +174 (+ 0.02%) ~ ~ p=0.001 n=6
Types 407,049 407,127 +78 (+ 0.02%) ~ ~ p=0.001 n=6
Memory used 1,222,154k (± 0.00%) 1,223,819k (± 0.00%) +1,664k (+ 0.14%) 1,223,752k 1,223,903k p=0.005 n=6
Parse Time 8.05s (± 0.57%) 8.07s (± 0.67%) ~ 8.02s 8.16s p=0.809 n=6
Bind Time 2.23s (± 0.62%) 2.28s (± 0.72%) +0.05s (+ 2.32%) 2.26s 2.30s p=0.005 n=6
Check Time 36.28s (± 0.12%) 36.72s (± 0.27%) +0.43s (+ 1.19%) 36.62s 36.90s p=0.005 n=6
Emit Time 17.94s (± 0.68%) 18.11s (± 0.50%) +0.17s (+ 0.95%) 18.01s 18.25s p=0.030 n=6
Total Time 64.49s (± 0.28%) 65.18s (± 0.29%) +0.68s (+ 1.06%) 64.97s 65.46s p=0.005 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 2,051,460 2,051,489 +29 (+ 0.00%) ~ ~ p=0.001 n=6
Types 899,446 899,469 +23 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,065,603k (± 0.01%) 2,065,874k (± 0.00%) +271k (+ 0.01%) 2,065,749k 2,065,985k p=0.013 n=6
Parse Time 8.10s (± 0.46%) 8.11s (± 0.21%) ~ 8.09s 8.13s p=1.000 n=6
Bind Time 2.75s (± 0.88%) 2.77s (± 0.84%) ~ 2.74s 2.80s p=0.124 n=6
Check Time 81.77s (± 0.36%) 82.13s (± 0.44%) ~ 81.76s 82.71s p=0.066 n=6
Emit Time 0.16s (± 3.16%) 0.17s (± 3.10%) ~ 0.16s 0.17s p=0.311 n=6
Total Time 92.78s (± 0.28%) 93.18s (± 0.40%) +0.39s (+ 0.43%) 92.82s 93.78s p=0.045 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,708 1,229,781 +73 (+ 0.01%) ~ ~ p=0.001 n=6
Types 260,904 260,917 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,351,266k (± 0.02%) 2,350,890k (± 0.06%) ~ 2,349,360k 2,353,094k p=0.575 n=6
Parse Time 4.98s (± 0.91%) 4.98s (± 0.85%) ~ 4.94s 5.05s p=0.936 n=6
Bind Time 1.91s (± 0.55%) 1.93s (± 0.39%) +0.03s (+ 1.40%) 1.92s 1.94s p=0.006 n=6
Check Time 34.12s (± 0.30%) 34.20s (± 0.17%) ~ 34.11s 34.27s p=0.109 n=6
Emit Time 2.56s (± 1.65%) 2.63s (± 2.41%) ~ 2.56s 2.72s p=0.066 n=6
Total Time 43.55s (± 0.21%) 43.78s (± 0.22%) +0.22s (+ 0.51%) 43.63s 43.89s p=0.013 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,708 1,229,781 +73 (+ 0.01%) ~ ~ p=0.001 n=6
Types 260,904 260,917 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,452,360k (± 2.48%) 2,428,222k (± 0.04%) ~ 2,427,090k 2,429,614k p=0.810 n=6
Parse Time 6.24s (± 0.45%) 6.26s (± 0.55%) ~ 6.22s 6.30s p=0.471 n=6
Bind Time 2.01s (± 0.96%) 2.20s (± 4.72%) 🔻+0.19s (+ 9.28%) 2.05s 2.27s p=0.005 n=6
Check Time 40.47s (± 0.33%) 40.48s (± 0.93%) ~ 40.18s 41.00s p=0.378 n=6
Emit Time 3.07s (± 2.70%) 3.05s (± 1.79%) ~ 2.99s 3.11s p=0.575 n=6
Total Time 51.82s (± 0.25%) 52.02s (± 0.49%) ~ 51.71s 52.35s p=0.230 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,593 258,618 +25 (+ 0.01%) ~ ~ p=0.001 n=6
Types 105,011 105,024 +13 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 428,227k (± 0.01%) 428,434k (± 0.01%) +207k (+ 0.05%) 428,406k 428,469k p=0.005 n=6
Parse Time 4.06s (± 0.57%) 4.08s (± 0.38%) ~ 4.07s 4.10s p=0.210 n=6
Bind Time 1.63s (± 0.92%) 1.65s (± 1.31%) ~ 1.62s 1.68s p=0.124 n=6
Check Time 22.42s (± 0.40%) 22.43s (± 0.20%) ~ 22.37s 22.47s p=0.809 n=6
Emit Time 1.70s (± 1.93%) 1.71s (± 1.41%) ~ 1.68s 1.75s p=0.466 n=6
Total Time 29.81s (± 0.35%) 29.88s (± 0.21%) ~ 29.80s 29.95s p=0.295 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,736 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 369,857k (± 0.03%) 369,994k (± 0.04%) ~ 369,826k 370,188k p=0.173 n=6
Parse Time 2.85s (± 0.79%) 2.85s (± 0.85%) ~ 2.82s 2.87s p=0.808 n=6
Bind Time 1.59s (± 0.97%) 1.60s (± 0.65%) ~ 1.59s 1.62s p=0.118 n=6
Check Time 15.73s (± 0.39%) 15.76s (± 0.27%) ~ 15.71s 15.82s p=0.746 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.17s (± 0.36%) 20.21s (± 0.31%) ~ 20.12s 20.29s p=0.377 n=6
vscode - node (v18.15.0, x64)
Errors 10 90 🔻+80 (+800.00%) ~ ~ p=0.001 n=6
Symbols 2,842,991 2,847,064 +4,073 (+ 0.14%) ~ ~ p=0.001 n=6
Types 963,472 964,365 +893 (+ 0.09%) ~ ~ p=0.001 n=6
Memory used 3,015,847k (± 0.00%) 3,019,578k (± 0.00%) +3,732k (+ 0.12%) 3,019,506k 3,019,681k p=0.005 n=6
Parse Time 17.02s (± 0.26%) 17.07s (± 0.32%) ~ 17.02s 17.16s p=0.065 n=6
Bind Time 5.16s (± 2.45%) 5.21s (± 1.76%) ~ 5.17s 5.40s p=0.226 n=6
Check Time 89.08s (± 0.11%) 91.48s (± 1.87%) +2.41s (+ 2.70%) 90.25s 94.91s p=0.005 n=6
Emit Time 28.89s (± 0.78%) 28.10s (± 6.97%) ~ 24.11s 29.07s p=0.936 n=6
Total Time 140.15s (± 0.15%) 141.87s (± 0.36%) +1.72s (+ 1.23%) 141.29s 142.45s p=0.005 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 266,361 266,362 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 108,554 108,557 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 411,503k (± 0.02%) 411,827k (± 0.04%) +324k (+ 0.08%) 411,629k 412,030k p=0.005 n=6
Parse Time 4.83s (± 0.54%) 4.78s (± 0.70%) -0.05s (- 1.04%) 4.73s 4.83s p=0.028 n=6
Bind Time 2.09s (± 0.58%) 2.12s (± 0.42%) +0.03s (+ 1.60%) 2.11s 2.13s p=0.005 n=6
Check Time 21.13s (± 0.16%) 21.29s (± 0.58%) ~ 21.07s 21.41s p=0.065 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.05s (± 0.18%) 28.19s (± 0.38%) ~ 27.99s 28.28s p=0.066 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 525,588 525,588 ~ ~ ~ p=1.000 n=6
Types 179,032 179,032 ~ ~ ~ p=1.000 n=6
Memory used 463,503k (± 0.07%) 463,672k (± 0.06%) ~ 463,176k 463,934k p=0.378 n=6
Parse Time 2.62s (± 0.45%) 2.62s (± 0.16%) ~ 2.62s 2.63s p=0.787 n=6
Bind Time 0.99s (± 0.41%) 1.00s (± 0.54%) +0.01s (+ 1.34%) 1.00s 1.01s p=0.006 n=6
Check Time 15.24s (± 0.62%) 15.33s (± 0.37%) ~ 15.27s 15.41s p=0.065 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 18.85s (± 0.48%) 18.96s (± 0.30%) ~ 18.89s 19.03s p=0.054 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@fatcerberus
Copy link

I feel like this is just going to flip the problem on its head in the end - instead of people complaining because their immediately-invoked callbacks didn't affect narrowing, an equal number of people will probably now complain instead that callbacks they know will be called out-of-band do affect narrowing. The goalposts don't even move really - the other team just gets possession is all 😄

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top 400 repos with tsc comparing main and refs/pull/58729/merge:

Something interesting changed - please have a look.

Details

apollographql/apollo-client

1 of 12 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS7022: 'match' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

src/tsconfig.json

  • error TS7022: 'match' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

conwnet/github1s

extensions/github1s/tsconfig.json

electron-react-boilerplate/electron-react-boilerplate

tsconfig.json

highcharts/highcharts

25 of 26 projects failed to build with the old tsc and were ignored

test/ts-node-unit-tests/tsconfig.json

labring/FastGPT

projects/app/tsconfig.json

packages/service/tsconfig.json

lyswhut/lx-music-desktop

1 of 6 projects failed to build with the old tsc and were ignored

src/main/tsconfig.json

microsoft/vscode

7 of 54 projects failed to build with the old tsc and were ignored

extensions/vscode-test-resolver/tsconfig.json

extensions/vscode-api-tests/tsconfig.json

reduxjs/redux-toolkit

11 of 32 projects failed to build with the old tsc and were ignored

packages/toolkit/tsconfig.build.json

subquery/subql

2 of 6 projects failed to build with the old tsc and were ignored

tsconfig.json

tinacms/tinacms

12 of 24 projects failed to build with the old tsc and were ignored

packages/@tinacms/mdx/tsconfig.json

@ahejlsberg
Copy link
Member Author

I think it's clear that there's no one-size-fits-all answer to whether effects of executing lambda arguments should be reflected in CFA types. Our current assumption is that lambdas are never executed synchronously. This PR experiments with the assumption they're possibly executed, which, given no additional information about the function to which the lambda arguments are passed, is definitely a more sound assumption. Also, the PR validates an implementation strategy and gives us data on the performance cost of analyzing lambda effects.

I would nice to avoid modifiers (like sync, immediate, deferred) on callback parameters, but in the end it may be unavoidable. Modifiers come with the added complication that CFA will need to resolve the function's type, which may in turn lead to circularities.

@ahejlsberg
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 3, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started 👀 Results
user test this ✅ Started 👀 Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,243 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 193,572k (± 1.01%) 193,028k (± 0.73%) ~ 192,339k 195,911k p=0.378 n=6
Parse Time 1.29s (± 0.94%) 1.29s (± 0.81%) ~ 1.28s 1.31s p=0.868 n=6
Bind Time 0.72s 0.74s +0.02s (+ 2.78%) ~ ~ p=0.001 n=6
Check Time 9.57s (± 0.23%) 9.59s (± 0.70%) ~ 9.48s 9.66s p=0.468 n=6
Emit Time 2.76s (± 0.20%) 2.75s (± 0.74%) ~ 2.72s 2.78s p=0.100 n=6
Total Time 14.35s (± 0.16%) 14.37s (± 0.48%) ~ 14.25s 14.44s p=0.195 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 9 🔻+4 (+80.00%) ~ ~ p=0.001 n=6
Symbols 944,109 944,283 +174 (+ 0.02%) ~ ~ p=0.001 n=6
Types 407,049 407,096 +47 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 1,222,193k (± 0.00%) 1,223,909k (± 0.00%) +1,717k (+ 0.14%) 1,223,856k 1,223,966k p=0.005 n=6
Parse Time 6.80s (± 0.47%) 6.79s (± 0.50%) ~ 6.74s 6.84s p=0.420 n=6
Bind Time 1.88s (± 0.29%) 1.91s (± 0.57%) +0.03s (+ 1.87%) 1.89s 1.92s p=0.004 n=6
Check Time 31.38s (± 0.34%) 31.71s (± 0.56%) +0.34s (+ 1.07%) 31.49s 31.98s p=0.006 n=6
Emit Time 15.21s (± 0.97%) 15.20s (± 0.32%) ~ 15.12s 15.24s p=0.575 n=6
Total Time 55.26s (± 0.23%) 55.60s (± 0.41%) +0.34s (+ 0.62%) 55.33s 55.97s p=0.013 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 2,054,061 2,054,090 +29 (+ 0.00%) ~ ~ p=0.001 n=6
Types 899,813 899,836 +23 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,067,140k (± 0.01%) 2,067,295k (± 0.01%) ~ 2,067,100k 2,067,509k p=0.336 n=6
Parse Time 8.10s (± 0.18%) 8.13s (± 0.34%) ~ 8.10s 8.17s p=0.120 n=6
Bind Time 2.75s (± 0.90%) 2.78s (± 0.87%) ~ 2.74s 2.80s p=0.145 n=6
Check Time 82.19s (± 0.36%) 82.05s (± 0.55%) ~ 81.46s 82.49s p=0.689 n=6
Emit Time 0.16s 0.17s (± 4.89%) ~ 0.16s 0.18s p=0.073 n=6
Total Time 93.21s (± 0.31%) 93.12s (± 0.51%) ~ 92.53s 93.57s p=1.000 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,585 1,229,658 +73 (+ 0.01%) ~ ~ p=0.001 n=6
Types 260,899 260,912 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,350,738k (± 0.02%) 2,350,985k (± 0.04%) ~ 2,350,160k 2,352,793k p=0.810 n=6
Parse Time 4.99s (± 1.00%) 4.99s (± 0.76%) ~ 4.95s 5.05s p=1.000 n=6
Bind Time 1.91s (± 0.51%) 1.94s (± 0.51%) +0.03s (+ 1.39%) 1.92s 1.95s p=0.008 n=6
Check Time 33.99s (± 0.36%) 34.19s (± 0.34%) +0.20s (+ 0.59%) 33.98s 34.28s p=0.031 n=6
Emit Time 2.58s (± 1.35%) 2.65s (± 3.33%) ~ 2.52s 2.73s p=0.230 n=6
Total Time 43.50s (± 0.31%) 43.78s (± 0.47%) +0.27s (+ 0.63%) 43.41s 43.94s p=0.045 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,585 1,229,658 +73 (+ 0.01%) ~ ~ p=0.001 n=6
Types 260,899 260,912 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,451,724k (± 2.52%) 2,426,666k (± 0.04%) ~ 2,426,036k 2,428,177k p=0.810 n=6
Parse Time 5.20s (± 0.51%) 5.16s (± 0.65%) -0.04s (- 0.83%) 5.12s 5.21s p=0.037 n=6
Bind Time 1.68s (± 0.58%) 1.89s (± 4.74%) 🔻+0.21s (+12.29%) 1.71s 1.95s p=0.004 n=6
Check Time 34.45s (± 0.15%) 34.35s (± 0.58%) ~ 34.13s 34.70s p=0.092 n=6
Emit Time 2.64s (± 3.81%) 2.64s (± 2.98%) ~ 2.56s 2.77s p=0.936 n=6
Total Time 43.99s (± 0.19%) 44.07s (± 0.39%) ~ 43.78s 44.31s p=0.230 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,592 258,617 +25 (+ 0.01%) ~ ~ p=0.001 n=6
Types 105,012 105,025 +13 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 428,264k (± 0.01%) 428,428k (± 0.01%) +165k (+ 0.04%) 428,359k 428,468k p=0.005 n=6
Parse Time 4.08s (± 0.22%) 4.07s (± 0.57%) ~ 4.05s 4.10s p=0.685 n=6
Bind Time 1.64s (± 1.89%) 1.67s (± 0.99%) ~ 1.64s 1.69s p=0.103 n=6
Check Time 22.39s (± 0.10%) 22.40s (± 0.38%) ~ 22.32s 22.52s p=1.000 n=6
Emit Time 1.72s (± 0.61%) 1.72s (± 0.70%) ~ 1.71s 1.74s p=0.868 n=6
Total Time 29.84s (± 0.20%) 29.87s (± 0.31%) ~ 29.76s 30.02s p=1.000 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,736 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 369,775k (± 0.01%) 369,980k (± 0.02%) +206k (+ 0.06%) 369,875k 370,097k p=0.005 n=6
Parse Time 2.84s (± 0.87%) 2.84s (± 1.03%) ~ 2.80s 2.87s p=1.000 n=6
Bind Time 1.58s (± 0.84%) 1.61s (± 0.64%) +0.03s (+ 1.80%) 1.59s 1.62s p=0.011 n=6
Check Time 15.72s (± 0.48%) 15.74s (± 0.38%) ~ 15.65s 15.82s p=0.376 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.14s (± 0.33%) 20.18s (± 0.40%) ~ 20.06s 20.30s p=0.226 n=6
vscode - node (v18.15.0, x64)
Errors 0 79 🔻+79 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 2,845,596 2,849,669 +4,073 (+ 0.14%) ~ ~ p=0.001 n=6
Types 964,085 964,978 +893 (+ 0.09%) ~ ~ p=0.001 n=6
Memory used 3,017,140k (± 0.00%) 3,021,037k (± 0.00%) +3,897k (+ 0.13%) 3,020,987k 3,021,138k p=0.005 n=6
Parse Time 13.90s (± 0.17%) 13.88s (± 0.23%) ~ 13.83s 13.93s p=0.326 n=6
Bind Time 4.23s (± 2.59%) 4.27s (± 1.80%) ~ 4.20s 4.42s p=0.230 n=6
Check Time 73.40s (± 0.42%) 75.35s (± 2.27%) +1.95s (+ 2.66%) 74.38s 78.83s p=0.005 n=6
Emit Time 23.70s (± 0.61%) 23.06s (± 7.06%) ~ 19.75s 23.90s p=0.810 n=6
Total Time 115.23s (± 0.26%) 116.57s (± 0.11%) +1.34s (+ 1.17%) 116.36s 116.75s p=0.005 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 266,361 266,362 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 108,554 108,557 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 411,328k (± 0.03%) 411,647k (± 0.02%) +320k (+ 0.08%) 411,571k 411,847k p=0.005 n=6
Parse Time 3.84s (± 0.39%) 3.84s (± 0.50%) ~ 3.82s 3.87s p=0.677 n=6
Bind Time 1.66s (± 0.82%) 1.70s (± 0.69%) +0.04s (+ 2.30%) 1.69s 1.72s p=0.005 n=6
Check Time 17.02s (± 0.27%) 17.12s (± 0.29%) +0.10s (+ 0.59%) 17.05s 17.19s p=0.008 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.52s (± 0.23%) 22.66s (± 0.22%) +0.14s (+ 0.61%) 22.62s 22.72s p=0.005 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 526,436 526,436 ~ ~ ~ p=1.000 n=6
Types 179,425 179,425 ~ ~ ~ p=1.000 n=6
Memory used 464,088k (± 0.06%) 464,116k (± 0.08%) ~ 463,817k 464,702k p=0.936 n=6
Parse Time 3.15s (± 0.56%) 3.16s (± 0.68%) ~ 3.13s 3.18s p=0.870 n=6
Bind Time 1.19s (± 0.43%) 1.20s (± 0.53%) +0.01s (+ 1.12%) 1.19s 1.21s p=0.009 n=6
Check Time 18.20s (± 0.30%) 18.12s (± 0.26%) -0.08s (- 0.47%) 18.05s 18.18s p=0.037 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.54s (± 0.30%) 22.48s (± 0.25%) ~ 22.37s 22.53s p=0.148 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user tests with tsc comparing main and refs/pull/58729/merge:

Something interesting changed - please have a look.

Details

enhanced-resolve

/mnt/ts_downloads/_/m/enhanced-resolve/tsconfig.json

  • [MISSING] error TS2339: Property 'replace' does not exist on type 'never'.
    • /mnt/ts_downloads/_/m/enhanced-resolve/node_modules/enhanced-resolve/lib/concord.js(149,24)
    • /mnt/ts_downloads/_/m/enhanced-resolve/node_modules/enhanced-resolve/lib/concord.js(188,17)

pyright

/mnt/ts_downloads/_/m/pyright/build.sh

  • [NEW] error TS18048: 'cacheEntry' is possibly 'undefined'.
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(951,25)
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(1064,41)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/analyzer/codeFlowEngine.ts(951,25)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/analyzer/codeFlowEngine.ts(1064,41)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(951,25)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(1064,41)

uglify-js

/mnt/ts_downloads/_/m/uglify-js/tsconfig.json

  • [MISSING] error TS18048: 'ldef' is possibly 'undefined'.
    • /mnt/ts_downloads/_/m/uglify-js/node_modules/uglify-js/lib/compress.js(6753,56)

xterm.js

src/tsconfig-library-base.json

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top 400 repos with tsc comparing main and refs/pull/58729/merge:

Something interesting changed - please have a look.

Details

apollographql/apollo-client

1 of 12 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS7022: 'match' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

src/tsconfig.json

  • error TS7022: 'match' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

conwnet/github1s

extensions/github1s/tsconfig.json

electron-react-boilerplate/electron-react-boilerplate

tsconfig.json

labring/FastGPT

projects/app/tsconfig.json

packages/service/tsconfig.json

lyswhut/lx-music-desktop

1 of 6 projects failed to build with the old tsc and were ignored

src/main/tsconfig.json

microsoft/vscode

4 of 54 projects failed to build with the old tsc and were ignored

src/tsconfig.tsec.json

src/tsconfig.monaco.json

src/tsconfig.json

extensions/vscode-test-resolver/tsconfig.json

extensions/vscode-api-tests/tsconfig.json

tinacms/tinacms

12 of 24 projects failed to build with the old tsc and were ignored

packages/@tinacms/mdx/tsconfig.json

@ethanresnick
Copy link
Contributor

ethanresnick commented Jun 5, 2024

@ahejlsberg If I'm understanding correctly, this would apply to arguments that are declared as arrow functions or function expressions, but not function declarations. Is that right? If so, why exclude function declarations?

(FWIW, I do like this experiment and the attempt at added strictness, if it ends up not being too breaking.)

@ahejlsberg
Copy link
Member Author

@ethanresnick It only applies to arrow functions and function expressions passed directly as arguments. It does not apply to functions referenced through identifiers or other indirect expression constructs.

@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@ahejlsberg
Copy link
Member Author

@typescript-bot test it

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s a slight issue with not considering deferred (or immediate, if we go that direction) in signature relations. I know we briefly discussed this having no effect on assignability, and I think that’s probably for the best, but I think it’s worth fixing subtype / strict subtype relations for union reduction. The current approach leads to a type ID order dependence bug [PR playground]:

// Swap the order of these two calls
fDeferred(() => {});
fImmediate(() => {});

declare function fDeferred(deferred cb: () => void): void;
declare function fImmediate(cb: () => void): void;

let f = Math.random() > 0.5 ? fDeferred : fImmediate;

let x: string | number = "OK";

f(() => {
  x = 10;
});

   x;
// ^?

The type of x is dependent on the type of f which is dependent on the order of the first two calls, since the signatures of fDeferred and fImmediate are indistinguishable in the strict subtype relation.

@ahejlsberg
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 8, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started 👀 Results
user test this ✅ Started 👀 Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user tests with tsc comparing main and refs/pull/58729/merge:

Something interesting changed - please have a look.

Details

enhanced-resolve

/mnt/ts_downloads/_/m/enhanced-resolve/tsconfig.json

  • [MISSING] error TS2339: Property 'replace' does not exist on type 'never'.
    • /mnt/ts_downloads/_/m/enhanced-resolve/node_modules/enhanced-resolve/lib/concord.js(149,24)
    • /mnt/ts_downloads/_/m/enhanced-resolve/node_modules/enhanced-resolve/lib/concord.js(188,17)

pyright

/mnt/ts_downloads/_/m/pyright/build.sh

  • [NEW] error TS18048: 'cacheEntry' is possibly 'undefined'.
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(981,25)
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(1105,41)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/analyzer/codeFlowEngine.ts(981,25)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/analyzer/codeFlowEngine.ts(1105,41)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(981,25)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/analyzer/codeFlowEngine.ts(1105,41)

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 193,609k (± 0.92%) 194,558k (± 0.91%) ~ 192,713k 196,242k p=0.066 n=6
Parse Time 1.57s (± 0.96%) 1.59s (± 1.10%) ~ 1.56s 1.61s p=0.211 n=6
Bind Time 0.85s (± 1.37%) 0.88s (± 1.33%) +0.03s (+ 3.13%) 0.86s 0.89s p=0.012 n=6
Check Time 11.35s (± 0.50%) 11.32s (± 0.40%) ~ 11.27s 11.38s p=0.628 n=6
Emit Time 3.23s (± 0.75%) 3.24s (± 0.23%) ~ 3.23s 3.25s p=0.075 n=6
Total Time 17.01s (± 0.42%) 17.03s (± 0.15%) ~ 16.99s 17.06s p=0.336 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 7 ~ ~ ~ p=1.000 n=6
Symbols 945,757 945,752 -5 (- 0.00%) ~ ~ p=0.001 n=6
Types 410,045 410,082 +37 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 1,222,457k (± 0.00%) 1,223,097k (± 0.00%) +641k (+ 0.05%) 1,223,068k 1,223,128k p=0.005 n=6
Parse Time 7.95s (± 0.42%) 7.95s (± 0.79%) ~ 7.87s 8.02s p=0.872 n=6
Bind Time 2.23s (± 0.18%) 2.28s (± 0.66%) +0.05s (+ 2.47%) 2.27s 2.31s p=0.004 n=6
Check Time 36.28s (± 0.54%) 36.30s (± 0.37%) ~ 36.15s 36.47s p=0.748 n=6
Emit Time 17.77s (± 0.35%) 17.86s (± 0.77%) ~ 17.74s 18.11s p=0.225 n=6
Total Time 64.22s (± 0.29%) 64.39s (± 0.38%) ~ 64.15s 64.83s p=0.296 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,487,631 2,487,654 +23 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,012,953 1,012,969 +16 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,493,621k (± 0.01%) 2,494,038k (± 0.01%) +416k (+ 0.02%) 2,493,890k 2,494,358k p=0.005 n=6
Parse Time 13.44s (± 0.45%) 13.45s (± 0.45%) ~ 13.36s 13.54s p=0.872 n=6
Bind Time 3.20s (± 0.88%) 3.21s (± 0.74%) ~ 3.18s 3.24s p=0.520 n=6
Check Time 109.30s (± 1.14%) 109.53s (± 0.84%) ~ 108.59s 111.20s p=0.378 n=6
Emit Time 0.40s (± 3.40%) 0.40s (± 2.06%) ~ 0.38s 0.40s p=0.101 n=6
Total Time 126.33s (± 1.00%) 126.58s (± 0.74%) ~ 125.66s 128.32s p=0.378 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,292 1,229,795 +503 (+ 0.04%) ~ ~ p=0.001 n=6
Types 264,032 264,159 +127 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 2,348,388k (± 0.03%) 2,472,550k (± 7.41%) 🔻+124,162k (+ 5.29%) 2,353,335k 2,709,589k p=0.005 n=6
Parse Time 6.07s (± 0.65%) 6.09s (± 0.72%) ~ 6.05s 6.16s p=0.572 n=6
Bind Time 2.25s (± 1.08%) 2.35s (± 1.73%) 🔻+0.10s (+ 4.67%) 2.30s 2.41s p=0.005 n=6
Check Time 40.82s (± 0.67%) 40.83s (± 0.74%) ~ 40.30s 41.15s p=0.689 n=6
Emit Time 4.05s (± 2.13%) 4.01s (± 1.16%) ~ 3.94s 4.06s p=0.575 n=6
Total Time 53.21s (± 0.58%) 53.30s (± 0.65%) ~ 52.77s 53.71s p=0.810 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,292 1,229,795 +503 (+ 0.04%) ~ ~ p=0.001 n=6
Types 264,032 264,159 +127 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 2,422,365k (± 0.05%) 2,486,773k (± 5.80%) +64,408k (+ 2.66%) 2,427,642k 2,781,443k p=0.005 n=6
Parse Time 6.25s (± 1.15%) 6.33s (± 0.87%) ~ 6.26s 6.40s p=0.066 n=6
Bind Time 2.02s (± 1.06%) 2.40s (± 1.68%) 🔻+0.37s (+18.47%) 2.33s 2.45s p=0.005 n=6
Check Time 41.41s (± 0.92%) 40.94s (± 0.52%) -0.47s (- 1.14%) 40.53s 41.09s p=0.031 n=6
Emit Time 4.06s (± 2.84%) 4.06s (± 0.98%) ~ 4.00s 4.11s p=1.000 n=6
Total Time 53.76s (± 0.80%) 53.73s (± 0.36%) ~ 53.42s 53.94s p=0.936 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,694 256,830 +136 (+ 0.05%) ~ ~ p=0.001 n=6
Types 105,545 105,615 +70 (+ 0.07%) ~ ~ p=0.001 n=6
Memory used 428,918k (± 0.02%) 429,740k (± 0.01%) +821k (+ 0.19%) 429,713k 429,788k p=0.005 n=6
Parse Time 4.16s (± 0.38%) 4.17s (± 0.55%) ~ 4.15s 4.21s p=0.565 n=6
Bind Time 1.61s (± 1.91%) 1.63s (± 0.60%) ~ 1.61s 1.64s p=0.211 n=6
Check Time 22.30s (± 0.41%) 22.39s (± 0.34%) ~ 22.32s 22.50s p=0.092 n=6
Emit Time 2.02s (± 1.46%) 2.03s (± 0.59%) ~ 2.02s 2.05s p=0.935 n=6
Total Time 30.08s (± 0.28%) 30.22s (± 0.21%) +0.14s (+ 0.47%) 30.15s 30.33s p=0.030 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 225,018 225,018 ~ ~ ~ p=1.000 n=6
Types 94,245 94,245 ~ ~ ~ p=1.000 n=6
Memory used 370,225k (± 0.04%) 370,391k (± 0.03%) +166k (+ 0.04%) 370,252k 370,510k p=0.045 n=6
Parse Time 3.44s (± 0.56%) 3.47s (± 0.89%) ~ 3.42s 3.50s p=0.124 n=6
Bind Time 1.92s (± 0.97%) 1.97s (± 0.89%) +0.06s (+ 2.96%) 1.94s 1.99s p=0.008 n=6
Check Time 19.30s (± 0.45%) 19.42s (± 0.30%) ~ 19.37s 19.50s p=0.108 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.66s (± 0.38%) 24.86s (± 0.24%) +0.20s (+ 0.81%) 24.77s 24.95s p=0.010 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,995,242 2,995,246 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,032,059 1,032,072 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,120,605k (± 0.00%) 3,121,257k (± 0.00%) +652k (+ 0.02%) 3,121,170k 3,121,369k p=0.005 n=6
Parse Time 17.02s (± 0.32%) 17.14s (± 0.19%) +0.11s (+ 0.67%) 17.08s 17.17s p=0.013 n=6
Bind Time 5.24s (± 0.39%) 5.28s (± 0.22%) +0.04s (+ 0.86%) 5.27s 5.30s p=0.007 n=6
Check Time 96.69s (± 0.34%) 96.59s (± 0.29%) ~ 96.25s 96.87s p=0.810 n=6
Emit Time 25.00s (± 0.86%) 24.99s (± 0.57%) ~ 24.79s 25.12s p=0.810 n=6
Total Time 143.95s (± 0.23%) 144.00s (± 0.24%) ~ 143.64s 144.44s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 271,703 271,703 ~ ~ ~ p=1.000 n=6
Types 110,714 110,714 ~ ~ ~ p=1.000 n=6
Memory used 417,637k (± 0.01%) 418,169k (± 0.01%) +532k (+ 0.13%) 418,130k 418,196k p=0.005 n=6
Parse Time 3.83s (± 0.75%) 3.88s (± 0.66%) +0.05s (+ 1.26%) 3.84s 3.90s p=0.029 n=6
Bind Time 1.69s (± 1.33%) 1.76s (± 1.10%) 🔻+0.07s (+ 4.04%) 1.74s 1.79s p=0.005 n=6
Check Time 16.98s (± 0.40%) 17.06s (± 0.38%) ~ 16.96s 17.14s p=0.077 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.50s (± 0.32%) 22.71s (± 0.31%) +0.20s (+ 0.89%) 22.59s 22.80s p=0.008 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 538,614 538,614 ~ ~ ~ p=1.000 n=6
Types 176,536 176,536 ~ ~ ~ p=1.000 n=6
Memory used 481,404k (± 0.01%) 481,817k (± 0.02%) +413k (+ 0.09%) 481,735k 481,927k p=0.005 n=6
Parse Time 2.83s (± 0.71%) 2.83s (± 0.85%) ~ 2.81s 2.87s p=1.000 n=6
Bind Time 1.04s (± 0.61%) 1.09s 🔻+0.05s (+ 4.81%) ~ ~ p=0.002 n=6
Check Time 15.29s (± 0.39%) 15.30s (± 0.39%) ~ 15.21s 15.34s p=0.686 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.16s (± 0.23%) 19.22s (± 0.35%) ~ 19.12s 19.29s p=0.173 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top 400 repos with tsc comparing main and refs/pull/58729/merge:

Something interesting changed - please have a look.

Details

tinacms/tinacms

11 of 23 projects failed to build with the old tsc and were ignored

packages/@tinacms/mdx/tsconfig.json

@ahejlsberg
Copy link
Member Author

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 8, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 192,926k (± 0.77%) 194,413k (± 1.02%) +1,487k (+ 0.77%) 192,600k 196,272k p=0.020 n=6
Parse Time 1.94s (± 0.56%) 1.96s (± 1.10%) +0.02s (+ 1.20%) 1.94s 2.00s p=0.046 n=6
Bind Time 1.06s (± 1.29%) 1.09s (± 0.47%) +0.03s (+ 2.84%) 1.08s 1.09s p=0.007 n=6
Check Time 14.08s (± 1.10%) 14.06s (± 0.22%) ~ 14.02s 14.11s p=0.809 n=6
Emit Time 3.97s (± 1.63%) 4.00s (± 0.47%) ~ 3.97s 4.02s p=0.746 n=6
Total Time 21.05s (± 0.65%) 21.10s (± 0.14%) ~ 21.05s 21.14s p=0.172 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 7 ~ ~ ~ p=1.000 n=6
Symbols 945,757 945,752 -5 (- 0.00%) ~ ~ p=0.001 n=6
Types 410,045 410,082 +37 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 1,222,503k (± 0.00%) 1,223,132k (± 0.00%) +629k (+ 0.05%) 1,223,093k 1,223,214k p=0.005 n=6
Parse Time 7.89s (± 0.91%) 7.93s (± 0.71%) ~ 7.87s 7.99s p=0.378 n=6
Bind Time 2.21s (± 0.37%) 2.27s (± 0.36%) +0.05s (+ 2.41%) 2.26s 2.28s p=0.003 n=6
Check Time 36.20s (± 0.26%) 36.34s (± 0.51%) ~ 36.13s 36.62s p=0.149 n=6
Emit Time 17.70s (± 0.37%) 17.76s (± 0.34%) ~ 17.64s 17.80s p=0.090 n=6
Total Time 64.00s (± 0.09%) 64.30s (± 0.34%) +0.30s (+ 0.47%) 64.01s 64.58s p=0.020 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,487,631 2,487,654 +23 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,012,953 1,012,969 +16 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,493,587k (± 0.01%) 2,493,965k (± 0.00%) +378k (+ 0.02%) 2,493,888k 2,494,012k p=0.005 n=6
Parse Time 10.95s (± 0.29%) 10.93s (± 0.29%) ~ 10.88s 10.96s p=0.373 n=6
Bind Time 2.61s (± 0.45%) 2.63s (± 0.24%) +0.02s (+ 0.83%) 2.62s 2.64s p=0.007 n=6
Check Time 89.50s (± 0.51%) 89.50s (± 0.36%) ~ 89.00s 89.90s p=0.936 n=6
Emit Time 0.33s (± 2.57%) 0.34s (± 2.22%) 🔻+0.01s (+ 4.10%) 0.33s 0.35s p=0.030 n=6
Total Time 103.39s (± 0.46%) 103.40s (± 0.30%) ~ 102.94s 103.79s p=0.873 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,498 1,230,001 +503 (+ 0.04%) ~ ~ p=0.001 n=6
Types 264,061 264,188 +127 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 2,468,078k (±11.76%) 2,354,875k (± 0.04%) ~ 2,353,520k 2,355,889k p=0.066 n=6
Parse Time 7.52s (± 1.70%) 7.54s (± 0.63%) ~ 7.49s 7.60s p=0.199 n=6
Bind Time 2.77s (± 0.87%) 2.92s (± 0.82%) 🔻+0.15s (+ 5.23%) 2.88s 2.94s p=0.005 n=6
Check Time 50.56s (± 0.86%) 50.74s (± 0.74%) ~ 50.35s 51.30s p=0.298 n=6
Emit Time 5.01s (± 4.58%) 5.09s (± 3.54%) ~ 4.94s 5.36s p=0.336 n=6
Total Time 65.91s (± 0.58%) 66.32s (± 0.46%) ~ 65.95s 66.67s p=0.066 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,498 1,230,001 +503 (+ 0.04%) ~ ~ p=0.001 n=6
Types 264,061 264,188 +127 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 2,423,316k (± 0.02%) 2,427,894k (± 0.02%) +4,578k (+ 0.19%) 2,427,190k 2,428,315k p=0.005 n=6
Parse Time 6.22s (± 0.78%) 6.30s (± 0.66%) +0.08s (+ 1.37%) 6.25s 6.35s p=0.020 n=6
Bind Time 2.02s (± 0.68%) 2.38s (± 0.93%) 🔻+0.36s (+17.61%) 2.35s 2.42s p=0.005 n=6
Check Time 41.18s (± 0.44%) 41.06s (± 0.27%) ~ 40.87s 41.20s p=0.230 n=6
Emit Time 4.07s (± 3.79%) 4.20s (± 4.08%) +0.13s (+ 3.11%) 4.08s 4.47s p=0.045 n=6
Total Time 53.51s (± 0.30%) 53.96s (± 0.24%) +0.45s (+ 0.85%) 53.82s 54.20s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,739 256,875 +136 (+ 0.05%) ~ ~ p=0.001 n=6
Types 105,560 105,630 +70 (+ 0.07%) ~ ~ p=0.001 n=6
Memory used 428,907k (± 0.01%) 429,683k (± 0.01%) +776k (+ 0.18%) 429,628k 429,738k p=0.005 n=6
Parse Time 3.36s (± 0.45%) 3.35s (± 0.52%) ~ 3.34s 3.38s p=0.744 n=6
Bind Time 1.32s (± 0.93%) 1.32s (± 1.41%) ~ 1.31s 1.36s p=0.655 n=6
Check Time 18.07s (± 0.24%) 18.15s (± 0.45%) ~ 18.03s 18.26s p=0.128 n=6
Emit Time 1.64s (± 1.88%) 1.66s (± 1.12%) ~ 1.64s 1.69s p=0.125 n=6
Total Time 24.38s (± 0.13%) 24.49s (± 0.32%) +0.11s (+ 0.44%) 24.40s 24.61s p=0.010 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 225,018 225,018 ~ ~ ~ p=1.000 n=6
Types 94,245 94,245 ~ ~ ~ p=1.000 n=6
Memory used 370,197k (± 0.04%) 370,385k (± 0.03%) ~ 370,291k 370,538k p=0.066 n=6
Parse Time 2.76s (± 0.58%) 2.78s (± 1.05%) ~ 2.74s 2.81s p=0.256 n=6
Bind Time 1.57s (± 0.70%) 1.61s (± 0.61%) +0.04s (+ 2.65%) 1.60s 1.63s p=0.004 n=6
Check Time 15.67s (± 0.31%) 15.72s (± 0.53%) ~ 15.59s 15.80s p=0.377 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.00s (± 0.18%) 20.11s (± 0.45%) +0.10s (+ 0.52%) 19.94s 20.18s p=0.044 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,995,250 2,995,254 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,032,086 1,032,099 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,120,649k (± 0.00%) 3,121,303k (± 0.00%) +655k (+ 0.02%) 3,121,181k 3,121,441k p=0.005 n=6
Parse Time 16.99s (± 0.17%) 17.14s (± 0.25%) +0.16s (+ 0.91%) 17.10s 17.21s p=0.005 n=6
Bind Time 5.26s (± 1.77%) 5.28s (± 0.53%) ~ 5.26s 5.33s p=0.063 n=6
Check Time 96.55s (± 0.27%) 97.01s (± 0.21%) +0.46s (+ 0.48%) 96.75s 97.34s p=0.020 n=6
Emit Time 25.16s (± 0.58%) 25.00s (± 0.47%) ~ 24.87s 25.18s p=0.078 n=6
Total Time 143.95s (± 0.23%) 144.42s (± 0.15%) +0.48s (+ 0.33%) 144.20s 144.78s p=0.020 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 273,789 273,789 ~ ~ ~ p=1.000 n=6
Types 111,669 111,669 ~ ~ ~ p=1.000 n=6
Memory used 419,923k (± 0.02%) 420,355k (± 0.02%) +432k (+ 0.10%) 420,245k 420,457k p=0.005 n=6
Parse Time 4.92s (± 0.44%) 4.91s (± 0.43%) ~ 4.89s 4.94s p=0.627 n=6
Bind Time 2.11s (± 0.98%) 2.16s (± 0.63%) +0.05s (+ 2.29%) 2.14s 2.18s p=0.006 n=6
Check Time 21.10s (± 0.29%) 21.35s (± 0.77%) +0.25s (+ 1.18%) 21.15s 21.55s p=0.010 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.13s (± 0.24%) 28.43s (± 0.55%) +0.30s (+ 1.05%) 28.22s 28.62s p=0.005 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 538,614 538,614 ~ ~ ~ p=1.000 n=6
Types 176,536 176,536 ~ ~ ~ p=1.000 n=6
Memory used 481,460k (± 0.01%) 481,823k (± 0.00%) +363k (+ 0.08%) 481,807k 481,839k p=0.005 n=6
Parse Time 3.38s (± 0.95%) 3.38s (± 0.54%) ~ 3.36s 3.40s p=0.809 n=6
Bind Time 1.24s (± 1.11%) 1.31s (± 0.39%) 🔻+0.06s (+ 4.95%) 1.30s 1.31s p=0.004 n=6
Check Time 18.04s (± 0.51%) 18.09s (± 0.20%) ~ 18.03s 18.13s p=0.335 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.67s (± 0.47%) 22.78s (± 0.14%) +0.11s (+ 0.49%) 22.72s 22.81s p=0.012 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@jakebailey
Copy link
Member

@typescript-bot perf test this faster predictable=true

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 8, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster predictable=true ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

@jakebailey
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
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 192,317k 192,541k +224k (+ 0.12%) ~ ~ p=0.001 n=6
Parse Time 1.28s (± 0.40%) 1.29s +0.01s (+ 0.52%) ~ ~ p=0.025 n=6
Bind Time 0.71s (± 0.73%) 0.73s (± 0.71%) +0.02s (+ 2.83%) 0.72s 0.73s p=0.004 n=6
Check Time 9.35s (± 0.12%) 9.21s (± 0.06%) -0.14s (- 1.44%) 9.21s 9.22s p=0.004 n=6
Emit Time 2.89s (± 0.18%) 2.98s (± 0.14%) +0.09s (+ 3.05%) 2.98s 2.99s p=0.003 n=6
Total Time 14.24s (± 0.07%) 14.21s (± 0.04%) -0.02s (- 0.15%) 14.21s 14.22s p=0.007 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 7 ~ ~ ~ p=1.000 n=6
Symbols 945,757 945,752 -5 (- 0.00%) ~ ~ p=0.001 n=6
Types 410,045 410,082 +37 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 1,222,697k (± 0.00%) 1,223,212k (± 0.01%) +515k (+ 0.04%) 1,223,101k 1,223,382k p=0.004 n=6
Parse Time 6.27s (± 0.14%) 6.31s (± 0.25%) +0.04s (+ 0.64%) 6.30s 6.34s p=0.004 n=6
Bind Time 1.85s (± 0.28%) 1.92s (± 0.64%) +0.06s (+ 3.33%) 1.91s 1.94s p=0.003 n=6
Check Time 35.27s (± 0.18%) 33.63s (± 0.16%) 🟩-1.64s (- 4.64%) 33.58s 33.73s p=0.005 n=6
Emit Time 14.65s (± 0.19%) 16.69s (± 0.22%) 🔻+2.04s (+13.92%) 16.65s 16.74s p=0.005 n=6
Total Time 58.04s (± 0.13%) 58.55s (± 0.05%) +0.51s (+ 0.87%) 58.52s 58.59s p=0.005 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,487,631 2,487,654 +23 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,012,953 1,012,969 +16 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,493,838k 2,494,479k +641k (+ 0.03%) ~ ~ p=0.001 n=6
Parse Time 8.93s (± 0.06%) 8.93s (± 0.15%) ~ 8.92s 8.95s p=0.794 n=6
Bind Time 2.81s (± 0.18%) 2.27s (± 0.23%) 🟩-0.54s (-19.19%) 2.27s 2.28s p=0.004 n=6
Check Time 77.26s (± 0.11%) 77.23s (± 0.05%) ~ 77.18s 77.28s p=0.298 n=6
Emit Time 0.29s 0.29s ~ ~ ~ p=1.000 n=6
Total Time 89.29s (± 0.09%) 88.73s (± 0.05%) -0.56s (- 0.63%) 88.67s 88.78s p=0.005 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,498 1,230,001 +503 (+ 0.04%) ~ ~ p=0.001 n=6
Types 264,061 264,188 +127 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 2,350,880k (± 0.00%) 2,355,888k (± 0.00%) +5,008k (+ 0.21%) 2,355,874k 2,355,947k p=0.005 n=6
Parse Time 5.75s (± 0.32%) 5.85s (± 0.13%) +0.10s (+ 1.80%) 5.84s 5.86s p=0.005 n=6
Bind Time 2.11s (± 0.24%) 2.31s (± 0.35%) 🔻+0.19s (+ 9.15%) 2.29s 2.31s p=0.003 n=6
Check Time 41.18s (± 0.06%) 41.61s (± 0.10%) +0.43s (+ 1.03%) 41.56s 41.66s p=0.005 n=6
Emit Time 4.18s (± 0.18%) 4.19s (± 0.29%) ~ 4.17s 4.20s p=0.323 n=6
Total Time 53.24s (± 0.06%) 53.96s (± 0.09%) +0.72s (+ 1.35%) 53.89s 54.02s p=0.005 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,229,498 1,230,001 +503 (+ 0.04%) ~ ~ p=0.001 n=6
Types 264,061 264,188 +127 (+ 0.05%) ~ ~ p=0.001 n=6
Memory used 2,423,250k (± 0.00%) 2,428,200k +4,950k (+ 0.20%) ~ ~ p=0.002 n=6
Parse Time 4.94s (± 0.17%) 5.00s (± 0.10%) +0.06s (+ 1.18%) 5.00s 5.01s p=0.004 n=6
Bind Time 1.70s (± 0.24%) 1.81s (± 0.23%) 🔻+0.11s (+ 6.46%) 1.81s 1.82s p=0.003 n=6
Check Time 35.37s (± 0.07%) 35.60s (± 0.12%) +0.23s (+ 0.65%) 35.53s 35.66s p=0.005 n=6
Emit Time 3.56s (± 0.15%) 3.57s (± 0.18%) +0.01s (+ 0.37%) 3.56s 3.58s p=0.009 n=6
Total Time 45.59s (± 0.07%) 45.96s (± 0.09%) +0.37s (+ 0.82%) 45.89s 46.02s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,739 256,875 +136 (+ 0.05%) ~ ~ p=0.001 n=6
Types 105,560 105,630 +70 (+ 0.07%) ~ ~ p=0.001 n=6
Memory used 428,755k 429,618k +863k (+ 0.20%) ~ ~ p=0.001 n=6
Parse Time 3.16s (± 0.38%) 3.15s (± 0.33%) ~ 3.14s 3.17s p=0.180 n=6
Bind Time 1.46s (± 0.35%) 1.50s +0.04s (+ 2.51%) ~ ~ p=0.002 n=6
Check Time 18.12s (± 0.24%) 18.19s (± 0.08%) ~ 18.17s 18.20s p=0.062 n=6
Emit Time 1.63s (± 0.33%) 1.65s (± 0.31%) +0.01s (+ 0.71%) 1.64s 1.65s p=0.013 n=6
Total Time 24.39s (± 0.16%) 24.49s (± 0.09%) +0.10s (+ 0.41%) 24.46s 24.51s p=0.007 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 225,018 225,018 ~ ~ ~ p=1.000 n=6
Types 94,245 94,245 ~ ~ ~ p=1.000 n=6
Memory used 370,111k 370,356k +245k (+ 0.07%) ~ ~ p=0.001 n=6
Parse Time 3.42s (± 0.40%) 3.45s (± 0.57%) +0.03s (+ 0.88%) 3.43s 3.48s p=0.016 n=6
Bind Time 1.73s (± 0.24%) 1.78s (± 0.23%) +0.05s (+ 3.09%) 1.78s 1.79s p=0.003 n=6
Check Time 19.89s (± 0.07%) 19.88s (± 0.13%) ~ 19.86s 19.93s p=0.277 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 25.04s (± 0.10%) 25.11s (± 0.11%) +0.07s (+ 0.29%) 25.08s 25.15s p=0.005 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,995,021 2,995,025 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,032,070 1,032,083 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,120,667k (± 0.00%) 3,121,565k (± 0.00%) +897k (+ 0.03%) 3,121,556k 3,121,605k p=0.003 n=6
Parse Time 14.39s (± 0.17%) 14.52s (± 0.06%) +0.13s (+ 0.87%) 14.50s 14.52s p=0.004 n=6
Bind Time 4.48s (± 0.14%) 4.72s (± 0.18%) 🔻+0.24s (+ 5.25%) 4.71s 4.73s p=0.004 n=6
Check Time 77.44s (± 0.15%) 77.50s (± 0.11%) ~ 77.39s 77.60s p=0.295 n=6
Emit Time 26.01s (± 0.24%) 25.98s (± 0.23%) ~ 25.91s 26.06s p=0.470 n=6
Total Time 122.32s (± 0.12%) 122.71s (± 0.09%) +0.39s (+ 0.32%) 122.55s 122.87s p=0.006 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 273,789 273,789 ~ ~ ~ p=1.000 n=6
Types 111,669 111,669 ~ ~ ~ p=1.000 n=6
Memory used 419,865k 420,361k +496k (+ 0.12%) ~ ~ p=0.001 n=6
Parse Time 3.81s (± 0.26%) 3.95s (± 0.19%) +0.14s (+ 3.68%) 3.94s 3.96s p=0.004 n=6
Bind Time 1.77s 1.83s +0.06s (+ 3.39%) ~ ~ p=0.001 n=6
Check Time 16.94s (± 0.03%) 17.07s (± 0.07%) +0.13s (+ 0.79%) 17.06s 17.09s p=0.004 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.52s (± 0.06%) 22.84s (± 0.05%) +0.33s (+ 1.46%) 22.83s 22.86s p=0.005 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 538,614 538,614 ~ ~ ~ p=1.000 n=6
Types 176,536 176,536 ~ ~ ~ p=1.000 n=6
Memory used 481,455k 481,794k +339k (+ 0.07%) ~ ~ p=0.001 n=6
Parse Time 3.23s (± 0.32%) 3.23s (± 0.46%) ~ 3.22s 3.26s p=0.558 n=6
Bind Time 1.48s 1.51s (± 0.27%) +0.03s (+ 2.14%) 1.51s 1.52s p=0.002 n=6
Check Time 18.00s (± 0.12%) 18.01s (± 0.12%) ~ 17.99s 18.05s p=0.464 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.71s (± 0.09%) 22.75s (± 0.14%) +0.04s (+ 0.19%) 22.72s 22.80s p=0.030 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@ahejlsberg
Copy link
Member Author

@jakebailey Asking for predictable seems to have very unpredictable effects. 😮

@ahejlsberg
Copy link
Member Author

@jakebailey The issue with switching to actual immediate modifiers is that we need an updated ESLint.

@jakebailey
Copy link
Member

Asking for predictable seems to have very unpredictable effects. 😮

The error bars are 3-4x smaller! 😄 But yes, don't use this feature, I'm still not sure if it's a good thing or not.

The issue with switching to actual immediate modifiers is that we need an updated ESLint.

Ah, right. Theoretically we can exclude src/lib from both linting and formatting temporarily. But, let me see if I can switch to the keyword locally and compare profiles before or after to see if there's some potential JSDoc win... (I assume you didn't commit that to a branch somewhere?)

@jakebailey
Copy link
Member

Even with the keyword, #59580 (comment) shows roughly the same perf regression in bind. Still not sure what it could be reading 5ae48a2 (#58729).

@dgreensp
Copy link

dgreensp commented Sep 23, 2024

I'm just a passer-by (who writes a lot of TypeScript), who got excited by the prospect of a new keyword that would improve CFA or soundness, but I'm not sure I understand the motivation here, relative to the magnitude of the change (new syntax).

I guess it started as an effort to improve soundness by considering that called functions might have side effects, and now it basically helps correct for overzealous CFA.

Here is another case (not related to this feature) where CFA thinks it knows everything and narrows the type annotation of a local variable:

function foo(a: number[], i: number) {
    // I'm serious, Typescript, I'm saying this could be out-of-bounds!
    const n: number | undefined = a[i];
    const n2 = n; // : number
}

In both cases, you have to occasionally override CFA, e.g. in the example at the top of this thread, one could write:

declare function mystery(cb: () => void): void;

let x: string | number = "OK" as string | number;
mystery(() => {
    x = 10;
});
if (x === 10) { // works
}

In terms of the larger issue of side effects, I think it should at least be acknowledged that passing any closure to any function could lead to functions having side effects that affect local variables; it doesn't really depend on whether a callback is invoked "immediately" or "deferred."

For example:

const foo = new Foo(() => { /* ... set a local variable */ });
foo.execute();

Here, the callback is not called immediately, but it is called during the course of the function. The point is, the question of whether a callback might be called immediately or not by a function is only loosely connected to the question of whether a function call has side effects that might affect the analysis of local variables.

I think an annotation that says "this callback is called exactly once, synchronously" or "this callback is called at least once, synchronously" might even be more useful? It would serve a slightly different purpose. If this keyword opens the door to other keywords, I'm for it. There are a lot of keywords I would want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet