-
Notifications
You must be signed in to change notification settings - Fork 154
Add a stress test for uninit representations #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
550e6f6
04066ae
7e4500c
2996458
1656ec7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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-uninit-stress**: A stress test for representation of values with | ||
uninitialized bytes in compile-time function evaluation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove it or merge the two comments? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
name = "ctfe-uninit-stress" | ||
version = "0.1.0" | ||
authors = ["Andreas Molzer <andreas.molzer@gmx.de>"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![feature(const_fn, const_let)] | ||
197g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Try CTFE that operate on values that contain largely uninitialized memory, not requiring any | ||
// particular representation in MIR. | ||
|
||
use core::mem::MaybeUninit; | ||
type LargeUninit = MaybeUninit<[u8; 1 << 24]>; | ||
|
||
// 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()); |
Uh oh!
There was an error while loading. Please reload this page.