Skip to content

Commit 8a40e2e

Browse files
committed
Add more bench-cargo-miri programs
These example programs are derived from long-running (>15 minutes) tests in the test suites of highly-downloaded crates. They should serve as realistic but also somewhat pathological workloads for the interpreter. The unicode program stresses the code which looks for adjacent and equal stacks to merge them. The backtrace program has an uncommonly large working set of borrow tags per borrow stack. This also updates the .gitignore to ignore files commonly emitted in the course of using these benchmark programs.
1 parent 4d6eca1 commit 8a40e2e

File tree

9 files changed

+277
-0
lines changed

9 files changed

+277
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ tex/*/out
44
*.dot
55
*.rs.bk
66
.vscode
7+
*.mm_profdata
8+
perf.data
9+
perf.data.old
10+
flamegraph.svg

bench-cargo-miri/backtraces/Cargo.lock

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "backtraces"
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]
9+
backtrace = "0.3.65"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//! Extracted from the backtrace crate's test test_frame_conversion
2+
3+
use backtrace::{Backtrace, BacktraceFrame};
4+
use std::fmt::Write;
5+
6+
fn main() {
7+
let mut frames = vec![];
8+
backtrace::trace(|frame| {
9+
let converted = BacktraceFrame::from(frame.clone());
10+
frames.push(converted);
11+
true
12+
});
13+
14+
let mut manual = Backtrace::from(frames);
15+
manual.resolve();
16+
let frames = manual.frames();
17+
18+
let mut output = String::new();
19+
for frame in frames {
20+
// Originally these were println! but we'd prefer our benchmarks to not emit a lot of
21+
// output to stdout/stderr. Unfortunately writeln! to a String is faster, but we still
22+
// manage to exercise interesting code paths in Miri.
23+
writeln!(output, "{:?}", frame.ip()).unwrap();
24+
writeln!(output, "{:?}", frame.symbol_address()).unwrap();
25+
writeln!(output, "{:?}", frame.module_base_address()).unwrap();
26+
writeln!(output, "{:?}", frame.symbols()).unwrap();
27+
}
28+
drop(output);
29+
}

bench-cargo-miri/mse/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench-cargo-miri/serde1/Cargo.lock

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench-cargo-miri/unicode/Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench-cargo-miri/unicode/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "unicode"
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]
9+
unicode-xid = "0.2.3"

bench-cargo-miri/unicode/src/main.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! Extracted from the unicode-xid exhaustive test all_valid_chars_do_not_panic_for_is_xid_continue
2+
3+
use unicode_xid::UnicodeXID;
4+
5+
/// A `char` in Rust is a Unicode Scalar Value
6+
///
7+
/// See: http://www.unicode.org/glossary/#unicode_scalar_value
8+
fn all_valid_chars() -> impl Iterator<Item = char> {
9+
(0u32..=0xD7FF).chain(0xE000u32..=0x10FFFF).map(|u| {
10+
core::convert::TryFrom::try_from(u)
11+
.expect("The selected range should be infallible if the docs match impl")
12+
})
13+
}
14+
15+
fn main() {
16+
// Take only the first few chars because we don't want to wait all day
17+
for c in all_valid_chars().take(2_000) {
18+
let _ = UnicodeXID::is_xid_continue(c);
19+
}
20+
}

0 commit comments

Comments
 (0)