Open kigawas opened 3 years ago
I don't think this is directly related to benchmarks, but due to const-eval using large amounts of memory due to these lines: https://github.com/ecies/rs/blob/9d893d19b7343aaecd30891f595b2601523dbcbd/bench/simple.rs#L6-L10
I think there are several other issues already open about similar issues, such as #79601, but I'm uncertain of the underlying cause (I'm not familiar with how const-eval works).
This program:
const BIGGER_MSG_SIZE: usize = 200 * 1024 * 1024;
const BIGGER_MSG: [u8; BIGGER_MSG_SIZE] = [2u8; BIGGER_MSG_SIZE];
fn main() {
println!("{:?}", BIGGER_MSG[12]);
}
takes 30 seconds to build, and used over a gigabyte of memory.
I don't think this is directly related to benchmarks, but due to const-eval using large amounts of memory due to these lines: https://github.com/ecies/rs/blob/9d893d19b7343aaecd30891f595b2601523dbcbd/bench/simple.rs#L6-L10
I think there are several other issues already open about similar issues, such as #79601, but I'm uncertain of the underlying cause (I'm not familiar with how const-eval works).
This program:
const BIGGER_MSG_SIZE: usize = 200 * 1024 * 1024; const BIGGER_MSG: [u8; BIGGER_MSG_SIZE] = [2u8; BIGGER_MSG_SIZE]; fn main() { println!("{:?}", BIGGER_MSG[12]); }
takes 30 seconds to build, and used over a gigabyte of memory.
Well, the array is exactly 200 megabytes, it'd be so hard to perceive that it could use gigabytes :(
Interestingly, this only occurs at cargo bench
's building phase inside WSL2 (which means Windows itself is okay).
@camelid this is unrelated to libtest or benchmarking, it's about compile times.
@kigawas can you confirm whether you have the same issue with cargo bench --no-run
?
I'll update the result about 8 hours later
====update==== @jyn514
--no-run
did not help.
This issue supersedes https://github.com/rust-lang/cargo/issues/8961
TL;DR
This can be worked around by setting
CARGO_BUILD_JOBS
.Description
Briefly,
cargo bench
eats excessive memory on WSL2 with a 10-core 20-thread i9-10900K Intel CPU and 32GB memory, due to:rustc
processes and each process would take more than 2GB memory.rustc
s get killed.Other information
cargo build
orcargo test
, with or without--release
.Steps
git clone https://github.com/ecies/rs.git eciesrs && cd eciesrs
in WSL2 ubuntu shell.cargo bench --no-default-features --features pure
Possible Solution(s)
Set
CARGO_BUILD_JOBS
to a lower value.Notes
Output of
cargo version
:Possibly related issues