Skip to content

Add Liquid IL benchmark#525

Open
tekknolagi wants to merge 4 commits into
mainfrom
mb-benchmark-liquid-il
Open

Add Liquid IL benchmark#525
tekknolagi wants to merge 4 commits into
mainfrom
mb-benchmark-liquid-il

Conversation

@tekknolagi

@tekknolagi tekknolagi commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

https://github.com/tobi/liquid-il compiles Liquid code to Ruby code. Let's see how well YJIT and ZJIT can optimize that Ruby code.

River and others added 3 commits July 14, 2026 12:50
LiquidIL (https://github.com/tobi/liquid-il) compiles Liquid templates to
standalone Ruby that runs without an interpreter loop. This benchmark renders
that generated Ruby for a set of Liquid templates (a one-line output up to full
storefront product/cart/collection pages), exercising the machine-generated
code a JIT actually compiles: heavy runtime-helper dispatch, partial lambdas,
string-buffer building, hash lookups, and loops.

The exact generated Ruby is committed under generated/ (produced from
templates.yml by extract.rb and validated against each template's expected
output), so what the JIT compiles lives in the repo and does not drift with the
LiquidIL compiler. benchmark.rb requires the pinned liquid-il gem for its
runtime helpers and renders the committed modules.

Co-authored-by: Max Bernstein <max.bernstein@shopify.com>
@tekknolagi tekknolagi marked this pull request as ready for review July 14, 2026 17:12
@tekknolagi tekknolagi requested a review from a team July 14, 2026 17:12
run_benchmark(150) do
# Each render is quick; render the whole template set several times per
# iteration to reduce time-measurement noise (mirrors liquid-render).
100.times do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you consider iterating more per iteration? Like 1000?

This seems to take the shortest time per iteration (27ms) out of all headline benchmarks, so unless we change it, I would expect it to suffer from time-measurement noise more than other benchmarks.

interp: ruby 4.1.0dev (2026-07-13T13:26:16Z :detached: cb2ea293c6) +PRISM [x86_64-linux]
yjit: ruby 4.1.0dev (2026-07-13T13:26:16Z :detached: cb2ea293c6) +YJIT +PRISM [x86_64-linux]

----------------------  -------------  -------------  ------------  -----------
bench                     interp (ms)      yjit (ms)  yjit 1st itr  interp/yjit
activerecord             339.0 ± 0.0%   157.9 ± 0.0%         2.091        2.146
chunky-png               948.6 ± 0.0%   404.7 ± 0.0%         2.053        2.344
erubi-rails             1324.0 ± 0.0%   745.4 ± 0.0%         1.552        1.776
hexapdf                 2761.1 ± 0.0%  1300.2 ± 0.0%         1.545        2.124
liquid-c                  71.8 ± 0.0%    55.2 ± 0.0%         0.651        1.300
liquid-compile            56.4 ± 0.0%    41.3 ± 0.0%         0.604        1.366
liquid-il                 44.3 ± 0.0%    27.5 ± 0.0%         0.496        1.609
liquid-render            175.3 ± 0.0%    67.5 ± 0.0%         1.181        2.599
lobsters                1204.9 ± 0.0%  1133.9 ± 0.0%         0.635        1.063
mail                     167.1 ± 0.0%    83.0 ± 0.0%         0.616        2.013
psych-load              2414.1 ± 0.0%  1215.2 ± 0.0%         1.931        1.987
railsbench              2532.9 ± 0.0%  1457.8 ± 0.0%         1.256        1.738
rubocop                  231.2 ± 0.0%   318.8 ± 0.0%         0.374        0.725
ruby-lsp                 203.2 ± 0.0%   139.9 ± 0.0%         0.756        1.453
sequel                    55.6 ± 0.0%    42.1 ± 0.0%         1.365        1.322
shipit                  1954.0 ± 0.0%  1276.1 ± 0.0%         1.003        1.531

https://github.com/ruby/ruby-bench/actions/runs/29353153108/job/87154143699?pr=525

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