Skip to content

Latest commit

 

History

History

01_Faster_Compilation_Rust


멀티 쓰레드 숫자가 8이상은 되어야 효과가 있는듯 싶다.

How to use it(Nightly 231109 기준)

https://doc.rust-lang.org/beta/cargo/reference/registry-authentication.html

https://blog.rust-lang.org/2023/11/09/parallel-rustc.html

The nightly compiler is now shipping with the parallel front-end enabled. However, by default it runs in single-threaded mode and won't reduce compile times.

Keen users can opt into multi-threaded mode with the -Z threads option. For example:

$ RUSTFLAGS="-Z threads=8" cargo build --release

Alternatively, to opt in from a config.toml file (for one or more projects), add these lines:

  • 경로 맞는지는 테스트 해봐야함
  • ~/.cargo/config.toml
[build]
rustflags = ["-Z", "threads=8"]

Available Parallelism : Cpu 갯수 체크하기

fn main() {
    println!(
        "You can use {:?} threads(available_parallelism) now.  ",
        std::thread::available_parallelism().unwrap()
    );
}

SysInfo

https://docs.rs/sysinfo/latest/sysinfo/

echo 로 빠르게 넣기

rm -rf .cargo rust-toolchain.toml &&
mkdir .cargo &&
echo "[toolchain]" >> rust-toolchain.toml &&
echo "channel ="\"nightly"\"" >> rust-toolchain.toml &&
echo "components = ["\"rustfmt\"", "\"rust-src"\"]" >> rust-toolchain.toml &&

echo "[build]" >> .cargo/config.toml &&
echo "rustflags = ["\"-Z\"", "\"threads=8"\"]" >> .cargo/config.toml