Store only type pointer for Node/Type self-ref, not full interface
I've had this sitting on a branch for a while but I'm sending it just to get it off of my mind.
The idea here is to stop storing a full interface value for the data field, but to instead assume that the node's address is the right place, and instead store only the type part of the interface value, constructing the interface out of that.
Assuming that we ensure Node is always embedded first, this should work.
For parse time, this saves 6-9% memory by bytes allocated. However, using the data field is slower; bind is 6% slower on checker.ts. I would expect this to also affect checking itself, but we don't have a benchmark for that quite yet.
This makes me feel like this isn't really worth it.
pkg: github.com/microsoft/typescript-go/internal/parser
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Parse/empty.ts/tsc-20 393.2n ± 2% 394.6n ± 1% ~ (p=0.280 n=10)
Parse/empty.ts/server-20 383.8n ± 3% 389.6n ± 3% ~ (p=0.617 n=10)
Parse/checker.ts/tsc-20 39.96m ± 1% 39.97m ± 3% ~ (p=0.631 n=10)
Parse/checker.ts/server-20 40.82m ± 2% 40.13m ± 2% ~ (p=0.052 n=10)
Parse/dom.generated.d.ts/tsc-20 12.50m ± 1% 12.40m ± 1% -0.83% (p=0.029 n=10)
Parse/dom.generated.d.ts/server-20 18.77m ± 1% 18.38m ± 1% -2.06% (p=0.002 n=10)
Parse/Herebyfile.mjs/tsc-20 657.1µ ± 3% 652.7µ ± 3% ~ (p=0.247 n=10)
Parse/Herebyfile.mjs/server-20 664.5µ ± 1% 657.6µ ± 1% ~ (p=0.089 n=10)
Parse/jsxComplexSignatureHasApplicabilityError.tsx/tsc-20 244.7µ ± 2% 240.4µ ± 1% -1.75% (p=0.007 n=10)
Parse/jsxComplexSignatureHasApplicabilityError.tsx/server-20 363.8µ ± 1% 360.7µ ± 2% ~ (p=0.075 n=10)
geomean 543.4µ 539.6µ -0.70%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
Parse/empty.ts/tsc-20 816.0 ± 0% 800.0 ± 0% -1.96% (p=0.000 n=10)
Parse/empty.ts/server-20 816.0 ± 0% 800.0 ± 0% -1.96% (p=0.000 n=10)
Parse/checker.ts/tsc-20 24.21Mi ± 0% 21.98Mi ± 0% -9.23% (p=0.000 n=10)
Parse/checker.ts/server-20 24.39Mi ± 0% 22.15Mi ± 0% -9.19% (p=0.000 n=10)
Parse/dom.generated.d.ts/tsc-20 8.638Mi ± 0% 7.862Mi ± 0% -8.98% (p=0.000 n=10)
Parse/dom.generated.d.ts/server-20 11.00Mi ± 0% 10.14Mi ± 0% -7.86% (p=0.000 n=10)
Parse/Herebyfile.mjs/tsc-20 429.2Ki ± 0% 398.1Ki ± 0% -7.23% (p=0.000 n=10)
Parse/Herebyfile.mjs/server-20 429.3Ki ± 0% 398.2Ki ± 0% -7.24% (p=0.000 n=10)
Parse/jsxComplexSignatureHasApplicabilityError.tsx/tsc-20 159.8Ki ± 0% 150.8Ki ± 0% -5.61% (p=0.000 n=10)
Parse/jsxComplexSignatureHasApplicabilityError.tsx/server-20 236.9Ki ± 0% 223.3Ki ± 0% -5.75% (p=0.000 n=10)
geomean 440.2Ki 411.4Ki -6.54%
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
Parse/empty.ts/tsc-20 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹
Parse/empty.ts/server-20 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹
Parse/checker.ts/tsc-20 28.83k ± 0% 28.80k ± 0% -0.10% (p=0.000 n=10)
Parse/checker.ts/server-20 29.44k ± 0% 29.42k ± 0% -0.09% (p=0.000 n=10)
Parse/dom.generated.d.ts/tsc-20 21.05k ± 0% 21.04k ± 0% -0.05% (p=0.000 n=10)
Parse/dom.generated.d.ts/server-20 27.98k ± 0% 27.97k ± 0% -0.04% (p=0.000 n=10)
Parse/Herebyfile.mjs/tsc-20 1.354k ± 0% 1.354k ± 0% ~ (p=1.000 n=10) ¹
Parse/Herebyfile.mjs/server-20 1.354k ± 0% 1.354k ± 0% ~ (p=1.000 n=10) ¹
Parse/jsxComplexSignatureHasApplicabilityError.tsx/tsc-20 352.0 ± 0% 353.0 ± 0% +0.28% (p=0.000 n=10)
Parse/jsxComplexSignatureHasApplicabilityError.tsx/server-20 618.0 ± 0% 619.0 ± 0% +0.16% (p=0.000 n=10)
geomean 1.123k 1.123k +0.02%
¹ all samples are equal
goos: linux
goarch: amd64
pkg: github.com/microsoft/typescript-go/internal/binder
cpu: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
Bind/empty.ts-20 283.3n ± 26% 283.4n ± 27% ~ (p=0.739 n=10)
Bind/checker.ts-20 17.43m ± 3% 18.46m ± 3% +5.93% (p=0.000 n=10)
Bind/dom.generated.d.ts-20 6.815m ± 3% 6.977m ± 1% +2.37% (p=0.019 n=10)
Bind/Herebyfile.mjs-20 291.8µ ± 2% 301.2µ ± 2% +3.21% (p=0.000 n=10)
Bind/jsxComplexSignatureHasApplicabilityError.tsx-20 140.2µ ± 4% 146.7µ ± 3% +4.63% (p=0.000 n=10)
geomean 267.8µ 276.4µ +3.21%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
Bind/empty.ts-20 432.0 ± 0% 432.0 ± 0% ~ (p=1.000 n=10) ¹
Bind/checker.ts-20 7.206Mi ± 0% 7.206Mi ± 0% ~ (p=1.000 n=10) ¹
Bind/dom.generated.d.ts-20 4.873Mi ± 0% 4.873Mi ± 0% ~ (p=0.777 n=10)
Bind/Herebyfile.mjs-20 174.2Ki ± 0% 174.2Ki ± 0% ~ (p=1.000 n=10) ¹
Bind/jsxComplexSignatureHasApplicabilityError.tsx-20 114.8Ki ± 0% 114.8Ki ± 0% ~ (p=1.000 n=10) ¹
geomean 198.8Ki 198.8Ki +0.00%
¹ all samples are equal
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
Bind/empty.ts-20 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
Bind/checker.ts-20 13.69k ± 0% 13.69k ± 0% ~ (p=1.000 n=10) ¹
Bind/dom.generated.d.ts-20 14.68k ± 0% 14.68k ± 0% ~ (p=1.000 n=10) ¹
Bind/Herebyfile.mjs-20 344.0 ± 0% 344.0 ± 0% ~ (p=1.000 n=10) ¹
Bind/jsxComplexSignatureHasApplicabilityError.tsx-20 280.0 ± 0% 280.0 ± 0% ~ (p=1.000 n=10) ¹
geomean 565.9 565.9 +0.00%
¹ all samples are equal
I rebased this to simplify it, but I actually negated the entire point since the struct embedding seems to add some padding, oops.