Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.
https://shopify.github.io/liquid/
MIT License
11.13k stars 1.39k forks source link

Speed up the lexer for Ruby 3.4+ #1832

Closed ianks closed 3 weeks ago

ianks commented 3 weeks ago

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:

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.