-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
perf(parser): reduce Token
size from 16 to 12 bytes
#2010
Merged
Boshen
merged 1 commit into
main
from
01-13-perf_parser_reduce_Token_size_from_16_to_12_bytes
Jan 13, 2024
Merged
perf(parser): reduce Token
size from 16 to 12 bytes
#2010
Boshen
merged 1 commit into
main
from
01-13-perf_parser_reduce_Token_size_from_16_to_12_bytes
Jan 13, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
Boshen
force-pushed
the
01-13-perf_parser_reduce_Token_size_from_16_to_12_bytes
branch
from
January 13, 2024 03:40
1f1bde5
to
99d1179
Compare
CodSpeed Performance ReportMerging #2010 will not alter performanceComparing Summary
|
Boshen
force-pushed
the
01-13-perf_parser_reduce_Token_size_from_16_to_12_bytes
branch
from
January 13, 2024 04:20
99d1179
to
31a69cb
Compare
Boshen
deleted the
01-13-perf_parser_reduce_Token_size_from_16_to_12_bytes
branch
January 13, 2024 04:42
This was referenced Jan 19, 2024
Boshen
pushed a commit
that referenced
this pull request
Jan 30, 2024
Counter-intuitively, it seems that *increasing* the size of `Token` improves performance slightly. This appears to be because when `Token` is 16 bytes, copying `Token` is a single 16-byte load/store. At present, it's 12 bytes which requires an 8-byte load/store + a 4-byte load/store. https://godbolt.org/z/KPYsn3ab7 This suggests that either: 1. #2010 could be reverted at no cost, and the overhead of the hash table removed. or: 2. We need to get `Token` down to 8 bytes! I have an idea how to *maybe* do (2), so I'd suggest leaving it as is for now until I've been able to research that. NB I also tried putting `#[repr(align(16))]` on `Token` so that copying uses aligned loads/stores. That [hurt the benchmarks very slightly](https://codspeed.io/overlookmotel/oxc/branches/lexer-pad-token), though it might produce a gain on architectures where unaligned loads are more expensive (ARM64 I think?). But I can't test that theory, so have left it out.
IWANABETHATGUY
pushed a commit
to IWANABETHATGUY/oxc
that referenced
this pull request
May 29, 2024
I also had to change how the string for private identifiers are built, otherwise they will always be allocated.
IWANABETHATGUY
pushed a commit
to IWANABETHATGUY/oxc
that referenced
this pull request
May 29, 2024
Counter-intuitively, it seems that *increasing* the size of `Token` improves performance slightly. This appears to be because when `Token` is 16 bytes, copying `Token` is a single 16-byte load/store. At present, it's 12 bytes which requires an 8-byte load/store + a 4-byte load/store. https://godbolt.org/z/KPYsn3ab7 This suggests that either: 1. oxc-project#2010 could be reverted at no cost, and the overhead of the hash table removed. or: 2. We need to get `Token` down to 8 bytes! I have an idea how to *maybe* do (2), so I'd suggest leaving it as is for now until I've been able to research that. NB I also tried putting `#[repr(align(16))]` on `Token` so that copying uses aligned loads/stores. That [hurt the benchmarks very slightly](https://codspeed.io/overlookmotel/oxc/branches/lexer-pad-token), though it might produce a gain on architectures where unaligned loads are more expensive (ARM64 I think?). But I can't test that theory, so have left it out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I also had to change how the string for private identifiers are built, otherwise they will always be allocated.