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
|
This is not worth pursuing right now. At present, it's hurting perf slightly. If could fix it to make it improve perf, then likely that perf improvement would be small anyway. So it's not worthwhile putting any time into now. Archived on overlookmotel/optimize-lexer-source-with-offset branch in case want to return to this later. |

SourcePositionhas a couple of invariants:SourcePositionmust be in bounds ofSource.SourcePositions 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 usizecalculations withstd::ptr::offset_from.offset_fromhas safety invariants which matchSource's.SourcePositions withu32::try_from(distance).unwrap_unchecked(). This informs compiler offset is definitely non-negative and<= u32::MAX.