perf(parser): remove lexer lookahead#11332
perf(parser): remove lexer lookahead#11332camchenry wants to merge 3 commits into05-27-refactor_parser_remove_lexer_lookahead_in_module_parsingfrom
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 Instrumentation Performance ReportMerging #11332 will degrade performances by 4.92%Comparing Summary
Benchmarks breakdown
|
7954053 to
1323dbb
Compare
940e394 to
3bf4f58
Compare
|
Similar to before, this speeds up the lexer (~3-4%) but slows down the parser (~3-4%) which nets out to being slower than before. However, once we work on #11334 and other small perf improvements, we should be able to recover this performance and do even better in the long run. |
| if !trailing_separator | ||
| && self.at(separator) | ||
| && self.lookahead(|p| { | ||
| p.bump_any(); | ||
| p.at(close) | ||
| }) | ||
| { |
There was a problem hiding this comment.
I suggest splitting this change out into a separate PR. Presumably these lines is where the parser perf regression is coming from. Removing the VecDeque from the lexer should be a gain in both lexer and parser benchmarks.
Then in this block of code, I think we can refactor to avoid using lookahead at all. I think that should be possible since we're immediately bumping on to next token anyway in the next line self.expect(separator). If we can do that, hopefully it'll remove the perf regression.
But it'd be useful to benchmark that in isolation without the change of removing the VecDeque also in the mix - hence why I think it'd be better in a separate PR.
There was a problem hiding this comment.
@overlookmotel got it, I can an intermediate PR to benchmark this specifically. I was planning to write a follow-up PR to improve the performance in this function and hopefully remove the lookahead.
3bf4f58 to
186b6f2
Compare
1323dbb to
f85a6a4
Compare
186b6f2 to
61fdf9f
Compare
61fdf9f to
f0a9349
Compare
|
Okay Graphite seems to think this PR doesn't exist. I'm just going to close and re-create. |

Removes the lookahead
VecDequein the lexer and all of the bookkeeping code depending on it.