Hacker News AI · 2026/10/20 23:50:29

ra-jit 发布 Rust 即时编译工具 提速 24 倍

原标题:24x faster Rust compilation with rust-analyzer
68AI 研判分
核心综述

开源项目 ra-jit 推出基于 rust-analyzer 的即时编译技术,实现保存文件后毫秒级热更新运行中程序。该工具通过增量重编仅修改函数,将单次编辑构建时间从 169ms 降至 7ms,提升约 24 倍,但暂不支持借用检查且仅限 Apple Silicon 实时预览。

报道全文原始报道全文

本文目录6 个章节

ra-jit

Edit Rust. See it change in milliseconds, in the program that is already running.

文本
nix run github:indexable-inc/ra-jit

That opens a Game of Life window you can edit while it runs (live on macOS Apple silicon).

Editing the running Game of Life: rule, colours and speed change live

For release news: Watch → Custom → Releases on GitHub.

What you get

  • Live edits. Save a file and the running program has the new code about a millisecond later. Its state stays. (docs/live.md)
  • Fast builds. After the first build, an edit rebuilds only the functions you changed. No rustc, no waiting.
  • Same cargo. cargo ra-jit build|run|test|check in any project.

How fast

Live edit to running code, Game of Life demo (median of 20 edits, one 96-core Linux machine):

Editincremental cargo buildra-jit live
One function169 ms7 ms24x
One function, 300 new functions added282 ms60 ms4.7x

Edit, then build (generated 200-crate workspace, Linux x86-64, 8 CPUs, both warm and incremental, same linker, median of three):

Editcargora-jit
A function in the main crate1.76 s0.42 s4.2x
A function in a crate everything depends on6.33 s0.60 s10.6x
Functions in 30 crates at once6.26 s0.62 s10.1x
A new function2.09 s0.56 s3.7x
A signature used in every crate13.87 s10.87 s1.3x

Not measured yet: real projects, and a build from nothing against a fresh cargo build (#benchmarks).

Try it on your project

文本
nix run github:indexable-inc/ra-jit#ra-jit -- build

No nix? cargo +1.99.0 install --locked ra-jit, or put the binaries from a release on your PATH. Then use Rust 1.99.0 with its source: rustup toolchain install 1.99.0 -c rust-src && rustup override set 1.99.0.

Use it as your normal cargo build

文本
nix profile install github:indexable-inc/ra-jit#ra-jit
ra-jit enable

From then on plain cargo build, run, test and check in any project go through ra-jit. ra-jit disable puts your cargo config back.

Live edits

Add the crate and poll once per frame:

TOML
ra-jit-live = "0.1"
RUST
let mut live = ra_jit_live::Live::start().ok();
loop {
    if let Some(outcome) = live.as_mut().and_then(|it| it.poll()) {
        eprintln!("ra-jit: {outcome}");
    }
    // ...your frame
}

What to know

  • Live edits work on macOS Apple silicon only. Elsewhere you still get fast builds.
  • No borrow checker: keep running cargo check.
  • Rust 1.99.0 only.
  • Changing a struct the program is using asks for a restart.

More: how it works, full results, what is supported.