Skip to content
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

Speed up the lexer for Ruby 3.4+ #1832

Merged
merged 4 commits into from
Oct 23, 2024
Merged

Speed up the lexer for Ruby 3.4+ #1832

merged 4 commits into from
Oct 23, 2024

Conversation

ianks
Copy link
Contributor

@ianks ianks commented Oct 23, 2024

This PR speeds up lexing by making using of some new strscan features when available, namely StringScanner#peek_byte.

Benchmarks

Local

Comparison of be rake benchmark:strict on Ruby 3.4:

  • old parse: 72.452 (± 4.1%) i/s (13.80 ms/i) - 2.170k in 30.029157s
  • new parse: 92.409 (± 1.1%) i/s (10.82 ms/i) - 2.772k in 30.002144s

Production

I ran the two in A/B style against some production traffic. The following measures Liquid::Template.parse with the new lexer:

image

1: Old
2: New

To make this work smoothly with CI and such, I needed to bump min version to Ruby 3.0 and remove Gemfile.lock, which need to be updated anyway.

@ianks ianks merged commit b355378 into main Oct 23, 2024
11 checks passed
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.

2 participants