Skip to content

[WIP] Improve parser-class cache threshold defaults#22

Draft
suleman-uzair wants to merge 4 commits into
mainfrom
parser-performance-and-dynamic-callbacks
Draft

[WIP] Improve parser-class cache threshold defaults#22
suleman-uzair wants to merge 4 commits into
mainfrom
parser-performance-and-dynamic-callbacks

Conversation

@suleman-uzair
Copy link
Copy Markdown

@suleman-uzair suleman-uzair commented May 21, 2026

This PR updates adaptive cache threshold handling so parser-class grammars use a separate fallback from direct atom-level parsing.

This PR:

  • adds a :parser_default threshold for parser-class contexts without a named override
  • sets that parser-class fallback to 0 so memoization starts immediately for unnamed parser classes
  • keeps direct atom-level parsing on the existing 1000 threshold
  • keeps named parser thresholds, such as JsonParser, ahead of the parser-class fallback
  • makes the fallback check explicit so 0 is treated as an intentional threshold value
  • adds focused specs for atom-level defaults, parser-class defaults, and named parser precedence
  • adds a benchmark-framework case that compares the new parser-class fallback with the previous 1000 behavior

This matters for recursive or retry-heavy parser-class grammars where the same atom can be attempted again at the same source position before the input reaches 1000 bytes.

This change affects the pure-Ruby parsing path only. Native mode still goes through the Rust-backed parser path and is not changed here.

@suleman-uzair suleman-uzair changed the title [WIP] Speed up parser workloads and fix dynamic callbacks [WIP] Improve parser-class cache threshold defaults May 22, 2026
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