Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions collector/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ programs.
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
the past.
- **ctfe-stress-2**: A stress test for compile-time function evaluation.
- **ctfe-stress-uninit**: A stress test for representation of values with
uninitialized bytes in compile-time function evaluation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it or merge the two comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no uninit benchmark anymore, I would expect a single entry with -3.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just dropping the uninit bit; that can be moved to a comment in the file.

- **deeply-nested**: A small program that caused [exponential
behavior](https://github.com/rust-lang/rust/issues/38528) in the past.
- **deep-vector**: A test containing a single large vector of zeroes, which
Expand Down
4 changes: 0 additions & 4 deletions collector/benchmarks/ctfe-stress-2/Cargo.lock

This file was deleted.

6 changes: 6 additions & 0 deletions collector/benchmarks/ctfe-stress-3/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
name = "ctfe-stress-2"
name = "ctfe-stress-3"
version = "0.1.0"
authors = ["Ralf Jung <[email protected]>"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(const_fn, const_let)]
use std::mem::MaybeUninit;

// Try to make CTFE actually do a lot of computation, without producing a big result.
// And without support for loops.
Expand Down Expand Up @@ -65,3 +66,32 @@ expensive_static!(UNSIZE_TRAIT: &'static Trait = &42u32; [4 16 16 16 16 16]);
// prone to regressions.
// 24 is an exponent that makes the repeat expression take less than two seconds to compute
const FOO: [i32; 1 << 24] = [0; 1 << 24];

// Try CTFE that operate on values that contain largely uninitialized memory, not requiring any
// particular representation in MIR.
type LargeUninit = MaybeUninit<[u8; 1 << 23]>;

// copying uninitialized bytes could also be expensive and could be optimized independently, so
// track regressions here separately. It should also be less costly to compose new values
// containing largly undef bytes.
const BAR: LargeUninit = MaybeUninit::uninit();

// Check the evaluation time of passing through a function.
const fn id<T>(val: T) -> T { val }
const ID: LargeUninit = id(MaybeUninit::uninit());

const fn build() -> LargeUninit { MaybeUninit::uninit() }
const BUILD: LargeUninit = build();

// Largely uninitialized memory but initialized with tag at the start, in both cases.
const NONE: Option<LargeUninit> = None;
const SOME: Option<LargeUninit> = Some(MaybeUninit::uninit());

// A large uninit surrounded by initialized bytes whose representation is surely computed.
const SURROUND: (u8, LargeUninit, u8) = (0, MaybeUninit::uninit(), 0);
const SURROUND_ID: (u8, LargeUninit, u8) = id((0, MaybeUninit::uninit(), 0));

// Check actual codegen for these values.
pub static STATIC_BAR: LargeUninit = MaybeUninit::uninit();
pub static STATIC_NONE: Option<LargeUninit> = None;
pub static STATIC_SOME: Option<LargeUninit> = Some(MaybeUninit::uninit());