When trying to write an optimized DSP algorithm, I was interested to know the relative speed between the stack distribution and the heap distribution and the size limitations of the arrays distributed over the stacks. I understand that there is a restriction on the size of the stack frames, but I don’t understand why the following runs, generating apparently realistic test results with cargo bench, but with an error when starting with cargo test --release.
cargo bench
cargo test --release
#![feature(test)] extern crate test; #[cfg(test)] mod tests { use test::Bencher; #[bench] fn it_works(b: &mut Bencher) { b.iter(|| { let stack = [[[0.0; 2]; 512]; 512]; }); } }
, , 8 × 2 × 512 × 512 = 4 .
cargo test, cargo bench , "" it_works() , "" .
cargo test
it_works()
8 MiB, . , , .
, , . Linux 2 MiB, . , 4 MiB /segfault.
RUST_MIN_STACK.
RUST_MIN_STACK
$ RUST_MIN_STACK=8388608 cargo test
cargo test , , .
- , . (box it), static mut.
box
static mut
Source: https://habr.com/ru/post/1015938/More articles:How to scroll a browser page - Laravel Dusk (Browser tests) - phpboost :: filesystem :: path :: lexically_normal: is this the wrong behavior? - c ++the go version command shows the old version number after upgrading to 1.8 - goNew Eclipse gluon project doesn't end - javahow to get ipaddress virtual box running on local machine - virtualboxПочему в работе JavaScript на веб-узлах и узлах есть разные результаты? - javascriptAngular 2 Injected Service undefined - dependency-injectionangular 2 - Introduced service in HTTP error handler - angularThe boundaries of transactions and DTO with JPA - javaCrashlytics WriteZStream stacktrace - iosAll Articles