Closed ianks closed 3 weeks ago
This PR speeds up lexing by making using of some new strscan features when available, namely StringScanner#peek_byte.
strscan
StringScanner#peek_byte
Comparison of be rake benchmark:strict on Ruby 3.4:
be rake benchmark:strict
72.452 (± 4.1%) i/s (13.80 ms/i) - 2.170k in 30.029157s
92.409 (± 1.1%) i/s (10.82 ms/i) - 2.772k in 30.002144s
I ran the two in A/B style against some production traffic. The following measures Liquid::Template.parse with the new lexer:
Liquid::Template.parse
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.
This PR speeds up lexing by making using of some new
strscan
features when available, namelyStringScanner#peek_byte
.Benchmarks
Local
Comparison of
be rake benchmark:strict
on Ruby 3.4:72.452 (± 4.1%) i/s (13.80 ms/i) - 2.170k in 30.029157s
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: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.