blog.rust.gay

Rust's parallel frontend is now on by default in nightly

Rust's compiler frontend has been able to run in parallel for years, but it was never the default. That changed with nightly-2026-11-14: the nightly toolchain now enables the parallel frontend with two threads. The Rust team is not calling this a stabilization. It is a deliberately wide test run before stabilization, and the interesting questions are not the single-crate speedups in the announcement. They are whether whole workspaces get faster, whether builds stay reproducible, and whether the compiler's diagnostics remain stable enough for CI.

The change is easy to misread as "Rust builds are now 3x faster." Some benchmarks do show roughly that, but only under specific conditions: one crate, a clean build, eight frontend threads, and a workload where type checking dominates. A normal cargo build of a large workspace is a different animal. Cargo is already compiling crates in parallel, LLVM is already using multiple threads, and the machine may already be saturated before the frontend gets a chance to help.

What actually changed

The Rust compiler has two broad halves. The frontend parses, expands macros, resolves names, type-checks, and borrow-checks. The backend turns the resulting intermediate representation into machine code, largely through LLVM. The backend has used multiple threads for a long time. The frontend, which includes the work that decides whether a program is valid Rust, ran on a single thread.

The compiler has had an opt-in parallel frontend since 2023, with a plan to stabilize it in 2024. That plan slipped. Correctness and reproducibility issues kept showing up, and the performance work was not finished. Over the last year, Vadim Petrochenkov and other contributors fixed a long list of those issues. The team now believes the frontend is ready for a broader trial, but not ready to be declared stable.

The default is two frontend threads. That is a conservative number on purpose. Two threads are enough to exercise the parallel code paths and expose races or ordering bugs, but not so many that memory use jumps or a laptop becomes unusable. The team explicitly says it wants to find remaining issues "in the wild" before stabilization. That is a different goal from maximizing throughput.

You can change the thread count with --jobs-frontend. The flag is unstable, so it needs -Zunstable-options on nightly. You can put it in RUSTFLAGS or in .cargo/config.toml:

[build]
rustflags = ["-Zunstable-options", "--jobs-frontend=8"]

Setting --jobs-frontend=1 disables the parallel frontend. That is the escape hatch if a build starts behaving strangely, and the team wants to hear about it.

The benchmark that looks amazing

The headline numbers come from compiling a single leaf crate from scratch. With eight frontend threads, the aggregated wall-time mean improved by 44.23% for cargo check, 41.76% for clippy, 36.1% for a debug build, and 27.88% for an optimized build. In some cases, checking nalgebra, cargo, or diesel was almost three times faster.

Those numbers are real, but they describe a narrow shape of work. A leaf crate has no downstream crates waiting on it, and the benchmark measures the compiler's frontend in isolation. If you spend your day running cargo check on a single crate with a warm dependency graph, the parallel frontend can be a meaningful improvement. If you run clean release builds of a large workspace, the gain may be much smaller.

The announcement is careful about this. It says the results were varied, that some benchmarks barely helped, and that the backend can also get faster for reasons explained in the earlier parallel-rustc post. It also warns that whole-graph builds may already saturate the CPU through Cargo and LLVM. The frontend is not a second pool of free cores. It is another consumer of the same machine.

The more representative end-to-end result is a cargo check of the cargo crate on an eight-core machine. With one frontend thread it took 36.7 seconds. With two it took 35.1 seconds, with four 31.9 seconds, and with eight 30.8 seconds. That is about a 15% end-to-end improvement at eight threads, not 44%. The difference is the point: the single-crate benchmark isolates the frontend, while the end-to-end build includes everything else Cargo and LLVM are already doing.

Incremental builds are the harder case

Most developers do not rebuild a crate from scratch very often. They edit a file and run cargo check or cargo build again. Incremental rebuilds reuse compiler state, and that changes the parallel story. The announcement reports a mean improvement of 3-5% for incremental rebuilds, but also says the benchmarks for this case are not great and results will vary.

That is a modest number, and it is worth taking seriously. A 3-5% improvement on the edit-check loop is still useful, but it is not the kind of change that justifies rewriting CI assumptions. The team is also still discovering which parts of the frontend can actually run in parallel. Macro expansion and name resolution have been a Google Summer of Code project, and there is an open pull request to parallelize the lowering of the AST to HIR. Some frontend work remains sequential even when the parallel frontend is enabled.

The practical advice is to measure your own workload. Compare a clean cargo check, a clean debug build, a clean release build, and an incremental rebuild with one, two, four, and eight frontend threads. Keep the same dependency graph, the same feature flags, and the same machine. If the machine is already busy with Cargo jobs or LLVM, the frontend thread count may need to come down, not up.

Two threads is a bug-finding decision

The most important design choice is not the thread count. It is the decision to ship the default on nightly before stabilization. Nightly users are the people most likely to hit weird compiler states, and they are also the people most likely to file a useful bug report. The team gets a large, diverse test corpus without exposing stable users to the change.

That trade-off has a cost. Parallelism makes some compiler behavior less deterministic. The announcement says the order of diagnostics may not be deterministic when the parallel frontend is enabled. For a human reading errors in a terminal, that is annoying. For a CI system that compares compiler output, or a tool that parses diagnostics, it can be a real regression.

There is also a reproducibility question. The team says some generated binaries may not be reproducible when the parallel frontend is used, and it considers those cases bugs. There are open issues tagged for reproducibility and the parallel compiler. If you maintain a reproducible-build pipeline, this is the part to test first. A compiler that produces a different binary on each run is not acceptable for a distribution that signs its outputs or attests to their contents.

The team is asking for exactly this kind of report. If a build crashes, produces a non-reproducible binary, or emits diagnostics in a way that breaks tooling, the useful thing is a minimal reproduction and a note about the thread count. The GitHub issue and the Zulip channel are both listed in the announcement. "It felt slower" is less useful than a command, a revision, and a comparison.

Memory is the other ceiling

Parallelism is not free. Each frontend thread needs its own working state, and the compiler already holds a large amount of metadata, spans, and query results. The announcement warns that higher thread counts will likely increase memory use and, in extreme cases, run out of memory. That is why the default is two threads and why the team says scaling above roughly eight threads is not expected to work well.

On a laptop with 16 GB of RAM, two threads are unlikely to be the difference between a successful build and an OOM kill. On a CI runner with many parallel jobs, the interaction matters more. If Cargo is already running eight crate builds and each one starts two frontend threads, the runner may be oversubscribed. The right configuration depends on the whole build, not just the compiler flag.

This is also a place where the "faster compiler" story can invert. A build that finishes in less CPU time but spends more time waiting on memory pressure, swap, or the scheduler is not faster for the person waiting. The only way to know is to measure wall time and peak memory together.

How to try it without wrecking CI

The safest way to test the parallel frontend is to keep it out of the default CI path until you have a baseline. Run a nightly job with --jobs-frontend=1 and a second job with --jobs-frontend=2 or 4, using the same commit and the same runner class. Compare wall time, peak RSS, and the compiler output. If the parallel job is faster and the output is stable, expand the test.

For local experiments, put the flag in a separate Cargo config or pass it through RUSTFLAGS for one command. Do not bake an unstable flag into a project-wide config that stable users also read. -Zunstable-options only works on nightly, and a config file that assumes nightly will break stable builds in confusing ways.

If you maintain a tool that parses rustc diagnostics, add a test that runs the compiler with two frontend threads and checks that your parser still handles the output. The diagnostic text should be the same; the order may not be. If your tool assumes a fixed order, that assumption is now a bug.

What stabilization still needs

The announcement lists several pieces of work that are not finished. Macro expansion and name resolution are still being parallelized. AST-to-HIR lowering has an open pull request. Some frontend phases remain sequential. The team also wants to improve the performance of the parts that are already parallel; much of the recent work was about correctness, not tuning.

Stabilization will require more than "no one reported a crash in a week." It will require confidence that the compiler behaves consistently across platforms, that diagnostics remain usable, that incremental builds do not regress, and that reproducible builds are not silently broken. The nightly trial is how the team collects that evidence.

For now, the correct description is narrow: nightly Rust can type-check and borrow-check with two frontend threads by default. Some single-crate checks get much faster. Whole workspaces get a smaller, workload-dependent gain. The compiler may emit diagnostics in a different order, and some binaries may not be reproducible. Those are the trade-offs to test, not footnotes to skip.

If you use nightly, try it on a branch, measure the build you actually run, and report what breaks. That is more valuable to the compiler team than another benchmark of a synthetic crate. The parallel frontend will become stable when the messy cases are understood, and the messy cases live in real workspaces.

Sources


← back to posts