Rust Compiles Faster NOW!

preview_player
Показать описание
Recorded live on twitch, GET IN

By: Nicholas Nethercote

MY MAIN YT CHANNEL: Has well edited engineering videos

Discord

Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
Рекомендации по теме
Комментарии
Автор

I've implemented a topological sort with groups in my job, but I didn't know that's what it's called.
It really improved event processing speed. As a reward, I got a pat on the back.

pacifico
Автор

1:39 Looking at the performance numbers that they linked, the performance suite is a large collection of crates compiled under different compiler flags. I would expect that these crates in particular were chosen to try and be as representative a selection of crates that are actively used in real rust code as possible, but its only a subset of all crates in order to make running against the test suite a tractable problem, since individual rust devs cant just iteratively test against the entirety of crates every time they want to test a change.

darkspells
Автор

for clean builds with lots of crates, using "more threads per crate" (mostly) doesn't help.
the cpu is already saturated because independent crates are compiled in parallel.
in fact, adding more threads actually makes compiles slower, as there are now way more threads than cpu cores, so there's more context switching and cache pressure.

however, with larger binary crates, compiling the binary crate itself often takes a long time. and that of course can't be overlapped with compiling its dependencies. in those cases, the multi-threaded front end does help. (and it should also help for incremental compilation.)

for my own project, which has barely any dependencies, clean compile times went from 1.78 s to 1.25 s with the multi-threaded front-end.

leddoo
Автор

My pc never felt this much of potato before. Compiling rust absolutely paralyzed it

vimdiesel
Автор

Borrow checking is actually a very cheap and quick part of the compilation. Compare cargo check and cargo build on something big. BC can also be massively parallelized, as functions signatures function as a boundary.

Demiuuu
Автор

More parallellellisms will be added until compile times improve.

Kane
Автор

the blog post is from november 9th and the nightly version is from november 8th holy cow that could be it LOL

viniciusataidedealbuquerqu
Автор

Have you tried mold for linking? There has been an article recently about using -O1, mold/sold and cranelift to improve compile time performance

CielMC
Автор

Just compiling is relatively fast. Enable fat LTO to see the true madness.

mkvoq
Автор

not an expert here but don't you have to set the default toolchain? or at least specify which one you'd like to use?

ruvasqm
Автор

Okay crustaceans. Crates??? Why not libraries???? Cargo??? Why not a normal Command? Also, what’s with the ::s all over functions? And why use the keyword let? Let is such a weird keyword, why adopt that from JS? Finally, yes I just started looking into rust 😂

Warpgatez
Автор

To speed up linking you should just use mold (the linker)

nextlifeonearth
Автор

Was anyone surprised that adding more threads slowed down the process.... I laughed so hard it was true....

eduardflorea
Автор

I'm pretty sure their performance suites here are their site that does compiles of major crates every day.

thekwoka
Автор

"It seems like serde should have been up here", *hovers over serde*

ollierkul
Автор

It didn't work because you never used the nightly toolchain, e.g. `cargo +nightly ...`

Xetrill
Автор

The lack of cargo +nightly in the chat is painful

darklajid
Автор

Thats cool! Although generally only the first compile is a bit of a wait. But parallel compile is always good.

CallousCoder
Автор

`rustup default nightly`. I think that was it, its still using the stable build.

debarchito
Автор

As far as I understand it this may be more impactful when doing incremental compiles rather than a clean build on a project with many dependencies. Rust already parallelized multiple crates. So as long as all your CPU cores are saturated there shouldn't be a benefit.
One thing that can improve compile times significantly is using a faster linker. Rust usually statically links everything, so this has a big impact.

ymi_yugy