Skip to content

Commit a45d6ef

Browse files
committed
Auto merge of rust-lang#2352 - saethlin:new-benchmark, r=RalfJung
Add a benchmark of the hang-on-test-failure code path This is the code pattern that produces the performance problem in rust-lang/miri#2273 I figured out what I was stuck on in rust-lang/miri#2315 (comment). For a while I was just doing `let x: &[u8] = &[0u8; 4096];` but that doesn't produce the runtime inside `Stack::item_popped` that I was looking for, I think because this allocation is never deallocated. But with `Vec`, I get the profile I'm looking for.
2 parents db5a2b9 + 7d9f04f commit a45d6ef

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

bench-cargo-miri/slice-get-unchecked/Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "slice-get-unchecked"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//! This is a stripped-down version of the code pattern that causes runtime blowup when printing
2+
//! backtraces in a failed test under cargo miri test with -Zmiri-disable-isolation.
3+
//! See https://github.com/rust-lang/miri/issues/2273
4+
5+
fn main() {
6+
let x = vec![0u8; 4096];
7+
let mut i = 0;
8+
while i < x.len() {
9+
let _element = unsafe { *x.get_unchecked(i) };
10+
i += 1;
11+
}
12+
}

0 commit comments

Comments
 (0)