Skip to content

Don't resolve mapped type members to find their signatures - #64873

Open
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:perf/mapped-type-signatures
Open

Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:perf/mapped-type-signatures

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Mapped types never have call or construct signatures, but asking for their signatures resolved all of their properties. Signature checks in relations ask for them first, so every mapped type that reached a relation had its properties built, even when nothing else needed them. In MUI, components accept Partial<...> of each intrinsic element's props, so this built hundreds of properties for each of thousands of such types, and their combined base properties too.

Measured with --checkers 4 (n=6):

                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
    Tsc/bluesky         2.459 ± 3%   2.458 ± 3%       ~ (p=0.818 n=6)
    Tsc/sentry          10.21 ± 4%   10.27 ± 3%       ~ (p=0.937 n=6)
    Tsc/t3code-server   8.097 ± 3%   8.085 ± 1%       ~ (p=0.937 n=6)
    Tsc/mui-docs        6.423 ± 4%   5.902 ± 4%  -8.10% (p=0.002 n=6)
    geomean             6.011        5.892       -1.98%

                      │   old.txt    │              new.txt               │
                      │    rss-B     │    rss-B      vs base              │
    Tsc/bluesky         1.184Gi ± 1%   1.176Gi ± 3%       ~ (p=0.699 n=6)
    Tsc/sentry          3.415Gi ± 5%   3.273Gi ± 5%       ~ (p=0.240 n=6)
    Tsc/t3code-server   2.875Gi ± 6%   2.913Gi ± 8%       ~ (p=0.699 n=6)
    Tsc/mui-docs        2.323Gi ± 7%   2.203Gi ± 5%       ~ (p=0.240 n=6)
    geomean             2.280Gi        2.229Gi       -2.21%

                      │   old.txt    │              new.txt               │
                      │    heap-B    │    heap-B     vs base              │
    Tsc/bluesky         915.1Mi ± 0%   914.7Mi ± 0%       ~ (p=0.132 n=6)
    Tsc/sentry          2.483Gi ± 0%   2.481Gi ± 0%       ~ (p=0.065 n=6)
    Tsc/t3code-server   2.179Gi ± 0%   2.179Gi ± 0%       ~ (p=0.589 n=6)
    Tsc/mui-docs        1.722Gi ± 0%   1.634Gi ± 0%  -5.16% (p=0.002 n=6)
    geomean             1.699Gi        1.676Gi       -1.35%

vscode is unaffected (n=12):

               │    old     │             new              │
               │   sec/op   │   sec/op    vs base          │
    Tsc/vscode   11.71 ± 1%   11.67 ± 2%  ~ (p=0.899 n=12)

               │     old      │              new               │
               │    rss-B     │    rss-B      vs base          │
    Tsc/vscode   4.765Gi ± 1%   4.787Gi ± 1%  ~ (p=0.443 n=12)

               │     old      │              new               │
               │    heap-B    │    heap-B     vs base          │
    Tsc/vscode   3.977Gi ± 0%   3.976Gi ± 0%  ~ (p=1.000 n=12)

Mapped types never have call or construct signatures, but asking for
their signatures resolved all of their properties. Signature checks
in relations ask for them first, so every mapped type that reached a
relation had its properties built, even when nothing else needed
them. In MUI, components accept Partial<...> of each intrinsic
element's props, so this built hundreds of properties for each of
thousands of such types, and their combined base properties too.

Measured with --checkers 4 (n=6):

                      │  old.txt   │             new.txt              │
                      │   sec/op   │   sec/op    vs base              │
    Tsc/bluesky         2.459 ± 3%   2.458 ± 3%       ~ (p=0.818 n=6)
    Tsc/sentry          10.21 ± 4%   10.27 ± 3%       ~ (p=0.937 n=6)
    Tsc/t3code-server   8.097 ± 3%   8.085 ± 1%       ~ (p=0.937 n=6)
    Tsc/mui-docs        6.423 ± 4%   5.902 ± 4%  -8.10% (p=0.002 n=6)
    geomean             6.011        5.892       -1.98%

                      │   old.txt    │              new.txt               │
                      │    rss-B     │    rss-B      vs base              │
    Tsc/bluesky         1.184Gi ± 1%   1.176Gi ± 3%       ~ (p=0.699 n=6)
    Tsc/sentry          3.415Gi ± 5%   3.273Gi ± 5%       ~ (p=0.240 n=6)
    Tsc/t3code-server   2.875Gi ± 6%   2.913Gi ± 8%       ~ (p=0.699 n=6)
    Tsc/mui-docs        2.323Gi ± 7%   2.203Gi ± 5%       ~ (p=0.240 n=6)
    geomean             2.280Gi        2.229Gi       -2.21%

                      │   old.txt    │              new.txt               │
                      │    heap-B    │    heap-B     vs base              │
    Tsc/bluesky         915.1Mi ± 0%   914.7Mi ± 0%       ~ (p=0.132 n=6)
    Tsc/sentry          2.483Gi ± 0%   2.481Gi ± 0%       ~ (p=0.065 n=6)
    Tsc/t3code-server   2.179Gi ± 0%   2.179Gi ± 0%       ~ (p=0.589 n=6)
    Tsc/mui-docs        1.722Gi ± 0%   1.634Gi ± 0%  -5.16% (p=0.002 n=6)
    geomean             1.699Gi        1.676Gi       -1.35%

vscode is unaffected (n=12):

               │    old     │             new              │
               │   sec/op   │   sec/op    vs base          │
    Tsc/vscode   11.71 ± 1%   11.67 ± 2%  ~ (p=0.899 n=12)

               │     old      │              new               │
               │    rss-B     │    rss-B      vs base          │
    Tsc/vscode   4.765Gi ± 1%   4.787Gi ± 1%  ~ (p=0.443 n=12)

               │     old      │              new               │
               │    heap-B    │    heap-B     vs base          │
    Tsc/vscode   3.977Gi ± 0%   3.976Gi ± 0%  ~ (p=1.000 n=12)
Copilot AI balanced review requested due to automatic review settings October 19, 2026 17:47
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 19, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 19, 2026
@jakebailey

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) perf test this faster

@typescript-automation

typescript-automation Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Command Status Results
perf test this faster ✅ Started 👀 Results

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow guard preserves signature results and deferred property resolution, with only a nonblocking regression-test suggestion.

1 open issue
What changed in this PR

Avoids resolving mapped-type properties when the native TypeScript checker only needs call or construct signatures.

Changes:

  • Returns empty signatures for unresolved mapped types.
  • Adds a guard matching the existing member-resolution dispatch.
File Description
tsc/​internal/​checker/​checker.go Skips unnecessary mapped-type member resolution during signature queries.

Review effort: Balanced


func (c *Checker) getSignaturesOfStructuredType(t *Type, kind SignatureKind) []*Signature {
if t.flags&TypeFlagsStructuredType == 0 {
if t.flags&TypeFlagsStructuredType == 0 || isUnresolvedMappedType(t) {
@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@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 - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,276 115,276 ~ ~ ~ p=1.000 n=12
Types 79,613 79,613 ~ ~ ~ p=1.000 n=12
Memory Used 113,562k (± 0.08%) 113,574k (± 0.05%) ~ 113,440k 113,703k p=0.977 n=12
Memory Allocs 2,212,567 (± 0.01%) 2,212,564 (± 0.00%) ~ 2,212,316 2,212,832 p=0.977 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.048s (± 3.57%) 0.049s (± 3.68%) ~ 0.044s 0.054s p=0.764 n=12
Bind Time 0.017s (± 6.81%) 0.017s (±10.09%) ~ 0.014s 0.021s p=0.902 n=12
Check Time 0.567s (± 0.79%) 0.559s (± 0.76%) -0.009s (- 1.57%) 0.549s 0.567s p=0.006 n=12
Emit Time 0.324s (± 2.76%) 0.324s (± 2.10%) ~ 0.301s 0.338s p=0.898 n=12
Total Time 0.965s (± 0.83%) 0.957s (± 0.61%) -0.008s (- 0.86%) 0.940s 0.969s p=0.049 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 846,722 (± 0.10%) 846,666 (± 0.07%) ~ 845,352 848,581 p=0.843 n=12
Types 247,034 (± 0.00%) 247,000 (± 0.00%) -33 (- 0.01%) 246,999 247,001 p=0.000 n=12
Memory Used 596,272k (± 0.02%) 596,333k (± 0.02%) ~ 595,963k 596,596k p=0.443 n=12
Memory Allocs 13,140,143 (± 0.03%) 13,138,645 (± 0.02%) ~ 13,134,693 13,146,627 p=0.514 n=12
Config Time 0.020s (± 0.90%) 0.020s ~ ~ ~ p=1.000 n=12
Parse Time 0.276s (± 2.41%) 0.276s (± 2.02%) ~ 0.264s 0.290s p=0.876 n=12
Bind Time 0.111s (±12.88%) 0.108s (±12.64%) ~ 0.074s 0.138s p=0.701 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.851s (± 1.34%) 1.851s (± 1.70%) ~ 1.758s 1.941s p=0.876 n=12
Total Time 2.278s (± 1.08%) 2.278s (± 1.37%) ~ 2.165s 2.358s p=0.876 n=12
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=12
Symbols 4,331,983 4,248,807 -83,176 (- 1.92%) ~ ~ p=0.000 n=12
Types 1,370,520 1,356,171 -14,349 (- 1.05%) ~ ~ p=0.000 n=12
Memory Used 2,625,111k (± 0.07%) 2,504,476k (± 0.05%) 🟩-120,635k (- 4.60%) 2,500,350k 2,508,434k p=0.000 n=12
Memory Allocs 27,712,290 (± 0.16%) 27,001,515 (± 0.06%) -710,775 (- 2.56%) 26,965,584 27,048,722 p=0.000 n=12
Config Time 0.020s (± 1.21%) 0.020s (± 1.40%) ~ 0.020s 0.021s p=1.000 n=12
Parse Time 0.572s (± 4.17%) 0.578s (± 1.98%) ~ 0.543s 0.604s p=0.989 n=12
Bind Time 0.003s (±12.54%) 0.002s (±13.14%) ~ 0.002s 0.003s p=1.000 n=12
Check Time 8.612s (± 0.36%) 7.751s (± 0.48%) 🟩-0.861s (-10.00%) 7.702s 7.900s p=0.000 n=12
Emit Time 0.701s (±11.12%) 0.560s (± 3.27%) 🟩-0.141s (-20.12%) 0.497s 0.576s p=0.011 n=12
Total Time 10.822s (± 0.77%) 9.826s (± 0.13%) 🟩-0.997s (- 9.21%) 9.795s 9.856s p=0.000 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,388,680 1,388,668 -12 (- 0.00%) ~ ~ p=0.000 n=12
Types 441,862 441,862 ~ ~ ~ p=1.000 n=12
Memory Used 1,309,498k (± 0.49%) 1,313,069k (± 0.64%) ~ 1,298,825k 1,341,227k p=0.551 n=12
Memory Allocs 78,228,753 (± 0.09%) 78,258,865 (± 0.10%) ~ 77,949,564 78,427,082 p=0.378 n=12
Config Time 0.003s (±12.29%) 0.004s (±10.43%) ~ 0.003s 0.005s p=0.215 n=12
Parse Time 0.249s (± 1.77%) 0.253s (± 1.95%) ~ 0.237s 0.263s p=0.224 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.674s (± 0.41%) 1.667s (± 0.39%) ~ 1.649s 1.686s p=0.086 n=12
Emit Time 0.297s (± 4.76%) 0.304s (± 2.92%) ~ 0.281s 0.332s p=0.542 n=12
Total Time 19.723s (± 0.88%) 19.841s (± 0.64%) ~ 19.532s 20.244s p=0.178 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 334,953 334,941 -12 (- 0.00%) ~ ~ p=0.000 n=12
Types 197,616 197,616 ~ ~ ~ p=1.000 n=12
Memory Used 247,462k (± 0.02%) 247,520k (± 0.02%) ~ 247,336k 247,608k p=0.091 n=12
Memory Allocs 4,329,204 (± 0.01%) 4,329,462 (± 0.01%) ~ 4,328,060 4,330,519 p=0.410 n=12
Config Time 0.000s (±113.79%) 0.001s (±55.53%) ~ 0.000s 0.001s p=0.214 n=12
Parse Time 0.094s (± 4.07%) 0.091s (± 5.51%) ~ 0.078s 0.104s p=0.541 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 0.801s (± 0.65%) 0.798s (± 0.66%) ~ 0.787s 0.815s p=0.417 n=12
Emit Time 0.122s (± 6.16%) 0.120s (± 5.83%) ~ 0.102s 0.133s p=0.788 n=12
Total Time 1.062s (± 0.60%) 1.055s (± 0.97%) ~ 1.023s 1.082s p=0.297 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 303,834 303,815 -19 (- 0.01%) ~ ~ p=0.000 n=12
Types 181,663 181,663 ~ ~ ~ p=1.000 n=12
Memory Used 215,259k (± 0.02%) 215,228k (± 0.01%) ~ 215,089k 215,274k p=0.259 n=12
Memory Allocs 1,401,682 (± 0.01%) 1,401,627 (± 0.02%) ~ 1,400,828 1,402,141 p=0.887 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.080s (± 3.93%) 0.077s (± 4.93%) ~ 0.068s 0.085s p=0.297 n=12
Bind Time 0.030s (± 9.76%) 0.034s (±11.39%) ~ 0.024s 0.044s p=0.091 n=12
Check Time 0.625s (± 1.01%) 0.619s (± 1.11%) ~ 0.603s 0.644s p=0.173 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.749s (± 0.75%) 0.743s (± 0.86%) -0.006s (- 0.80%) 0.734s 0.772s p=0.029 n=12
vscode - native
Errors 396 396 ~ ~ ~ p=1.000 n=12
Symbols 12,485,544 12,485,523 -21 (- 0.00%) ~ ~ p=0.000 n=12
Types 4,087,014 4,086,995 -19 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 5,846,309k (± 0.03%) 5,846,108k (± 0.02%) ~ 5,843,481k 5,848,894k p=0.843 n=12
Memory Allocs 59,404,397 (± 0.02%) 59,387,756 (± 0.01%) -16,642 (- 0.03%) 59,378,508 59,397,926 p=0.028 n=12
Config Time 0.076s (± 0.37%) 0.076s (± 0.32%) ~ 0.076s 0.077s p=1.000 n=12
Parse Time 1.852s (± 2.32%) 1.837s (± 2.49%) ~ 1.765s 2.000s p=0.514 n=12
Bind Time 0.632s (±12.07%) 0.692s (±14.08%) ~ 0.514s 0.956s p=0.478 n=12
Check Time 15.910s (± 1.24%) 15.768s (± 1.23%) ~ 15.452s 16.198s p=0.068 n=12
Emit Time 5.775s (± 6.24%) 5.661s (± 6.38%) ~ 4.752s 6.541s p=0.755 n=12
Total Time 24.336s (± 1.10%) 24.126s (± 1.09%) ~ 23.321s 24.793s p=0.242 n=12
webpack - native
Errors 598 598 ~ ~ ~ p=1.000 n=12
Symbols 1,398,302 1,398,302 ~ ~ ~ p=1.000 n=12
Types 670,900 670,882 -18 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 885,696k (± 0.02%) 885,701k (± 0.02%) ~ 885,293k 886,303k p=0.887 n=12
Memory Allocs 6,927,301 (± 0.02%) 6,926,881 (± 0.01%) ~ 6,924,812 6,928,620 p=0.755 n=12
Config Time 0.007s (± 4.37%) 0.008s (± 4.38%) ~ 0.007s 0.008s p=1.000 n=12
Parse Time 0.246s (± 2.57%) 0.253s (± 3.01%) ~ 0.226s 0.270s p=0.075 n=12
Bind Time 0.060s (± 7.26%) 0.065s (±13.16%) ~ 0.056s 0.098s p=0.101 n=12
Check Time 2.472s (± 0.41%) 2.428s (± 0.20%) -0.044s (- 1.77%) 2.414s 2.442s p=0.000 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.817s (± 0.43%) 2.783s (± 0.31%) -0.034s (- 1.20%) 2.761s 2.803s p=0.000 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,060,810 1,060,743 -67 (- 0.01%) ~ ~ p=0.000 n=12
Types 389,671 389,443 -228 (- 0.06%) ~ ~ p=0.000 n=12
Memory Used 471,851k (± 0.03%) 471,700k (± 0.02%) ~ 471,559k 471,971k p=0.062 n=12
Memory Allocs 4,218,918 (± 0.07%) 4,218,038 (± 0.09%) ~ 4,209,110 4,228,892 p=0.755 n=12
Config Time 0.003s (± 8.64%) 0.003s (± 8.64%) ~ 0.002s 0.003s p=1.000 n=12
Parse Time 0.133s (± 3.07%) 0.133s (± 3.01%) ~ 0.126s 0.142s p=0.989 n=12
Bind Time 0.047s (±14.30%) 0.051s (±14.60%) ~ 0.034s 0.069s p=0.449 n=12
Check Time 1.090s (± 0.77%) 1.087s (± 0.65%) ~ 1.070s 1.110s p=0.680 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.280s (± 0.72%) 1.282s (± 0.61%) ~ 1.253s 1.304s p=0.702 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

This branch has not been deployed

No deployments
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

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants