Skip to content

Commit 32a7580

Browse files
committedJun 9, 2022
Auto merge of #2219 - saethlin:more-benchmarks, r=RalfJung
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 (if I have my way, that runtime will not be correct for long). 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 backtraces 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. --- The benchmark programs are so-named to avoid confusingly duplicating the names of the crates they are benchmarking. Is that a good idea? I started doing this so that I could use `cargo add` but now I'm not entirely sold on the names.
2 parents 4d6eca1 + 8a40e2e commit 32a7580

File tree

9 files changed

+277
-0
lines changed

9 files changed

+277
-0
lines changed
 

‎.gitignore

+4
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

+94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+9
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"
+29
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

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bench-cargo-miri/serde1/Cargo.lock

+89
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bench-cargo-miri/unicode/Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bench-cargo-miri/unicode/Cargo.toml

+9
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

+20
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)
Please sign in to comment.