---
title: "How the Cinder JIT’s function inliner helps us optimize Instagram"
description: "Cinder, Instagram's open-source CPython fork, ships a method-at-a-time JIT that lowers bytecode through HIR, SSA, LIR and register allocation to native code, removing interpreter dispatch and stack overhead."
url: "https://swe.quest/articles/how-the-cinder-jit-s-function-inliner-helps-us-optimize-instagram-bec4e8e06857e7ce"
canonical: "https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/"
source: "Meta Engineering"
published: "2022-05-02"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 13
tags: ["compilers","python","runtimes","performance"]
---

# How the Cinder JIT’s function inliner helps us optimize Instagram

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2022-05-02, 13 min read, Deep dive. Original: [https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/](https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/)

## Summary

Cinder, Instagram's open-source CPython fork, ships a method-at-a-time JIT that lowers bytecode through HIR, SSA, LIR and register allocation to native code, removing interpreter dispatch and stack overhead. Because type information is only available within a single function, generic operations like BinaryOp and VectorCall often can't be specialized. The new function inliner splices known call targets (identified via guarded global loads) into the caller's CFG. It does this by SSA-ifying the callee separately, splitting the block, rewriting LoadArg and Return into Assigns, adding shadow-frame bookkeeping, and cleaning the CFG. Later type inference and optimization passes can then specialize or even constant-fold the inlined code.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- compiler intermediate representations
- SSA form
- CPython bytecode
- JIT compilation basics ([easy posts on Compilers](https://swe.quest/tags/compilers.md?difficulty=easy))

## Keywords

Cinder, CPython, Instagram, HIR, SSA, shadow frames, Django

## Related posts

- [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.
- [Meta contributes new features to Python 3.12](https://swe.quest/articles/meta-contributes-new-features-to-python-3-12-9b216e044692b29d.md): Meta Engineering · 2023-10-05 · Medium · 6 min read · Python, Runtimes & VMs, Performance engineering, Compilers, Open source
  Meta upstreamed several features into CPython 3.12, many derived from its Cinder runtime: immortal objects (PEP 683) that skip reference counting to cut copy-on-write memory in forked Instagram workers, the @typing.override decorator (PEP 698), and inlined comprehensions (PEP 709) running up to 2x faster.
- [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.
- [Bun v0.1.9](https://swe.quest/articles/bun-v0-1-9-4ecfe167e5b29929.md): Bun · 2022-08-18 · Medium · 3 min read · Runtimes & VMs, JavaScript, Zig, Performance engineering, Compilers
  Bun v0.1.9 starts using JavaScriptCore's DOMJIT API to JIT-optimize native functions, making \`ptr()\` in \`bun:ffi\` 6-10x faster and \`TextEncoder.encodeInto\` 1.5-5x faster.
- [YJIT: Building a New JIT Compiler for CRuby](https://swe.quest/articles/yjit-building-a-new-jit-compiler-for-cruby-51c5ee3c390b2164.md): Shopify Engineering · 2021-10-14 · Easy · 6 min read · Compilers, Ruby, Runtimes & VMs, Performance engineering
  YJIT is a new JIT compiler built inside CRuby by Shopify and GitHub engineers, based on Basic Block Versioning, and aimed at real-world workloads like Rails where the GCC-based MJIT has struggled.

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)
