Skip to content
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

Move from const enums to consts #1645

Merged
merged 15 commits into from
Nov 5, 2024
Merged

Conversation

wycats
Copy link
Contributor

@wycats wycats commented Oct 31, 2024

This PR ended up being much more extensive than originally intended because it ended up including quite a bit of cleanup to the benchmark setup and cleaned up mistakes in the package.jsons that were causing subtle issues in the benchmark environment.

[EDIT] @NullVoxPopuli pushed me to extract a lot of the incidental changes into their own PRs. I did quite a bit of that and it did streamline this PR. Thanks @NullVoxPopuli!

@wycats wycats force-pushed the feature/error-recovery-redux-pt2 branch 2 times, most recently from 797a506 to bda4a4b Compare November 3, 2024 00:06
@wycats wycats changed the title Streamline VM implementation + move from const enums to consts Move from const enums to consts Nov 3, 2024
@wycats wycats marked this pull request as ready for review November 3, 2024 06:52
@wycats wycats added the perf label Nov 3, 2024
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of changes! But overall looks good, and all the types of changes here are straight forward.

Good improvement, yay!

Left a question tho
(Doesn't affect approval)

bin/setup-bench.mjs Outdated Show resolved Hide resolved
packages/@glimmer/compiler/index.ts Outdated Show resolved Hide resolved
packages/@glimmer/compiler/lib/passes/2-encoding/index.ts Outdated Show resolved Hide resolved
packages/@glimmer/compiler/package.json Outdated Show resolved Hide resolved
packages/@glimmer/compiler/test/compiler-test.ts Outdated Show resolved Hide resolved
packages/@glimmer/debug-util/package.json Outdated Show resolved Hide resolved
packages/@glimmer/local-debug-flags/index.ts Show resolved Hide resolved
packages/@glimmer/local-debug-flags/index.ts Show resolved Hide resolved
packages/@glimmer/runtime/lib/opcodes.ts Show resolved Hide resolved
Historically, many of these enums used `const enum`s, which at least had
the benefit of being compiled away at build time.

We've now moved to mostly normal `enum`s, which are both less efficient
than normal constants, and a relic of an earlier TypeScript era before
literal types.

This PR moves all enums to normal constants, and creates types for the
constant values when the code needs them.
@wycats wycats force-pushed the feature/error-recovery-redux-pt2 branch from 74a32c5 to b10d437 Compare November 3, 2024 22:51
@wycats wycats added perf and removed perf labels Nov 3, 2024
@wycats
Copy link
Contributor Author

wycats commented Nov 3, 2024

image

Local results are "no change". I would have expected at least a small change, but the main motivation for this change was to move away from enums and const enums in favor of normal constants and literal types, which eliminates a dependency on increasingly non-standard compilation infrastructure.

So no news is good news.

@NullVoxPopuli
Copy link
Contributor

No perf difference on either of our local tests -- CI thinks improvement, so we'll merge.

@wycats wycats merged commit 0774f9c into main Nov 5, 2024
12 of 15 checks passed
@wycats wycats deleted the feature/error-recovery-redux-pt2 branch November 5, 2024 20:10
@wycats wycats restored the feature/error-recovery-redux-pt2 branch November 5, 2024 20:10
@wycats wycats deleted the feature/error-recovery-redux-pt2 branch November 5, 2024 20:10
@github-actions github-actions bot mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants