Skip to content

Parser: fix exponential parse time on compound keyword chains#2350

Open
LucaCappelletti94 wants to merge 3 commits into
apache:mainfrom
LucaCappelletti94:pathological3
Open

Parser: fix exponential parse time on compound keyword chains#2350
LucaCappelletti94 wants to merge 3 commits into
apache:mainfrom
LucaCappelletti94:pathological3

Conversation

@LucaCappelletti94
Copy link
Copy Markdown
Contributor

Same family as #2344 and #2349. A reserved keyword in field position (e.g. NOT in .not-b.not-b...) drives parse_prefix -> parse_not -> parse_subexpr, re-walking the chain at every segment and doubling the work. The result is always rejected (UnaryOp), so the speculation is wasted, and parse_identifier in the existing None branch produces the same Identifier directly. The solution I identified is to skip the speculative parse_prefix in parse_compound_expr when the next token is a Word not followed by (. Surfaced by subql fuzzing on a 527 B input that took 2.65 s and now takes 270 us.

N before after
5 63.3 us 8.06 us
10 1.97 ms 15.1 us
15 65.3 ms 22.4 us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant