Skip to content

[regexp] Use required literal filter to speed up matching - #502

Merged
Hans-Halverson merged 1 commit into
masterfrom
regexp-literal-filters-search
Aug 12, 2026
Merged

[regexp] Use required literal filter to speed up matching#502
Hans-Halverson merged 1 commit into
masterfrom
regexp-literal-filters-search

Conversation

@Hans-Halverson

@Hans-Halverson Hans-Halverson commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

Use the RequiredLiteralFilter introduced in #501 during matching. This filter allows us to 1) filter out any inputs that never contain the required literal and 2) if the literal has a known bound from the start of the match, restricts match start positions that need to be checked. Is used in combination with the MatchStartFilter in order to further optimize where the backtracking matcher even needs to be run.

Notes:

  • Required literal search is specialized for the "matches can only appear at the start" case by restricting search to bounded window, if possible.
  • We must conservatively widen the search window in HeapTwoByteCodePointLexerStream to account for code points that take two code units.

Seeing a massive +62.6% increase to Octane RegExp benchmark score from this change, an a +3.3% overall improvement to Octane score.

Tests

  • Added LLM-generated integration tests exercising the required literal filter in a variety of situations

@Hans-Halverson
Hans-Halverson force-pushed the regexp-literal-filters-search branch 2 times, most recently from 853a62f to 74706ba Compare August 12, 2026 00:34
@Hans-Halverson
Hans-Halverson force-pushed the regexp-literal-filters-search branch from 74706ba to fe767fe Compare August 12, 2026 00:37
@Hans-Halverson
Hans-Halverson merged commit dda302c into master Aug 12, 2026
11 checks passed
@Hans-Halverson
Hans-Halverson deleted the regexp-literal-filters-search branch August 12, 2026 00:59
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