How the Cinder JIT’s function inliner helps us optimize Instagram
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.
Related posts
- Optimizing JavaScript Standard Library Functions in JSC
WebKit hardMasterJavaScriptCore speeds up Function.prototype.toString by stacking several general optimizations that together reduce a call like f.toString() to a constant string. The result is cached on the function object, watchpoints let the DFG/FTL speculate that f and f.toString never change, an intrinsic replaces the generic call with a FunctionToString instruction that loads the cached value inline with a C++ fallback, and the abstract interpreter constant-folds the load when the receiver is known. The walkthrough also contrasts C++ and JS-implemented builtins, noting that native builtins can't be inlined but intrinsics can still emit their fast paths.
- Meta contributes new features to Python 3.12
Meta Engineering mediumAdeptMeta 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. Other changes include opt-in eager asyncio tasks that resolve immediately-available results without event-loop scheduling, a LOAD_SUPER_ATTR opcode that avoids allocating super objects, and new async_tree and comprehension benchmarks in pyperformance. New runtime hooks, including vectorcall entrypoints, dict/type/function/code watchers, and a thread-safe perf-map API, let third-party JITs like CinderX plug into CPython.
- Copy Hunting
TigerBeetle mediumAdeptReading 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. A small line-by-line tool, copyhound, flags large `llvm.memcpy` calls per function and also sums IR lines per generic function name to expose monomorphization blowup, the same idea as cargo-llvm-lines. In TigerBeetle it traced copies to `std.meta.eql`, which was replaced with a comptime-checked word-wise byte comparison. In the Zig compiler it found an inlined float-parsing slow path costing 10 KB of stack, fixed with `@setCold`. Making comptime parameters runtime in a version-printing function cut 300 bytes from the binary.
- Bun v0.1.9
Bun mediumAdept
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. To get there, Bun extended DOMJIT to accept Typed Array arguments and to declare more kinds of side effects. Bun now code-generates C++ binding classes and ABI-checked Zig bindings from JavaScript class definitions, an approach inspired by WebIDL, replacing most use of the JSC C API. Other changes include a more reliable, lower-CPU event loop on Linux, about 20% faster `Bun.serve` through better `Headers` handling, native `buffer` and `process` modules, and numerous crash fixes.
- YJIT: Building a New JIT Compiler for CRuby
Shopify Engineering easyNoviceYJIT 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. After about a year it delivers speedups over the interpreter of 20% on railsbench, 39% on liquid template rendering and 37% on activerecord, with near-peak performance after one iteration. It passes CRuby's ~30,000 tests and the CI suites of Shopify Core and GitHub, and is slated to merge into Ruby 3.1. Only about 79% of railsbench instructions currently run in YJIT, and planned CRuby changes include object shapes, cheaper type tagging, finer-grained constant caching, a lighter calling convention, and rewriting C runtime methods in Ruby to enable inlining.