-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Swap closure state in the type-checker to var
to avoid TDZ checks.
#52835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@typescript-bot perf test this faster |
Heya @DanielRosenwasser, I've started to run the abridged perf test suite on this PR at 99368d9. You can monitor the build here. Update: The results are in! |
var
to avoid TDZ checks.var
to avoid TDZ checks.
@DanielRosenwasser Here they are:Comparison Report - main..52835
System
Hosts
Scenarios
Developer Information: |
It's sort of interesting that it's always 0.10ish seconds saved; is there a fixed window where this is problematic? |
Ugh, probably conflating changes. @typescript-bot perf test this |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 99368d9. You can monitor the build here. |
GitHub has been 500'ing, so the perf run succeeded, but posting a comment didn't succeed. Here are the results:CompilerComparison Report - main..52835
System
Hosts
Scenarios
TSServerComparison Report - main..52835
System
Hosts
Scenarios
StartupComparison Report - main..52835
System
Hosts
Scenarios
|
The parser scanner change was a huge win for the few variables it modified, but this one is 10x less of a win for like 4x the variables changed (a few hundred); do we think it's worth it? |
Well, I guess xstate is consistently like 3%, and the server tests have good |
Definitely! I think it's very scoped, and the conceptual cleanliness buys us relatively little - so it's a free win to me. I could never argue with a developer using TypeScript that a 1-3% reduction in type-checking time wasn't worth it because we didn't want to disable our linter. So I think we should even do this across the compiler. The only thing that might be lacking is some documentation on why it is that we're doing this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't like it given how it's like 300 variables, but I guess LGTM given they're at the top and rarely touched.
// A package name maps to true when we detect it has .d.ts files. | ||
// This is useful as an approximation of whether a package bundles its own types. | ||
// Note: we only look at files already found by module resolution, | ||
// so there may be files we did not consider. | ||
const map = new Map<string, boolean>(); | ||
var map = new Map<string, boolean>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var map = new Map<string, boolean>(); | |
const map = new Map<string, boolean>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, why did you suggest reverting just this one back to const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a top level variable and is only referenced once for this memoized call. There's no way it has any meaningful performance impact.
But, my suggestion wasn't merged anyway and it's not hurting anything either.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Follow-up from #52832.