Repository navigation
🏃 Reduce Selector type-checking cost - #283
Conversation
|
Thank you! I will test this locally soon. @snowyukitty can you tell me how you found Sandstone and what motivated you to contribute? Just curious. |
|
I found Sandstone through a structured search of active GitHub issues in TypeScript projects. #269 stood out because the compiler-instantiation blow-up had a deterministic reproduction and the variance change could be measured against both tsc and tsgo without changing runtime behavior. That combination—clear user impact, a narrow type-level fix, and a falsifiable benchmark—is what motivated me to work on it. |
|
I just tested this, its legit! Thanks, merging this now |
|
Also if a real person was steering the model for this, I'd appreciate you saying something,
This is obviously a slop non-answer. I'm curious what you get out of spending who knows how much money on all of these tokens, and I hope you don't use nasty compute running in xAI/OpenAI/Meta datacenters, they're destroying communities and the planet. |
|
Yes—there’s a real person here. I steer the work and decide what gets submitted, but I do use AI heavily. For this PR, I used OpenAI Codex for most of the implementation workflow, with Anthropic Claude and xAI Grok in review passes. My previous reply was AI-assisted and dodged the human part of your question. That criticism was fair, and I’m sorry. What I get out of the token spend is practice and learning. I think AI-assisted coding is going to become a normal part of software development, so I’m trying to become genuinely good at working with these tools while contributing something useful to open source. Real projects give me real constraints, tests, standards, and maintainer feedback. That helps me improve both my own engineering judgment and the way I guide the agents. A few years ago, Go-playing AIs became teachers for human players. AI agents feel a little like that to me: they teach and guide me while I learn how to collaborate with them thoughtfully and use them well. I’m still learning, but that’s the point—and I hope the work itself is useful along the way. For this PR, I didn’t use a Meta model. I don’t have a trustworthy per-PR energy or emissions estimate, so I don’t want to make one up. I hear your concern about the effects data centers can have on communities and the environment, and I don’t think it should be brushed aside. |
* 🏃 Reduce Selector type-checking cost * test(types): benchmark selectors on TS 6 and TS 7 * test(types): guard Selector instantiation cost * test(types): fingerprint emitted declarations --------- Co-authored-by: snowyukitty <[email protected]>
* 🏃 Reduce Selector type-checking cost * test(types): benchmark selectors on TS 6 and TS 7 * test(types): guard Selector instantiation cost * test(types): fingerprint emitted declarations --------- Co-authored-by: snowyukitty <[email protected]>
Summary
SelectorClass's three structurally covariant type parametersWhy
TypeScript's trace attributes the issue fixture's extra check time to inferring
variance for
SelectorClass. That inference recursively traverses thegenerated entity/NBT graph. The explicit
outmodifiers state the samecovariance the class already has, allowing comparisons between
SelectorClassinstantiations to compare their type arguments directly.Before the change, all 729 assignability relations among the 27 boolean
instantiations were checked against component-wise covariance with no
mismatches. Base-versus-candidate probes also produced identical diagnostics
for unresolved generic parameters and
never, under bothstrictFunctionTypesmodes.Current-master reproduction
The emitted-declaration fixture still reproduces the regression on current
master (
4bc288f):Candidate benchmark
Ten measured fresh-process selector/control pairs after warmup:
The exact integer counters are the primary result. Timing ratios remain
informational because compiler totals are rounded to 10 ms and wall time
includes process startup. Benchmark output records a stable SHA-256 over the
emitted declaration tree so saved results can be tied to the measured build.
Run with:
Test plan
bun test(76 passed)--noEmitcheck--noEmitcheckoutmodifiers fails at 471,298 instantiations versus the 10,000 ceilinggit diff --checkOn Windows, the build was validated by launching the repository-pinned
extensionless TypeScript 7 binary through
node; Bun cannot execute thatupstream package script directly.
bun lintremains blocked before sourceanalysis by current master's configuration referencing an unavailable
eslint/no-dupe-argsrule; this change does not modify the lint setup.Fixes #269