Skip to content

Commit ec5327d

Browse files
committed
Auto merge of rust-lang#3638 - saethlin:big-alloc-bench, r=RalfJung
Add a benchmark for creating large uninit allocations Extracted from rust-lang/miri#3637 I used this program to confirm that rust-lang#125633 has the desired effect.
2 parents 9d162eb + 483485e commit ec5327d

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "big-allocs"
7+
version = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "big-allocs"
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,13 @@
1+
//! This is a regression test for https://github.com/rust-lang/miri/issues/3637.
2+
//! `Allocation`s are backed by a `Box<[u8]>`, which we create using `alloc_zeroed`, which should
3+
//! make very large allocations cheap. But then we also need to not clone those `Allocation`s, or
4+
//! we end up slow anyway.
5+
6+
fn main() {
7+
// We can't use too big of an allocation or this code will encounter an allocation failure in
8+
// CI. Since the allocation can't be huge, we need to do a few iterations so that the effect
9+
// we're trying to measure is clearly visible above the interpreter's startup time.
10+
for _ in 0..10 {
11+
drop(Vec::<u8>::with_capacity(512 * 1024 * 1024));
12+
}
13+
}

0 commit comments

Comments
 (0)