Skip to content

Remove checker pointer from Type - #64946

Open
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:remove-checker-pointer
Open

Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:remove-checker-pointer

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This brings the Type type down from 40 bytes to 32 bytes.

Unfortunately, lazy members has made this more annoying, hence sticking a checker pointer into LazyState.

Every type carried a pointer back to its checker, costing a word per
type header just so a handful of free helpers could reach the checker.
Those helpers can take the checker explicitly instead, shrinking Type
from 40 to 32 bytes on 64-bit platforms.

Lazily resolved class and interface references still need the checker
to resolve members on demand, so the pointer moves to LazyState, which
only exists for those types.
Copilot AI balanced review requested due to automatic review settings October 23, 2026 22:42
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 23, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 23, 2026
@jakebailey

Copy link
Copy Markdown
Member Author

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

@typescript-automation

typescript-automation Bot commented Oct 23, 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.

🟡 Changes recommended

The removed cross-checker ownership guard needs replacement to preserve the existing validation invariant.

1 open issue
What changed in this PR

Reduces the native compiler’s Type header from 40 to 32 bytes by removing its checker pointer and passing checker context explicitly where needed.

Changes:

  • Moves checker ownership needed for lazy member resolution into LazyState.
  • Updates type comparison, inference, relation checking, and tracing to receive checker context.
  • Adjusts size assertions and existing comparison tests.
File Description
tsc/​internal/​testrunner/​compiler_runner.go Uses checker-bound comparison in union-ordering checks.
tsc/​internal/​checker/​utilities.go Converts type comparison helpers to checker methods.
tsc/​internal/​checker/​types.go Removes the header pointer and adds checker context to lazy state.
tsc/​internal/​checker/​types_test.go Updates header-size and mapper-comparison assertions.
tsc/​internal/​checker/​tracer.go Passes checker context through traced-type adapters.
tsc/​internal/​checker/​relater.go Updates relation and recursion helpers to use checker context.
tsc/​internal/​checker/​nodebuilderimpl.go Supplies the checker when allocating extra type storage.
tsc/​internal/​checker/​inference.go Makes depth and ordering helpers checker methods.
tsc/​internal/​checker/​flow.go Uses checker-bound union membership lookup.
tsc/​internal/​checker/​checker.go Initializes lazy-state ownership and updates affected callers.

Review effort: Balanced

if t1.checker != t2.checker {
panic("Cannot compare types from different checkers")
}
// First sort in order of increasing type flags values.
@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 88,466 88,466 ~ ~ ~ p=1.000 n=12
Types 79,607 79,607 ~ ~ ~ p=1.000 n=12
Memory Used 109,197k (± 0.06%) 108,539k (± 0.07%) -658k (- 0.60%) 108,419k 108,774k p=0.000 n=12
Memory Allocs 2,196,614 (± 0.00%) 2,195,942 (± 0.01%) -672 (- 0.03%) 2,195,603 2,196,232 p=0.000 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.049s (± 3.49%) 0.048s (± 4.12%) ~ 0.043s 0.053s p=0.398 n=12
Bind Time 0.017s (± 8.53%) 0.018s (± 9.43%) ~ 0.014s 0.021s p=0.364 n=12
Check Time 0.578s (± 0.99%) 0.579s (± 0.82%) ~ 0.571s 0.594s p=0.504 n=12
Emit Time 0.326s (± 2.24%) 0.326s (± 2.72%) ~ 0.303s 0.360s p=0.898 n=12
Total Time 0.977s (± 0.81%) 0.979s (± 1.06%) ~ 0.954s 1.013s p=0.809 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 586,587 (± 0.02%) 586,543 (± 0.01%) ~ 586,464 586,791 p=0.219 n=12
Types 241,723 (± 0.00%) 241,724 (± 0.00%) ~ 241,721 241,733 p=0.216 n=12
Memory Used 551,380k (± 0.04%) 549,268k (± 0.03%) -2,112k (- 0.38%) 548,886k 549,709k p=0.000 n=12
Memory Allocs 13,076,218 (± 0.07%) 13,075,336 (± 0.10%) ~ 13,066,131 13,140,917 p=0.514 n=12
Config Time 0.017s (± 1.86%) 0.017s (± 1.07%) ~ 0.016s 0.017s p=0.317 n=12
Parse Time 0.223s (± 3.16%) 0.221s (± 2.64%) ~ 0.208s 0.236s p=0.723 n=12
Bind Time 0.082s (±14.25%) 0.084s (±14.04%) ~ 0.060s 0.109s p=0.619 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.502s (± 1.57%) 1.476s (± 1.80%) ~ 1.414s 1.558s p=0.131 n=12
Total Time 1.841s (± 1.62%) 1.814s (± 1.78%) ~ 1.746s 1.897s p=0.242 n=12
arktype - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 685,943 685,943 ~ ~ ~ p=1.000 n=12
Types 939,496 939,496 ~ ~ ~ p=1.000 n=12
Memory Used 533,284k (± 0.01%) 525,330k (± 0.02%) -7,955k (- 1.49%) 525,057k 525,650k p=0.000 n=12
Memory Allocs 12,770,347 (± 0.01%) 12,763,370 (± 0.01%) -6,976 (- 0.05%) 12,761,346 12,765,710 p=0.000 n=12
Config Time 0.003s 0.003s ~ ~ ~ p=1.000 n=12
Parse Time 0.090s (± 3.63%) 0.088s (± 3.17%) ~ 0.082s 0.099s p=0.504 n=12
Bind Time 0.025s (± 5.11%) 0.026s (± 8.87%) ~ 0.023s 0.036s p=0.919 n=12
Check Time 2.148s (± 0.62%) 2.143s (± 0.66%) ~ 2.102s 2.185s p=0.504 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.328s (± 0.22%) 2.318s (± 0.48%) ~ 2.295s 2.349s p=0.070 n=12
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=12
Symbols 3,855,253 3,855,253 ~ ~ ~ p=1.000 n=12
Types 1,370,331 1,370,331 ~ ~ ~ p=1.000 n=12
Memory Used 2,308,603k (± 0.04%) 2,297,698k (± 0.05%) -10,905k (- 0.47%) 2,294,767k 2,300,537k p=0.000 n=12
Memory Allocs 27,146,756 (± 0.05%) 27,139,671 (± 0.07%) ~ 27,101,405 27,204,320 p=0.410 n=12
Config Time 0.017s (± 1.70%) 0.017s ~ ~ ~ p=0.217 n=12
Parse Time 0.463s (± 2.46%) 0.476s (± 2.17%) ~ 0.451s 0.506s p=0.097 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 6.567s (± 0.14%) 6.626s (± 0.51%) +0.059s (+ 0.90%) 6.583s 6.787s p=0.000 n=12
Emit Time 0.465s (± 0.10%) 0.461s (± 1.86%) ~ 0.419s 0.467s p=0.372 n=12
Total Time 8.274s (± 0.15%) 8.339s (± 0.26%) +0.065s (+ 0.79%) 8.305s 8.405s p=0.000 n=12
sentry - native
Errors 2 2 ~ ~ ~ p=1.000 n=12
Symbols 4,793,345 4,793,345 ~ ~ ~ p=1.000 n=12
Types 2,607,067 2,607,067 ~ ~ ~ p=1.000 n=12
Memory Used 3,207,003k (± 0.04%) 3,185,522k (± 0.02%) -21,480k (- 0.67%) 3,183,797k 3,187,939k p=0.000 n=12
Memory Allocs 75,273,378 (± 0.13%) 75,269,354 (± 0.07%) ~ 75,073,219 75,395,193 p=0.630 n=12
Config Time 0.060s (± 0.30%) 0.060s (± 0.54%) ~ 0.060s 0.061s p=0.155 n=12
Parse Time 1.014s (± 2.55%) 0.993s (± 2.61%) ~ 0.944s 1.068s p=0.202 n=12
Bind Time 0.320s (±11.06%) 0.347s (±14.10%) ~ 0.262s 0.454s p=0.401 n=12
Check Time 13.570s (± 0.40%) 13.675s (± 0.71%) +0.104s (+ 0.77%) 13.503s 13.957s p=0.039 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 15.045s (± 0.35%) 15.151s (± 0.74%) ~ 14.937s 15.480s p=0.117 n=12
social-app - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,883,343 1,883,343 ~ ~ ~ p=1.000 n=12
Types 1,158,474 1,158,474 ~ ~ ~ p=1.000 n=12
Memory Used 1,057,553k (± 0.03%) 1,048,437k (± 0.02%) -9,116k (- 0.86%) 1,047,738k 1,049,176k p=0.000 n=12
Memory Allocs 13,573,998 (± 0.14%) 13,550,811 (± 0.16%) ~ 13,507,806 13,602,069 p=0.160 n=12
Config Time 0.014s 0.014s (± 1.29%) ~ 0.014s 0.015s p=1.000 n=12
Parse Time 0.280s (± 1.76%) 0.286s (± 2.37%) ~ 0.268s 0.306s p=0.234 n=12
Bind Time 0.069s (±14.34%) 0.062s (± 8.30%) ~ 0.056s 0.088s p=0.136 n=12
Check Time 2.752s (± 0.78%) 2.776s (± 0.70%) ~ 2.707s 2.819s p=0.110 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 3.138s (± 0.49%) 3.157s (± 0.51%) ~ 3.114s 3.195s p=0.070 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,184,988 1,184,988 ~ ~ ~ p=1.000 n=12
Types 438,967 438,967 ~ ~ ~ p=1.000 n=12
Memory Used 1,276,670k (± 0.79%) 1,268,706k (± 0.29%) ~ 1,260,701k 1,279,632k p=0.114 n=12
Memory Allocs 77,384,489 (± 0.13%) 77,394,647 (± 0.05%) ~ 77,276,029 77,465,234 p=0.671 n=12
Config Time 0.004s (± 9.52%) 0.004s (±11.29%) ~ 0.003s 0.006s p=0.938 n=12
Parse Time 0.309s (± 1.80%) 0.305s (± 2.26%) ~ 0.279s 0.319s p=0.401 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.954s (± 0.48%) 1.979s (± 0.47%) +0.025s (+ 1.29%) 1.954s 2.011s p=0.001 n=12
Emit Time 0.365s (± 3.22%) 0.372s (± 3.49%) ~ 0.332s 0.396s p=0.325 n=12
Total Time 23.468s (± 0.52%) 23.754s (± 0.52%) +0.286s (+ 1.22%) 23.361s 24.083s p=0.002 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 263,525 263,525 ~ ~ ~ p=1.000 n=12
Types 196,118 196,118 ~ ~ ~ p=1.000 n=12
Memory Used 236,019k (± 0.03%) 234,302k (± 0.03%) -1,717k (- 0.73%) 234,111k 234,438k p=0.000 n=12
Memory Allocs 4,286,742 (± 0.01%) 4,285,604 (± 0.01%) -1,138 (- 0.03%) 4,283,988 4,286,569 p=0.000 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.113s (± 4.85%) 0.111s (± 4.45%) ~ 0.100s 0.122s p=0.400 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 0.949s (± 0.75%) 0.954s (± 0.72%) ~ 0.942s 0.974s p=0.325 n=12
Emit Time 0.142s (± 6.12%) 0.147s (± 3.86%) ~ 0.134s 0.161s p=0.385 n=12
Total Time 1.258s (± 0.62%) 1.267s (± 0.75%) ~ 1.236s 1.284s p=0.117 n=12
t3code-server - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 4,350,705 4,350,705 ~ ~ ~ p=1.000 n=12
Types 3,040,691 3,040,691 ~ ~ ~ p=1.000 n=12
Memory Used 2,610,725k (± 0.03%) 2,589,211k (± 0.03%) -21,514k (- 0.82%) 2,588,090k 2,592,024k p=0.000 n=12
Memory Allocs 37,334,344 (± 0.06%) 37,309,877 (± 0.05%) ~ 37,259,290 37,360,690 p=0.128 n=12
Config Time 0.006s 0.006s ~ ~ ~ p=1.000 n=12
Parse Time 0.561s (± 2.65%) 0.572s (± 2.22%) ~ 0.537s 0.596s p=0.284 n=12
Bind Time 0.175s (±11.45%) 0.179s (±12.94%) ~ 0.146s 0.250s p=0.919 n=12
Check Time 16.334s (± 0.47%) 16.432s (± 0.26%) +0.098s (+ 0.60%) 16.301s 16.510s p=0.032 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 17.091s (± 0.45%) 17.206s (± 0.26%) +0.114s (+ 0.67%) 17.079s 17.329s p=0.017 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 231,636 231,636 ~ ~ ~ p=1.000 n=12
Types 181,196 181,196 ~ ~ ~ p=1.000 n=12
Memory Used 203,560k (± 0.02%) 202,001k (± 0.02%) -1,559k (- 0.77%) 201,867k 202,092k p=0.000 n=12
Memory Allocs 1,358,418 (± 0.01%) 1,357,041 (± 0.02%) -1,377 (- 0.10%) 1,356,508 1,357,777 p=0.000 n=12
Config Time 0.000s 0.000s (±217.90%) ~ 0.000s 0.001s p=1.000 n=12
Parse Time 0.097s (± 4.97%) 0.098s (± 4.36%) ~ 0.090s 0.110s p=0.618 n=12
Bind Time 0.041s (± 9.15%) 0.043s (± 8.82%) ~ 0.032s 0.049s p=0.415 n=12
Check Time 0.729s (± 0.98%) 0.728s (± 0.96%) ~ 0.716s 0.749s p=0.944 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.883s (± 0.78%) 0.885s (± 0.93%) ~ 0.868s 0.913s p=0.809 n=12
vscode - native
Errors 10 10 ~ ~ ~ p=1.000 n=12
Symbols 7,198,621 7,198,621 ~ ~ ~ p=1.000 n=12
Types 4,248,778 4,248,778 ~ ~ ~ p=1.000 n=12
Memory Used 5,363,793k (± 0.02%) 5,329,835k (± 0.01%) -33,957k (- 0.63%) 5,327,975k 5,331,810k p=0.000 n=12
Memory Allocs 61,986,819 (± 0.02%) 61,971,932 (± 0.01%) -14,887 (- 0.02%) 61,960,745 62,006,431 p=0.001 n=12
Config Time 0.079s (± 0.39%) 0.078s (± 0.40%) ~ 0.078s 0.079s p=0.220 n=12
Parse Time 1.902s (± 2.21%) 1.971s (± 2.29%) +0.068s (+ 3.58%) 1.875s 2.112s p=0.010 n=12
Bind Time 0.859s (±11.95%) 0.667s (±14.13%) 🟩-0.193s (-22.41%) 0.524s 1.005s p=0.017 n=12
Check Time 15.853s (± 0.82%) 16.023s (± 0.75%) ~ 15.729s 16.339s p=0.052 n=12
Emit Time 6.471s (± 6.34%) 5.610s (± 7.97%) 🟩-0.861s (-13.30%) 5.068s 6.784s p=0.001 n=12
Total Time 25.252s (± 1.47%) 24.433s (± 1.81%) 🟩-0.819s (- 3.24%) 23.800s 25.569s p=0.002 n=12
webpack - native
Errors 602 602 ~ ~ ~ p=1.000 n=12
Symbols 916,593 916,593 ~ ~ ~ p=1.000 n=12
Types 643,793 643,793 ~ ~ ~ p=1.000 n=12
Memory Used 765,153k (± 0.01%) 760,036k (± 0.03%) -5,118k (- 0.67%) 759,437k 760,391k p=0.000 n=12
Memory Allocs 6,541,502 (± 0.02%) 6,537,266 (± 0.01%) -4,235 (- 0.06%) 6,535,439 6,539,942 p=0.000 n=12
Config Time 0.009s 0.009s ~ ~ ~ p=1.000 n=12
Parse Time 0.319s (± 4.05%) 0.328s (± 1.97%) ~ 0.308s 0.345s p=0.259 n=12
Bind Time 0.089s (±13.31%) 0.079s (± 6.50%) ~ 0.071s 0.102s p=0.306 n=12
Check Time 2.979s (± 0.17%) 3.003s (± 0.25%) +0.023s (+ 0.78%) 2.989s 3.023s p=0.000 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 3.435s (± 0.37%) 3.458s (± 0.37%) +0.023s (+ 0.66%) 3.429s 3.485s p=0.018 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 640,566 640,566 ~ ~ ~ p=1.000 n=12
Types 388,220 388,220 ~ ~ ~ p=1.000 n=12
Memory Used 398,693k (± 0.03%) 395,319k (± 0.02%) -3,374k (- 0.85%) 395,151k 395,516k p=0.000 n=12
Memory Allocs 3,995,603 (± 0.10%) 3,988,006 (± 0.08%) -7,597 (- 0.19%) 3,979,982 3,996,374 p=0.005 n=12
Config Time 0.003s 0.003s ~ ~ ~ p=1.000 n=12
Parse Time 0.137s (± 3.06%) 0.134s (± 3.23%) ~ 0.122s 0.145s p=0.116 n=12
Bind Time 0.038s (±13.05%) 0.044s (±17.28%) ~ 0.033s 0.067s p=0.155 n=12
Check Time 0.949s (± 0.45%) 0.947s (± 0.47%) ~ 0.933s 0.955s p=0.599 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.133s (± 0.72%) 1.132s (± 0.79%) ~ 1.115s 1.162s p=0.788 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • arktype - native
  • mui-docs - native
  • sentry - native
  • social-app - native
  • strada-build-src - native
  • strada-compiler - native
  • t3code-server - 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

@jakebailey

Jake Bailey (jakebailey) commented Oct 23, 2026 •

Copy link
Copy Markdown
Member Author

Pretty disappointing, but I also didn't check the size class, and then also I don't think we allocate these in arenas

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