-
-
Notifications
You must be signed in to change notification settings - Fork 723
perf(lexer): hint to compiler that EOF only happens once #15512
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): hint to compiler that EOF only happens once #15512
Conversation
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 #15512 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR applies a performance optimization to the lexer's EOF handling by using a #[cold] attribute to hint to the compiler that the EOF branch is rarely taken, potentially improving branch prediction for the hot path.
- Wraps the EOF return in a
#[cold]function to optimize branch prediction
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
In `Lexer::read_next_token`, reaching EOF is very uncommon (because it only happens once at end of the file). Inform compiler of this using a `#[cold]` function, so it makes "not at EOF" the default path. Small improvement on all the lexer and parser benchmarks (+1% on most lexer benchmarks).
bef04c1 to
2f0518d
Compare
In `Lexer::read_next_token`, reaching EOF is very uncommon (because it only happens once at end of the file). Inform compiler of this using a `#[cold]` function, so it makes "not at EOF" the default path. Small improvement on all the lexer and parser benchmarks (+1% on most lexer benchmarks).

In
Lexer::read_next_token, reaching EOF is very uncommon (because it only happens once at end of the file). Inform compiler of this using a#[cold]function, so it makes "not at EOF" the default path.Small improvement on all the lexer and parser benchmarks (+1% on most lexer benchmarks).