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

Only collect outermost intra expression inference sites #54186

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented May 8, 2023

It's a potential perf improvement. However, I don't expect this to yield significant gains in the automated tests - this can probably only show in more pathological cases with big objects used as arguments. It happens that in XState we deal with such so maybe I would be able to gather some more concrete data based on that.

At the moment, in a case like this:

declare function fn<T>(args: {
  foo: {
    bar: {
      baz: {
        producer: (arg: unknown) => T;
      };
    };
  };
  consumer: (val: T) => unknown;
}): T;

fn({
  foo: { // 4
    bar: { // 3
      baz: { // 2
        producer: (arg) => 1, // 1 (function itself)
      },
    },
  },
  consumer: (val) => {},
});

we collect four intra expression inference sites. The innermost function (site 1) "taints" all the objects containing it (minus the root one). This is because isContextSensitive is recursive.

This means that isContextSensitive has to be computed at all of those levels and that we end up inferring from all of those levels separately within inferFromIntraExpressionSites. Most of that work is more than duplicated here since the outermost expression contains all of the information that can be found in the expressions contained in it.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 8, 2023
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

1 similar comment
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@jakebailey
Copy link
Member

The perf machine is currently offline but I'll run that once it's back again and caught up. If you can show a diff before/after in your xstate case that'd be helpful!

@typescript-bot test this
@typescript-bot test top100
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 8, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 2aa9fe4. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 8, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 2aa9fe4. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 8, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at 2aa9fe4. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 8, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 2aa9fe4. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 8, 2023

Heya @jakebailey, I've started to run the extended test suite on this PR at 2aa9fe4. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 8, 2023

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/153998/artifacts?artifactName=tgz&fileId=E36702A34E86C3816B3C2F07FEF8A0CF4762934C08DD8495071314DAEC9DED1002&fileName=/typescript-5.1.0-insiders.20230508.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/54186/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/54186/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@jakebailey
Copy link
Member

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 9, 2023

Heya @jakebailey, I've started to run the abridged perf test suite on this PR at a8a2ff5. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..54186

Metric main 54186 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 365,382k (± 0.01%) 365,389k (± 0.02%) ~ 365,303k 365,432k p=1.000 n=6
Parse Time 3.55s (± 0.38%) 3.55s (± 0.65%) ~ 3.52s 3.58s p=1.000 n=6
Bind Time 1.17s (± 0.44%) 1.17s (± 0.88%) ~ 1.16s 1.19s p=0.928 n=6
Check Time 9.62s (± 0.40%) 9.55s (± 0.43%) -0.07s (- 0.73%) 9.51s 9.63s p=0.019 n=6
Emit Time 7.93s (± 0.50%) 7.91s (± 0.41%) ~ 7.85s 7.94s p=0.226 n=6
Total Time 22.27s (± 0.24%) 22.18s (± 0.21%) -0.08s (- 0.38%) 22.14s 22.26s p=0.030 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,362k (± 0.70%) 192,766k (± 0.04%) ~ 192,696k 192,866k p=0.173 n=6
Parse Time 1.59s (± 1.72%) 1.60s (± 0.66%) ~ 1.58s 1.61s p=0.935 n=6
Bind Time 0.82s (± 0.77%) 0.82s (± 0.99%) ~ 0.81s 0.83s p=0.432 n=6
Check Time 10.36s (± 0.50%) 10.28s (± 0.51%) -0.08s (- 0.76%) 10.23s 10.37s p=0.036 n=6
Emit Time 3.02s (± 0.77%) 3.01s (± 0.71%) ~ 2.98s 3.04s p=0.683 n=6
Total Time 15.78s (± 0.50%) 15.71s (± 0.26%) ~ 15.67s 15.79s p=0.076 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,845k (± 0.01%) 345,854k (± 0.01%) ~ 345,830k 345,882k p=0.575 n=6
Parse Time 2.74s (± 0.64%) 2.72s (± 0.60%) ~ 2.71s 2.75s p=0.117 n=6
Bind Time 1.08s (± 0.48%) 1.09s (± 0.50%) ~ 1.08s 1.09s p=0.640 n=6
Check Time 7.89s (± 0.33%) 7.84s (± 0.36%) -0.05s (- 0.63%) 7.81s 7.87s p=0.020 n=6
Emit Time 4.53s (± 1.23%) 4.46s (± 0.27%) -0.06s (- 1.44%) 4.45s 4.48s p=0.015 n=6
Total Time 16.25s (± 0.45%) 16.12s (± 0.28%) -0.13s (- 0.79%) 16.06s 16.17s p=0.020 n=6
TFS - node (v16.17.1, x64)
Memory used 300,094k (± 0.01%) 300,097k (± 0.01%) ~ 300,051k 300,139k p=0.936 n=6
Parse Time 2.17s (± 1.00%) 2.16s (± 0.65%) ~ 2.14s 2.18s p=0.870 n=6
Bind Time 1.24s (± 0.98%) 1.23s (± 1.11%) ~ 1.22s 1.25s p=0.868 n=6
Check Time 7.28s (± 0.34%) 7.27s (± 0.55%) ~ 7.22s 7.33s p=0.803 n=6
Emit Time 4.38s (± 0.47%) 4.37s (± 0.37%) ~ 4.35s 4.39s p=0.121 n=6
Total Time 15.07s (± 0.37%) 15.04s (± 0.41%) ~ 14.96s 15.10s p=0.295 n=6
material-ui - node (v16.17.1, x64)
Memory used 481,628k (± 0.02%) 481,660k (± 0.01%) ~ 481,550k 481,722k p=0.298 n=6
Parse Time 3.26s (± 0.39%) 3.24s (± 0.37%) ~ 3.23s 3.26s p=0.067 n=6
Bind Time 0.94s (± 0.67%) 0.93s (± 0.44%) -0.01s (- 0.89%) 0.93s 0.94s p=0.033 n=6
Check Time 18.04s (± 0.71%) 17.88s (± 0.43%) -0.16s (- 0.91%) 17.80s 17.99s p=0.024 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.24s (± 0.59%) 22.06s (± 0.39%) -0.19s (- 0.84%) 21.97s 22.17s p=0.025 n=6
xstate - node (v16.17.1, x64)
Memory used 560,483k (± 0.01%) 560,400k (± 0.02%) ~ 560,313k 560,518k p=0.128 n=6
Parse Time 4.01s (± 0.32%) 3.99s (± 0.41%) ~ 3.97s 4.02s p=0.071 n=6
Bind Time 1.76s (± 0.31%) 1.75s (± 0.47%) -0.01s (- 0.66%) 1.75s 1.77s p=0.027 n=6
Check Time 3.06s (± 0.43%) 3.05s (± 0.64%) ~ 3.02s 3.07s p=0.406 n=6
Emit Time 0.09s (± 7.02%) 0.09s (± 4.62%) ~ 0.08s 0.09s p=0.673 n=6
Total Time 8.92s (± 0.28%) 8.89s (± 0.29%) ~ 8.86s 8.92s p=0.065 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 54186 6
Baseline main 6

Developer Information:

Download Benchmark

@jakebailey
Copy link
Member

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 9, 2023

Heya @jakebailey, I've started to run the abridged perf test suite on this PR at a8a2ff5. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..54186

Metric main 54186 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 365,269k (± 0.00%) 365,399k (± 0.01%) +131k (+ 0.04%) 365,365k 365,447k p=0.005 n=6
Parse Time 3.56s (± 0.43%) 3.57s (± 0.78%) ~ 3.54s 3.62s p=0.869 n=6
Bind Time 1.18s (± 1.16%) 1.17s (± 0.35%) ~ 1.17s 1.18s p=0.528 n=6
Check Time 9.60s (± 0.79%) 9.62s (± 0.49%) ~ 9.54s 9.68s p=0.747 n=6
Emit Time 7.86s (± 0.55%) 7.95s (± 0.70%) +0.09s (+ 1.10%) 7.90s 8.03s p=0.030 n=6
Total Time 22.20s (± 0.60%) 22.31s (± 0.47%) ~ 22.18s 22.49s p=0.229 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,661k (± 0.05%) 192,786k (± 0.02%) +124k (+ 0.06%) 192,731k 192,834k p=0.031 n=6
Parse Time 1.58s (± 1.90%) 1.59s (± 0.73%) ~ 1.58s 1.61s p=0.935 n=6
Bind Time 0.83s (± 0.66%) 0.83s (± 0.62%) ~ 0.82s 0.83s p=0.640 n=6
Check Time 10.41s (± 0.52%) 10.31s (± 0.61%) -0.10s (- 0.98%) 10.22s 10.41s p=0.030 n=6
Emit Time 3.05s (± 5.14%) 3.02s (± 0.83%) ~ 2.99s 3.05s p=0.227 n=6
Total Time 15.87s (± 1.27%) 15.75s (± 0.35%) ~ 15.70s 15.84s p=0.108 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,873k (± 0.01%) 345,859k (± 0.00%) ~ 345,839k 345,873k p=0.199 n=6
Parse Time 2.72s (± 0.63%) 2.73s (± 0.40%) ~ 2.72s 2.74s p=0.357 n=6
Bind Time 1.08s (± 0.95%) 1.09s (± 0.37%) ~ 1.08s 1.09s p=0.257 n=6
Check Time 7.89s (± 0.31%) 7.90s (± 0.44%) ~ 7.84s 7.94s p=0.872 n=6
Emit Time 4.46s (± 0.96%) 4.49s (± 0.59%) ~ 4.45s 4.52s p=0.195 n=6
Total Time 16.16s (± 0.41%) 16.20s (± 0.29%) ~ 16.13s 16.27s p=0.227 n=6
TFS - node (v16.17.1, x64)
Memory used 300,103k (± 0.01%) 300,097k (± 0.01%) ~ 300,054k 300,125k p=0.810 n=6
Parse Time 2.17s (± 0.48%) 2.17s (± 0.77%) ~ 2.15s 2.20s p=0.801 n=6
Bind Time 1.23s (± 0.98%) 1.24s (± 0.66%) ~ 1.23s 1.25s p=0.677 n=6
Check Time 7.29s (± 0.31%) 7.28s (± 0.46%) ~ 7.24s 7.31s p=0.935 n=6
Emit Time 4.33s (± 0.75%) 4.39s (± 0.95%) +0.06s (+ 1.46%) 4.33s 4.43s p=0.035 n=6
Total Time 15.02s (± 0.15%) 15.08s (± 0.41%) ~ 14.98s 15.16s p=0.077 n=6
material-ui - node (v16.17.1, x64)
Memory used 480,933k (± 0.01%) 481,641k (± 0.01%) +708k (+ 0.15%) 481,596k 481,707k p=0.005 n=6
Parse Time 3.25s (± 0.57%) 3.25s (± 0.61%) ~ 3.23s 3.29s p=0.868 n=6
Bind Time 0.94s (± 0.43%) 0.93s (± 0.59%) ~ 0.93s 0.94s p=0.282 n=6
Check Time 17.91s (± 1.28%) 17.94s (± 0.57%) ~ 17.80s 18.06s p=0.471 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.10s (± 1.04%) 22.13s (± 0.53%) ~ 21.97s 22.28s p=0.471 n=6
xstate - node (v16.17.1, x64)
Memory used 560,492k (± 0.02%) 560,463k (± 0.02%) ~ 560,354k 560,665k p=0.689 n=6
Parse Time 4.01s (± 0.38%) 4.01s (± 0.38%) ~ 4.00s 4.04s p=0.563 n=6
Bind Time 1.76s (± 0.62%) 1.76s (± 0.59%) ~ 1.75s 1.78s p=0.546 n=6
Check Time 3.05s (± 0.67%) 3.07s (± 0.87%) ~ 3.04s 3.12s p=0.292 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 4.45%) ~ 0.09s 0.10s p=0.405 n=6
Total Time 8.91s (± 0.44%) 8.94s (± 0.25%) ~ 8.92s 8.98s p=0.063 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 54186 6
Baseline main 6

Developer Information:

Download Benchmark

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

IMO, it'd be nice if we had a pathlogical test that this fixes in our test suite, eg, a constructed examples this takes from 50s (timing out) down to 5s (since, unless I'm mistaken, this is the category of change that, in constructed examples, takes something from exponential time to linear time). While this is good, since it doesn't show much change in the perf suites, without anything benching the improvement, this might get lost in a future update without such a test.

@weswigham weswigham merged commit 4749c38 into microsoft:main Jun 5, 2023
@Andarist Andarist deleted the fix/only-add-outermost-intra-expression-sites branch June 5, 2023 19:43
@Andarist
Copy link
Contributor Author

Andarist commented Jun 5, 2023

I see that for some reason main is failing after merging this -> I'm investigating this.

@jakebailey
Copy link
Member

Probably just that the branch was out of date when it was merged.

@Andarist
Copy link
Contributor Author

Andarist commented Jun 5, 2023

Ye, right - I narrowed it down to a silent conflict with: #54380 , looking now if I can make it work in a reasonable time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants