about summary refs log tree commit diff
path: root/src/tools/miri
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-29 17:49:40 +0000
committerbors <bors@rust-lang.org>2024-05-29 17:49:40 +0000
commitec5327d0b77a1248a2c9b8c7c76ae70a867b39fe (patch)
tree35e05e5c5b83fa76dd9eb7e83d72b7f59daf8407 /src/tools/miri
parent9d162eb3fe96c4267630ec1ee5c16028e3b717ea (diff)
parent483485e19eb792e822f3388c6cf58785ab726cfa (diff)
downloadrust-ec5327d0b77a1248a2c9b8c7c76ae70a867b39fe.tar.gz
rust-ec5327d0b77a1248a2c9b8c7c76ae70a867b39fe.zip
Auto merge of #3638 - saethlin:big-alloc-bench, r=RalfJung
Add a benchmark for creating large uninit allocations

Extracted from https://github.com/rust-lang/miri/issues/3637

I used this program to confirm that https://github.com/rust-lang/rust/pull/125633 has the desired effect.
Diffstat (limited to 'src/tools/miri')
-rw-r--r--src/tools/miri/bench-cargo-miri/big-allocs/Cargo.lock7
-rw-r--r--src/tools/miri/bench-cargo-miri/big-allocs/Cargo.toml8
-rw-r--r--src/tools/miri/bench-cargo-miri/big-allocs/src/main.rs13
3 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/miri/bench-cargo-miri/big-allocs/Cargo.lock b/src/tools/miri/bench-cargo-miri/big-allocs/Cargo.lock
new file mode 100644
index 00000000000..da0db7f47ea
--- /dev/null
+++ b/src/tools/miri/bench-cargo-miri/big-allocs/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "big-allocs"
+version = "0.1.0"
diff --git a/src/tools/miri/bench-cargo-miri/big-allocs/Cargo.toml b/src/tools/miri/bench-cargo-miri/big-allocs/Cargo.toml
new file mode 100644
index 00000000000..7234c9371cf
--- /dev/null
+++ b/src/tools/miri/bench-cargo-miri/big-allocs/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "big-allocs"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/src/tools/miri/bench-cargo-miri/big-allocs/src/main.rs b/src/tools/miri/bench-cargo-miri/big-allocs/src/main.rs
new file mode 100644
index 00000000000..a1c1708cf3b
--- /dev/null
+++ b/src/tools/miri/bench-cargo-miri/big-allocs/src/main.rs
@@ -0,0 +1,13 @@
+//! This is a regression test for https://github.com/rust-lang/miri/issues/3637.
+//! `Allocation`s are backed by a `Box<[u8]>`, which we create using `alloc_zeroed`, which should
+//! make very large allocations cheap. But then we also need to not clone those `Allocation`s, or
+//! we end up slow anyway.
+
+fn main() {
+    // We can't use too big of an allocation or this code will encounter an allocation failure in
+    // CI. Since the allocation can't be huge, we need to do a few iterations so that the effect
+    // we're trying to measure is clearly visible above the interpreter's startup time.
+    for _ in 0..10 {
+        drop(Vec::<u8>::with_capacity(512 * 1024 * 1024));
+    }
+}