5 ms·
`cargo build -j11` will limit parallelism to eleven cores. Cargo and rustc use the Make jobserver protocol [0][1][2] to coordinate their use of threads and pro
by mbrubeck 4y ago
`cargo build -j11` will limit parallelism to eleven cores. Cargo and rustc use the Make jobserver protocol [0][1][2] to coordinate their use of threads and processes, even when multiple rustc processes are running (as long as they are part of the same `cargo` or `make` invocation):
[0]: https://www.gnu.org/software/make/manual/html_node/Job-Slots.html https://www.gnu.org/software/make/manual/html_node/Job-Slots...
[2]: https://github.com/rust-lang/cargo/issues/1744 https://github.com/rust-lang/cargo/issues/1744
[2]: https://github.com/rust-lang/rust/pull/42682 https://github.com/rust-lang/rust/pull/42682
`nice cargo build` will run all threads at low priority, but this is generally a good idea if you want to prioritize interactive processes while running a build in the background.
- epage 4y agoTo add, in rust 1.63, cargo added support for negative numbers, so you can say `cargo build --jobs -2` to leave two cores available. See https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-164-2022-09-22 https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#...
- touisteur 4y agoSmall quality of life changes like this really make the cargo and rust community shine, I feel. I'm not a heavy rust user but following all the little improvements in warnings, hints, they build up to a great experience. I wish we had the mindshare and peoplepower to do that in my language and tooling of choice (I'm specifically talking about effort and muscle, because motivation is clearly already there).