Rust’s compile‑time can feel like a wall when you’re iterating on a UI or a game prototype. Enter Relax, a live JIT compiler that lets you run a Cargo package straight from source, compiling each function the first time it’s called and hot‑patching edits into the running process. On an M4 MacBook a 3‑D demo drops from a 3‑minute cold build to an 11‑second first frame, and subsequent runs start in just over a second — all without invoking rustc, LLVM, or a linker.
In this post we’ll walk through how Relax works under the hood, compare its build‑time numbers to a traditional cargo build --release workflow, and discuss the trade‑offs you’ll see: slower optimized code (about 1.12× on x86‑64, 1.24× on arm64) and higher memory usage versus the dramatic iteration speed‑up. We’ll also cover the current limitations, how to set it up for your own crate, and what kinds of projects benefit most from this “edit‑run‑loop” approach.
What happened
Relax is a live compiler and JIT runtime written in Rust that lets you run a Cargo package directly from source, completely bypassing the traditional rustc → LLVM → linker pipeline. When you invoke relax run <package>, the tool loads the source files, parses them, and starts executing the program while it lazily compiles each function the first time it is called. Because there is no separate compilation step, the initial launch feels more like an interpreter than a conventional build‑and‑run cycle.
The JIT engine tracks which functions become “hot” during execution and recompiles them with more aggressive optimisations on the fly. If you edit a function while the program is running, Relax type‑checks the change, recompiles just that function, and hot‑patches the new code into the live process, preserving the existing state. More substantial edits—such as changes to struct layouts, trait implementations, or macro definitions—still require a restart, but the hot‑patching path works for the majority of routine edits.
The project is deliberately experimental. Its primary testing ground has been Makepad’s own edit‑run loop, where developers have observed dramatic reductions in perceived build latency (for example, a large 3D game that normally takes about three minutes to build can start its first frame in roughly eleven seconds on an M4 MacBook). Light testing on other codebases has been performed, but the authors warn that rough edges remain and encourage users to file bug reports. Windows support has not been verified, and not every crate in the Rust ecosystem is yet compatible with Relax’s JIT model.
Overall, Relax is positioned as a development‑time accelerator rather than a replacement for release builds. The authors recommend using cargo build --release for production binaries, while leveraging Relax to keep the edit‑run feedback loop tight during day‑to‑day coding.
Why it matters
Typical Rust development cycles still rely on a full cargo build, which invokes rustc and LLVM for every change. In a large codebase that step can take several minutes, turning a simple edit into a costly pause. When the edit‑run loop stretches beyond the time it takes to think about the next change, productivity suffers: you spend more time waiting than coding, and the feedback loop that makes debugging and experimentation effective is broken.
Relax attacks that bottleneck by removing the heavyweight rustc/LLVM stage for the majority of edits. Instead of rebuilding the whole binary, it JIT‑compiles each function the first time it is called, patches edits into the running process, and keeps hot code optimised on the fly. The result is an edit‑run loop measured in seconds rather than minutes. For example, a large 3‑D game that needs about three minutes to produce its first frame on a clean checkout can start the next frame in roughly eleven seconds on an M4 MacBook when run under Relax, and subsequent runs drop to just over a second.
That speed boost translates directly into developer productivity. Faster iteration means you can experiment with rendering pipelines, physics tweaks, or UI changes without waiting for a full rebuild, keeping the mental context fresh. In domains like game development, where the initial build already dominates the workflow, shaving off even a few seconds per change compounds into minutes saved each day. The quicker feedback also encourages more frequent testing, reducing the chance that bugs linger unnoticed.
Ultimately, Relax isn’t a replacement for release builds—those still go through the traditional cargo build --release pipeline—but it reshapes the daily development experience. By keeping the edit‑run loop tight, teams can maintain momentum on large Rust projects, iterate on complex systems more fluidly, and spend more time writing code and less time watching the compiler spin.
How it works (background)
Relax works by turning the usual Rust compile‑run cycle into a live, just‑in‑time process. When the program starts, no function has native code yet; the first time a function is invoked, Relax compiles that function to machine code, stores the result in an in‑process cache, and then executes it. Subsequent calls hit the cache directly, so the cost of compilation is paid only once per function. Because the JIT runs inside the same process as the program, hot functions can even be re‑optimised while the program is running, and the generated code is appended to the cache without needing a separate linker step.
At the same time, a lightweight borrow‑checker runs beside the program. Before a function is allowed to run, Relax type‑checks it, and the checker continues to verify the rest of the crate in the background. This “run‑time check‑first” mode means the program never executes code that hasn’t passed Rust’s safety rules, while the rest of the crate is being checked asynchronously. The design mirrors the traditional cargo check workflow, but the checks happen while the program is already alive, keeping the edit‑run loop tight.
State preservation across edits is another core idea. When you modify a source file, Relax re‑checks only the functions whose bodies changed, recompiles them, and hot‑patches the new code into the running process. All other functions keep their previously compiled versions, and any data that existed in the program’s memory remains untouched. Larger structural changes—such as altering a struct layout, adding a new impl, or changing a macro—cannot be hot‑patched; they trigger a full restart of the session, after which the new layout is loaded. This selective recompilation gives you near‑instant feedback for most edits while still handling the cases that require a clean rebuild.
- 1
Invoke
Run `relax run <package>` to start the program from source.
- 2
Lazy JIT
Each function is compiled to native code the first time it is called.
- 3
Hot‑patch
When a source file is edited, only changed functions are re‑checked, re‑compiled and patched in‑plac
- 4
Cache warm
Compiled functions are cached, so later launches execute instantly.
- 5
Restart if needed
Structural changes (e.g., struct layout) trigger a full session restart.
The key details and numbers
On an M4‑based MacBook, the biggest test we have is a large 3‑D game that starts from a clean checkout. The first time you run it through Relax, the JIT compiler has to compile every function on demand, so the initial frame takes roughly three minutes to appear. Once the code cache is warm, the same game launches the next frame in about eleven seconds, giving you a development turnaround that feels almost instantaneous compared with a full cargo‑build cycle.
A much smaller workload shows the same warm‑up advantage even more starkly. Building a tiny example application from scratch on the same M4 machine takes about 3.7 seconds when the process is cold. After the first run, the JIT‑generated code is cached, and a subsequent launch completes in roughly 0.41 seconds. That warm‑run time is an order of magnitude faster than the cold build, illustrating how Relax can keep the edit‑run loop tight for everyday coding tasks.
The speed‑up comes with a trade‑off in raw execution performance. Across a suite of 21 benchmark workloads, the code produced by Relax runs 1.12× slower on x86‑64 and 1.24× slower on arm64, which works out to a geometric mean slowdown of about 1.18× compared with a binary built by rustc --release. In practice this means that while you get dramatically faster iteration times, the final runtime of the JIT‑compiled binary is modestly slower than a traditional release build.
Overall, the numbers paint a clear picture: Relax slashes the time you spend waiting for builds—down to seconds for small projects and minutes for large ones—while incurring a predictable, modest performance penalty on the generated code. For day‑to‑day development where iteration speed matters more than absolute execution speed, those trade‑offs are often worth it.
Time to first frame or program start for different scenarios
What it means for developers
What this means for us as developers is that the edit‑run loop can stay alive. Relax keeps a single process running while you edit, and when you save a file it hot‑patches only the functions that changed. The rest of the program continues with its existing state, so you no longer have to wait for a full rebuild, relink, and restart just to see a tweak take effect.
The live‑testing workflow is built right into the tool. A relax test --live command watches your source files; as soon as you save, Relax re‑checks, recompiles the affected functions, and automatically reruns the tests that exercised those functions. In the Makepad demo, saving a file caused 92 tests to be rebuilt and run in just over two seconds, keeping the test suite warm and giving immediate feedback on the change you just made.
Beyond fast iteration, Relax also gives you debugging‑style capabilities without pulling in a separate debugger. When a panic occurs, the thread is parked with its stack intact, letting you inspect locals, evaluate Rust expressions, and then either resume or restart the function. You can set breakpoints with a simple break <file>:<line> command; hitting a breakpoint similarly parks the thread, exposing locals and allowing you to continue when you’re ready. These features let you pause, inspect, and step through code while the JIT‑compiled program stays alive.
Overall, the workflow collapses what used to be three distinct phases—compile, run, debug—into a single, continuously running session. Because only the changed code is recompiled and the program’s state is preserved, you can experiment, test, and troubleshoot in near‑real time, which can dramatically shorten the feedback loop during development.
Limits and caveats
Relax’s speed‑up comes with a trade‑off in raw performance. The JIT‑compiled code it produces is typically slower than a traditional cargo build --release binary – on the benchmark set the slowdown averages 1.12× on x86‑64 and 1.24× on ARM64, with individual workloads varying around that range. In practice you’ll see a modest penalty on compute‑heavy loops, while some tiny programs may even run a little faster if LLVM’s optimisations are less effective for that case.
Memory pressure is another side effect. Because every compiled function lives in an ever‑growing code cache inside the running process, the cache directory (target/relax) can occupy between 120 MB and 190 MB even for a minimal “hello‑world” crate. The cache is append‑only, so repeated edits keep expanding the footprint until you restart the session or manually clear the directory.
Support is still incomplete. The project lists a set of known gaps, and many crates – especially those that rely on complex build scripts or exotic target features – simply won’t run under Relax yet. Moreover, only function bodies are hot‑patched; changes that affect struct layout, import statements, trait or impl headers, or macro definitions force a full restart of the JIT session. Those restarts are fast compared to a full rebuild, but they still interrupt the edit‑run loop.
Finally, Relax is explicitly aimed at the development cycle, not at shipping. For any production artifact you should still invoke the standard toolchain (cargo build --release) to get the fully optimised, statically linked binary that users expect. Think of Relax as a convenience for rapid iteration, with the understanding that you’ll fall back to the proven release pipeline when it matters.
Key takeaways
- Relax is a live compiler and JIT runtime for Rust written in Rust that compiles each function on first call, optimizes hot code while the program runs, and patches edits into the running process.
- In a large 3‑D game on an M4 MacBook, the first frame after a clean checkout takes about 3 minutes with Cargo + rustc, but runs in 11 seconds when launched via Relax; the same game’s second run starts in 1.15 seconds with no recompilation.
- For a small app on the same hardware, a cold start takes 3.7 seconds and a warm start 0.41 seconds when using Relax.
- Optimized code generated by Relax is slower than a standard
cargo build --releasebinary, running 1.12× slower on x86‑64 and 1.24× slower on ARM64 (geometric mean of 21 workloads). - The JIT code cache for a simple “hello” package occupies 120–190 MB in the target/relax directory, and the overall process uses more memory than a regular Cargo build.
- Relax supports hot‑patching of function bodies while preserving program state, but changes to struct layouts, imports, traits, impl headers, or macros require a restart of the session.
Visual summary
The key points as images. Tap one to open it, or save it to share.


