-
-
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(lexer): optimize Source
#8295
base: main
Are you sure you want to change the base?
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #8295 will not alter performanceComparing Summary
|
5a91661
to
5270ad1
Compare
Ha! It actually seems to reduce perf slightly, according to CodSpeed. Probably it's the |
8442546
to
727ab4e
Compare
5270ad1
to
5eeb81f
Compare
727ab4e
to
c07b69c
Compare
5eeb81f
to
645092c
Compare
c07b69c
to
de208a9
Compare
645092c
to
134a26c
Compare
de208a9
to
e1f8ea4
Compare
134a26c
to
c691429
Compare
c691429
to
703d983
Compare
SourcePosition
has a couple of invariants:SourcePosition
must be in bounds ofSource
.SourcePosition
s cannot exceedu32::MAX
, because that's the upper limit on size of source text.However, prior to this PR, all compiler could see is pointers which could be anything. It wasn't able to understand the invariants, or utilize them for efficient codegen.
This PR makes compiler aware of these invariants in 2 ways:
>
,<
etc, and calculating offsets viaptr as usize
calculations withstd::ptr::offset_from
.offset_from
has safety invariants which matchSource
's.SourcePosition
s withu32::try_from(distance).unwrap_unchecked()
. This informs compiler offset is definitely non-negative and<= u32::MAX
.