Repository navigation
Commit d52b33f
committed
Resolve instantiated object members through a shared worker
Eagerly instantiating an entire generic member table leaves millions of
symbols alive even when checking only needs a few properties. Selective
resolution saves memory, but separate lookup and enumeration algorithms
would make inheritance, shadowing, and symbol identity harder to preserve.
Named lookup, flags-only shape queries, and full enumeration need the same
inheritance and shadowing rules. Cached member identities must stay stable
when symbol types resolve later. Missing-property lookup must stay bounded
in diamond-shaped hierarchies instead of exploring every path. Keeping
preparation state after enumeration would waste the memory saved.
Measured against upstream/main at aa81492 with six interleaved,
fresh-process samples per version. The workload parses, binds, and checks
the actual VS Code src/tsconfig.json with one checker, then measures live
heap and heap scan bytes after GC while keeping the checker and program
alive. No GC settings were changed.
VS Code retained heap decreases 6.06%, heap scanning decreases 6.48%, and
allocated bytes decrease 3.39%. Allocation events increase 2.83%; this is a
real tradeoff, not an allocation-count improvement. Instruction medians
decrease, but neither instructions nor elapsed time reach statistical
significance on the shared machine, so this does not claim a CPU speedup.
Exact benchstat output:
goos: linux
goarch: amd64
pkg: github.com/microsoft/TypeScript/tsc/internal/checker
cpu: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
│ unified-main-bench.txt │ unified-final-bench.txt │
│ sec/op │ sec/op vs base │
ExternalProject-20 39.12 ± 11% 41.18 ± 8% ~ (p=0.240 n=6)
│ unified-main-bench.txt │ unified-final-bench.txt │
│ diagnostics │ diagnostics vs base │
ExternalProject-20 321.0 ± 0% 321.0 ± 0% ~ (p=1.000 n=6) ¹
¹ all samples are equal
│ unified-main-bench.txt │ unified-final-bench.txt │
│ files │ files vs base │
ExternalProject-20 10.28k ± 0% 10.28k ± 0% ~ (p=1.000 n=6) ¹
¹ all samples are equal
│ unified-main-bench.txt │ unified-final-bench.txt │
│ retained-B │ retained-B vs base │
ExternalProject-20 4.996Gi ± 0% 4.693Gi ± 0% -6.06% (p=0.002 n=6)
│ unified-main-bench.txt │ unified-final-bench.txt │
│ scan-B │ scan-B vs base │
ExternalProject-20 4.657Gi ± 0% 4.356Gi ± 0% -6.48% (p=0.002 n=6)
│ unified-main-bench.txt │ unified-final-bench.txt │
│ symbols │ symbols vs base │
ExternalProject-20 6.385M ± 0% 4.154M ± 0% -34.94% (p=0.002 n=6)
│ unified-main-bench.txt │ unified-final-bench.txt │
│ B/op │ B/op vs base │
ExternalProject-20 6.391Gi ± 0% 6.174Gi ± 0% -3.39% (p=0.002 n=6)
│ unified-main-bench.txt │ unified-final-bench.txt │
│ allocs/op │ allocs/op vs base │
ExternalProject-20 32.61M ± 0% 33.54M ± 0% +2.83% (p=0.002 n=6)
│ unified-main-instructions.txt │ unified-final-instructions.txt │
│ instructions/op │ instructions/op vs base │
ExternalProject-20 322.1G ± 4% 308.8G ± 4% ~ (p=0.093 n=6)
The smaller compiler fixture also saves retained heap and allocated bytes,
with the same allocation-event tradeoff:
│ unified-fixture-main-bench.txt │ unified-fixture-final-bench.txt │
│ retained-B │ retained-B vs base │
ExternalProject-20 217.2Mi ± 0% 212.9Mi ± 0% -1.99% (p=0.002 n=6)
│ unified-fixture-main-bench.txt │ unified-fixture-final-bench.txt │
│ B/op │ B/op vs base │
ExternalProject-20 313.9Mi ± 0% 311.9Mi ± 0% -0.66% (p=0.002 n=6)
│ unified-fixture-main-bench.txt │ unified-fixture-final-bench.txt │
│ allocs/op │ allocs/op vs base │
ExternalProject-20 1.515M ± 0% 1.536M ± 0% +1.41% (p=0.002 n=6)
Compiler diagnostic, declaration, type, and symbol baselines match
unchanged main. Coverage includes inheritance, polymorphic this, recursive
defaults, reduced bases, index signatures, overlapping generic overloads,
lookup-before-enumeration identity, table-key/name differences, negative
diamond lookups, and hover/completion queries in either resolution state.
The actual VS Code no-emit CLI output is byte-identical to main, including
twelve pre-existing diagnostics and exit status 2.
Validation passed:
npx hereby validate
go -C tsc test -race ./internal/checker -run 'TestInstantiated' -count=1
Task-only measurement helpers are not included in this change.1 parent aa81492 commit d52b33f
9 files changed
Lines changed: 1543 additions & 45 deletions
File tree
- tsc
- internal
- checker
- fourslash/tests
- testdata
- baselines/reference/compiler
- tests/cases/compiler
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
118 | 282 | | |
119 | 283 | | |
120 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
682 | | - | |
| 681 | + | |
| 682 | + | |
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
0 commit comments