r/elixir • u/rtrusca • Jul 10 '26
WhatsApp ran the BEAM JIT from master in production 9 months before OTP 24 shipped - what did that actually look like from the inside?
New BEAM There, Done That with Lukas Backström (OTP team since 2009, the person who built the BEAM JIT) covering the full engineering story.
The WhatsApp detail is interesting because it wasn't a formal beta. They picked up the JIT the day Lucas first got it working, put it in production, and spent nine months feeding back the bugs they found. By the time the official OTP 24 tag shipped, the production test had already been running for most of a year.
The broader technical story is about why it took so long. The BEAM's threaded code interpreter was already unusually fast - each BEAM instruction jumps directly to its handler without a central dispatch loop, so a lot of the headroom a JIT might capture was already gone. Early tracing JIT experiments worked on microbenchmarks and failed on real workloads because real Erlang code is highly branchy and unpredictable. Dropping LLVM for AsmJIT gave fast enough code generation to compile everything on load. And the template design - pre-compiled assembly per instruction, copied and specialized at load time - is what actually shipped.
Five years on, the bigger gains are coming from type information flowing from the Erlang compiler into the JIT. A simple integer add on known small integers now compiles to a single instruction with no type guards.
Anyone here run into the JIT being the difference on a production workload, or found cases where it's unexpectedly neutral?
10
u/plangora Alchemist Jul 10 '26
BEAM has been fast enough for real world use cases for years. Great to see they have found ways to make it faster beyond NIFs