-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[experiment] Run babel over output for let/const to var #52656
Conversation
@typescript-bot perf test this |
Heya @jakebailey, I've started to run the perf test suite on this PR at 1a42515. You can monitor the build here. Update: The results are in! |
@jakebailey Here they are:
CompilerComparison Report - main..52656
System
Hosts
Scenarios
TSServerComparison Report - main..52656
System
Hosts
Scenarios
StartupComparison Report - main..52656
System
Hosts
Scenarios
Developer Information: |
Not bad results 😉 |
Yeah, though this was already known when we merged modules and gave up |
What’s the concern here though? Just the build time? |
Well, I wouldn't merge this as-is because (in no particular order):
|
On the whole though, the "big" build tasks don't actually get longer because esbuild/babel are running in parallel with dts emit / bundling, but the actual bundle tasks go from half a second to 8 seconds, which isn't great for the debugging loop. |
I assume the performance hit for let/const vs. var is down to TDZ tracking. Which is unfortunate because |
Yep, it's TDZ. I'm trying to figure out if there's a limited subset that can be changed to make parsing faster but it's not really turning out well. |
It’s weird because most potential TDZ violations can be detected syntactically so engines should have figured out how to optimize it away by now. |
I would certainly think. But at this point I'm having a hard time justifying not doing some form of this change. |
If people are stumbling on this, last time I tested this, it was 5-9%, and now it's more like 7-15%; the relative proportion has changed because we've increased the performance of the TS compiler since modules has merged meaning the fixed perf bump here is now a bigger overall proportion. |
I hacked up TypeScript and ts-perf to run this PR against bun v0.5.5. It doesn't seem like the engine Bun uses (Apple's Note that these benchmark results are not comparable to the ones earlier in this thread; I performed these tests on an entirely different perf-tuned machine in my office, not the corp-owned machine that we normally use. But, I probably will try and upstream my hacks to ts-perf as I've been wanting to test some more interesting hosts. DetailsLoading benchmark and comparing to baseline.
System
Hosts
Scenarios
|
But, i'm going to rerun this just to be sure I didn't mess up somehow. |
Nah, seems correct. A second go: DetailsLoading benchmark and comparing to baseline.
System
Hosts
Scenarios
EDIT: Updated this table to say "bun"; I did that in the last one but forgot in this one. ts-perf doesn't currently support bun so this is a hack. |
Note that Bun runs the transpiler on every file loaded either via import or require (not eval, not new Function, etc). It doesn’t convert let/const variables to var. I wouldn’t expect the results to be different l. it might not work, but you could try BUN_DISABLE_TRANSPILER=1 & it would rule out the possibility of Bun’s transpiler changing the output before being evaluated |
I'm not sure what you mean; the comparison is main versus this PR, i.e. let/const versus var. So if they don't do this transformation (as you say), then the comparison shows that their engine doesn't have this TDZ performance hit, at least not to any great extent. |
Unless you mean that I should try disabling the transpiler to make sure 100% they don't already do this transformation. |
The environment variable which prevents the transpiler from running is here: https://github.com/oven-sh/bun/blob/main/src/bundler.zig#L539 I think the results were already correct, just that since it’s two transpilers running it’s harder to be 100% sure. I sent the above message without re-reading the words I wrote very carefully. Bun doesn’t convert let or const to var, but does a bunch of other stuff. I do know that ESM imports bindings have virtually no overhead in JSC (there was a thread in Node’s issues about ESM imports being slower than var at some point) |
Looping in @evanw because that may be an interesting optimization to do right in esbuild itself. |
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@typescript-bot new perf test bun |
Heya @jakebailey, I've started to run the bun perf test suite on this PR at e67fbc0. You can monitor the build here. Update: The results are in! |
@jakebailey Here they are:
CompilerComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
StartupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@typescript-bot perf test public |
Heya @jakebailey, I've started to run the public perf test suite on this PR at 0c249d9. You can monitor the build here. Update: The results are in! |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@typescript-bot perf test this |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@typescript-bot perf test this |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
For the curious why this has been closed, see Jake's reply on X: https://x.com/andhaveaniceday/status/1775243613506867262?t=dzeDZE6NiL6MgjodaKIUIA&s=19 |
Well, mainly that we manually var'd everything critical and anything else seems to just be noise. |
This is a performance boost we already knew we'd be losing when switching to modules + esbuild, as the latter doesn't support this downleveling (yet?).
I want to retest to see how good this would be, it's probably going to be worth it to do some form of this.