---
title: "After the Refactor: A Path to Faster Rendering with Liquid-C"
description: "Liquid-C's bytecode VM was refactored to replace its sequential constant pointer with per-instruction indexes into the constants array, so the instruction pointer can jump freely without recomputing constant offsets."
url: "https://swe.quest/articles/after-the-refactor-a-path-to-faster-rendering-with-liquid-c-69e5ad9480eaeead"
canonical: "https://shopify.engineering/refactor-path-to-faster-rendering-liquid-c"
source: "Shopify Engineering"
published: "2022-03-10"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 4
tags: ["runtimes","compilers","ruby","c-cpp","refactoring"]
---

# After the Refactor: A Path to Faster Rendering with Liquid-C

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2022-03-10, 4 min read, Deep dive. Original: [https://shopify.engineering/refactor-path-to-faster-rendering-liquid-c](https://shopify.engineering/refactor-path-to-faster-rendering-liquid-c)

## Summary

Liquid-C's bytecode VM was refactored to replace its sequential constant pointer with per-instruction indexes into the constants array, so the instruction pointer can jump freely without recomputing constant offsets. This is a prerequisite for compiling Liquid's If and For tags via new GOTO/JMP-style instructions. A hash table now deduplicates constants (e.g. a cart template dropped from 157 to 104 constants), but the change slightly increased memory use and parse time and did not noticeably speed up theme rendering on its own.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)

## Prerequisites

- bytecode virtual machines
- template engines
- C Ruby extensions ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))

## Keywords

Liquid, Liquid-C, Shopify

## Related posts

- [Copy Hunting](https://swe.quest/articles/copy-hunting-7c2f19f97f1f7edc.md): TigerBeetle · 2023-07-26 · Medium · 11 min read · Zig, Compilers, Performance engineering, Debugging, Developer tools
  Reading Zig's emitted LLVM IR as plain text and grepping it is a practical substitute for staring at disassembly when chasing implicit memcopies and binary bloat.
- [Speculative Optimizations for WebAssembly using Deopts and Inlining](https://swe.quest/articles/speculative-optimizations-for-webassembly-using-deopts-and-inlining-bb89e7c53ac7945f.md): V8 · 2025-06-24 · Hard · 17 min read · WebAssembly, Compilers, Runtimes & VMs, Performance engineering
  V8 in Chrome M137 adds speculative call\_indirect inlining and deoptimization support for WebAssembly, using runtime call-target feedback gathered by the Liftoff baseline compiler so TurboFan can inline up to four likely callees behind cheap instance and target checks.
- [Optimizing JavaScript Standard Library Functions in JSC](https://swe.quest/articles/optimizing-javascript-standard-library-functions-in-jsc-1faf7ca6f0ee5e50.md): WebKit · 2021-07-28 · Hard · 6 min read · Runtimes & VMs, Compilers, JavaScript, Browsers, Performance engineering
  JavaScriptCore speeds up Function.prototype.toString by stacking several general optimizations that together reduce a call like f.toString() to a constant string.
- [Introducing the JetStream 3 Benchmark Suite](https://swe.quest/articles/introducing-the-jetstream-3-benchmark-suite-df1c85fb12e2a75d.md): WebKit · 2026-03-31 · Hard · 21 min read · Runtimes & VMs, WebAssembly, Compilers, Memory management, Performance engineering
  JetStream 3 replaces JetStream 2's separate Wasm Startup/Runtime scores with the JavaScript-style first-iteration, worst-case and average-case scoring.
- [We Have to Start Over: From Atom to Zed](https://swe.quest/articles/we-have-to-start-over-from-atom-to-zed-8db3be76f03d8a79.md): Zed · 2024-02-12 · Easy · 25 min read · Rust, Developer tools, Performance engineering, Data structures
  Zed's co-founders explain why they abandoned Atom's Electron/JavaScript stack and rebuilt a code editor in Rust: JavaScript's pointer-chasing arrays, uncontrollable GC pauses, and the costly JS/C++ boundary for multithreading made performance work feel like fighting the platform.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
