Remix.run Logo
▲ jadbox 7 hours ago

Is the compiler any faster now? Compiling takes forever. I'm also tired of always having to do "cargo clean" everyday to clear out 90gb of temp files.

▲epage 6 hours ago | parent | next [-]

Faster compile and smaller build-dir can be at odds with each other.

That said, this release includes some incremental improvements as well as the unused-dependency lint to help reduce wasted work within the ecosystem.

Some changes that have been or are about to be merged for upcoming releases

- We will be reducing the debug info generated for the `dev` profile which reduces build-dir size and speeds up builds. We've split off a `debug` profile for when that is needed.

- Cargo will be deleting the directory rustc writes before each invocation, avoiding the leaking of debug files when split-debug is enabled (default on Mac)

- rlibs for workspace members will no longer be copied from build-dir to target-dir which takes up extra space on systems without hardlinking or where we skip it (like Mac)

- redundant information in rlibs and rmeta's is going to be de-duplicated

Examples of further out changes

- This release includes the foundational work to add a build-dir GC

- Cross-workspace de-duplicating of build-dirs

- Cross-workspace build-dir cache

- Early cut off

▲iknowstuff 6 hours ago | parent | next [-]

Also

“Relink, don't rebuild” #790

https://github.com/rust-lang/compiler-team/issues/790

▲epage 2 hours ago | parent | next [-]

Note that this is a special form of early cut off (which was listed) where you are hashing a more specialized output file, rather than a broader one.

▲mohamedkoubaa 5 hours ago | parent | prev [-]

Ive always wondered why this wasn't an option from the beginning

▲epage 2 hours ago | parent [-]

To do it right you need

- stable id's even when the source changes

- a separate output file dedicated to it so you hash that

Those aren't free, taking extra work to implement and possibly slow down the compiler

▲pjmlp 5 hours ago | parent | prev [-]

Thanks for the list, looking forward to those improvements.

▲steveklabnik 7 hours ago | parent | prev | next [-]

Compiler speed is continually being worked on https://nnethercote.github.io/2026/11/04/how-to-speed-up-the...

And the large target directories is also being worked on as well.

▲the8472 26 minutes ago | parent | prev | next [-]

Yes, lots of optimization work has it made faster despite gaining new features.

https://perf.rust-lang.org/dashboard.html

▲small_model 6 hours ago | parent | prev | next [-]

Yes this is why I switched to Go for backend, much faster compiling and performance isn't an issue for the application yes using 100GB+ is just bad tooling.

▲barchar 4 hours ago | parent | prev | next [-]

try disabling at least some debug-info for your dependencies.

use cargo's --timings option to identify the slow crates, then use measureme to figure where rustc is spending time.

try fiddling with detached debug-info, dwp files can be smaller than their constituent dwo files.

ensure really small "template wrappers" are inlined.

lower the number of compilation-units you use.

For incremental builds I have found it can _sometimes_ be effective to split out larger dependencies into a dynlib. You create a dylib crate that re-exports said dependencies and your executable depends on that. Ofc things like generics from the offending libraries will still end up in your executables; Though I think there is a way to mitigate this a little.

This mostly helps with link-time, and saving space if you have a bunch of executables (using the argv[0] trick will help more, though).

▲vlovich123 7 hours ago | parent | prev | next [-]

Any faster vs what baseline? They’ve constantly made improvements and Rust today is pretty darn quick, especially for incremental. There’s work to parallelize the front end which will help a little bit and you can always use the cranelift backend for debugging which is substantially faster than LLVM.

They’re also doing work to reduce the amount of disk space usage (by clearing out unused articacts) and make it easier to maintain.

▲jtwaleson 6 hours ago | parent [-]

Best to do some benchmarks for cranelift on your codebases and system. It used to be quite a lot faster, but for me the advantage has disappeared over the last year of Rust improvements.

▲kennykartman 5 hours ago | parent | prev | next [-]

You might be interested in this: https://news.ycombinator.com/item?id=50458849 - I didn't try it yet, though.

▲amelius 6 hours ago | parent | prev | next [-]

There's really a paradox here. Rust claims to be a fast language, but compiling, even without optimizations on, takes ages ...

▲barchar 4 hours ago | parent | next [-]

Rust encourages a kind of generic programming that can result in generating too much code.

The compilation model is vastly, vastly, vastly better than languages like C++ and C, though, and it does compile much faster than an equivalent C++ build (doesn't count if you download precompiled binaries of your c++ dependencies)

▲cozzyd 2 hours ago | parent [-]

But the lack of ABI stability means that's not a choice anyway, doesn't it?

▲SAI_Peregrinus an hour ago | parent [-]

Rust can compile to dynamic libraries. If you don't use the C abi you have to compile anything that loads them with the same Rust compiler version and target triple. So you need to have some way to guarantee the correct compiler is being used, e.g. Nix or Bazel.

▲IshKebab 4 hours ago | parent | prev | next [-]

That's not a paradox, that's how it always works. Compiling to fast machine code requires more work and takes longer.

Is Python a fast language because it barely takes any time to compile the code? No obviously not.

▲Matrixik 3 hours ago | parent | next [-]

Looks like people extending rust never really focused on compile speed when designing features (from [1]):

> If you could reinvent/change any aspect of Rust, what would you do alternatively?

> A lot happened because we wanted to ship a useful thing with only so much time in the day, so some things were less deliberate than others. There’s an alternate version of Rust with significantly faster compiler times, because while we cared about compile times when designing we always prioritized other values more. We never asked ourselves how this feature or implementation impacted compiler analysis time and there are several spots where something slightly different would have much faster compiler times, which people do care about. But had we spent time on that, we would have neglected other things and not been any more successful.

[1]: https://alexalejandre.com/interviews/interview-with-steve-kl...

▲amelius 4 hours ago | parent | prev [-]

You missed "without optimizations on".

This is important, because most often during development you want fast compilation times more than you want fast code.

▲afdbcreid 4 hours ago | parent [-]

That still isn't a paradox. Furthermore it still makes sense: a language designed to generate the fastest code has constructs that cannot be compiled quickly, even without optimizations.

But some of it is implementation problems.

▲adastra22 5 minutes ago | parent [-]

Rust's compilation speed issues are not due to optimizations. There is some intrinsic slowness, but also some boneheaded decisions that are now baked in. E.g. the unit of compilation being the crate, not file/module, makes it so you hit some bad scaling laws. And the borrow checker is SLOW, and unavoidably so, but borrow checking could have been avoided with different lifetime rules. Etc.

I say this as a full-time rust developer btw.

▲kibwen 5 hours ago | parent | prev [-]

There's no paradox here. You can use any benchmark you like to prove that Rust is a fast language. The work that the compiler does is irrespective of the language that rustc is written in.

▲amelius 5 hours ago | parent [-]

Yes, the benchmark is compiler compiling itself. From scratch and incrementally.

▲kibwen 4 hours ago | parent [-]

Unfortunately, that isn't how any of this works.

▲eptcyka 6 hours ago | parent | prev | next [-]

On macOS there is a known bug where some temp files are always created anew, not reused, which slows down compilation and wastes more space than other platforms.

▲adastra22 11 minutes ago | parent | next [-]

Do you have details? I think I'm running into this.

▲epage 5 hours ago | parent | prev [-]

Fixed on nightly.

▲0o777 6 hours ago | parent | prev | next [-]

All the big AI companies use Rust so this is probably something they should focus on improving.

▲panstromek 6 hours ago | parent [-]

They do fund some of these efforts, yes.

▲flykespice an hour ago | parent | prev | next [-]

What the hell are you doing to produce 90gb of temp files? Is that normal on rust land?

▲adastra22 11 minutes ago | parent | next [-]

It's large but not insane. I've got 20gb in a not-too-large repo.

▲kstrauser 17 minutes ago | parent | prev [-]

No. My target directory is 329GB at the moment. I wish mine were just 90GB.

(And yet I’m perfectly happy running `cargo clean` periodically in exchange for all the Rust loveliness. Sure, I wish I didn’t need to. Sure, I hope it’ll get better. I can live with the temporary inconvenience though.

Also, I’m developing in a tight auto-build-on-commit loop so I have a gazillion builds.)

▲benjiro29 4 hours ago | parent | prev | next [-]

Is the compiler any faster now?

If your codebase is not some small project, its excruciating slow. Even if you try different linkers, and other compilers, nothing really make incremental compiles eat so much of your system. Even more so if you have multiple AI agents doing security and other checks.

Switched to Go for several months, and the difference was very noticeable. Until you started to get there also 50k+ files that are interlinked. And let us not talk about Go and Rust their issues with insane amount of debug/cache buildup.

Imaging if you have 4 to 6 agents running that, with each seeing the cache grow from 20, 30, 40 ... To the point that a 100/1000GB SSD grows to 800, 900GB usage. Often in barely a day.

Seen my NVME drive its lifespan drop from 98% to 91% in barely a few month time. I dread looking at it again lol

What was the solution? Going back to C ... Despite right now working on a 800k lines project, it compiles way faster the Go, and well, Rust will have pegged all 16 cores for a minute, for EACH agent trying to recompile on a small change.

Memory safety? Instead of checking at compile time, and wasting my time, this has simply been moved to AI agents checking, making tools, checking, at night. So it does not disturb my own work.

Its ironic, how both modern projects, end up being worse off. Best of all, the C project is way faster then the same project in Go and Rust. Yea, it was "fun" having AI transcompile them twice but the difference on actual large codebase, and not some micro benchmarks is not a joke. To the point that now all my projects have gone back to C...

And yea, i expect some fast downvotes by our Rust friends because saying something negative about Rust always gets people downvoted here. No offence but Rust being linked to LLM and the whole checker was a benefit before AI came around. But now you can offload a lot of safety checks to the backend/offhours, instead of paying for it with every compile.

▲shevy-java 5 hours ago | parent | prev | next [-]

Well, the AI that slops out Rust code won't mind having to wait!

▲throwaway27448 6 hours ago | parent | prev [-]

I don't understand why people complain about this non-stop. If compilation time is such an issue use a different language. I can't say I've been bottlenecked by compilation in a very long time.

▲IshKebab 4 hours ago | parent [-]

I don't think you can tell people not to complain about it - it is clearly very desirable to have faster compilation, like Zig or Go.

But that said I do agree it is pretty fast these days. Significantly faster than C++ and people have tolerated that for decades.

▲throwaway27448 2 hours ago | parent [-]

I didn't tell anyone to do anything. I just don't get why people complain—it's like they don't grasp the concept of tradeoffs.