From 5ef7e0cf06c82ed7781d2888ebcfa3dbe3480fe6 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 12 Nov 2019 13:07:19 +0000 Subject: [PATCH] Migrate ctfe-stress-test-3 to ctfe-stress-test-4 If rust PR #66294 lands then evaluation of `const fn` with no arguments will be memoized. This breaks the purpose of the tests in ctfe-stress-3, so this PR changes to a new ctfe-stress-test-4 which is identical save that the const functions now take a dummy u32 argument to avoid memoization. --- collector/benchmarks/README.md | 3 +-- .../Cargo.lock | 0 .../Cargo.toml | 2 +- .../src/lib.rs | 26 ++++++++++--------- 4 files changed, 16 insertions(+), 15 deletions(-) rename collector/benchmarks/{ctfe-stress-3 => ctfe-stress-4}/Cargo.lock (100%) rename collector/benchmarks/{ctfe-stress-3 => ctfe-stress-4}/Cargo.toml (74%) rename collector/benchmarks/{ctfe-stress-3 => ctfe-stress-4}/src/lib.rs (84%) diff --git a/collector/benchmarks/README.md b/collector/benchmarks/README.md index 025798446..26767764e 100644 --- a/collector/benchmarks/README.md +++ b/collector/benchmarks/README.md @@ -71,7 +71,7 @@ programs. - **coercions**: Contains a static array with 65,536 string literals, which caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in the past. -- **ctfe-stress-3**: A stress test for compile-time function evaluation. +- **ctfe-stress-4**: A stress test for compile-time function evaluation. - **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 @@ -94,4 +94,3 @@ programs. behavior](https://github.com/rust-lang/rust/pull/32062) in the past. - **unused-warnings**: Contains many unused imports, which caused [quadratic behavior](https://github.com/rust-lang/rust/issues/43572) in the past. - diff --git a/collector/benchmarks/ctfe-stress-3/Cargo.lock b/collector/benchmarks/ctfe-stress-4/Cargo.lock similarity index 100% rename from collector/benchmarks/ctfe-stress-3/Cargo.lock rename to collector/benchmarks/ctfe-stress-4/Cargo.lock diff --git a/collector/benchmarks/ctfe-stress-3/Cargo.toml b/collector/benchmarks/ctfe-stress-4/Cargo.toml similarity index 74% rename from collector/benchmarks/ctfe-stress-3/Cargo.toml rename to collector/benchmarks/ctfe-stress-4/Cargo.toml index 1ae40745d..e2c89a838 100644 --- a/collector/benchmarks/ctfe-stress-3/Cargo.toml +++ b/collector/benchmarks/ctfe-stress-4/Cargo.toml @@ -1,4 +1,4 @@ [package] -name = "ctfe-stress-3" +name = "ctfe-stress-4" version = "0.1.0" authors = ["Ralf Jung "] diff --git a/collector/benchmarks/ctfe-stress-3/src/lib.rs b/collector/benchmarks/ctfe-stress-4/src/lib.rs similarity index 84% rename from collector/benchmarks/ctfe-stress-3/src/lib.rs rename to collector/benchmarks/ctfe-stress-4/src/lib.rs index 7a932aa98..fdb0a7427 100644 --- a/collector/benchmarks/ctfe-stress-3/src/lib.rs +++ b/collector/benchmarks/ctfe-stress-4/src/lib.rs @@ -2,6 +2,8 @@ use std::mem::MaybeUninit; // Try to make CTFE actually do a lot of computation, without producing a big result. +// The const fn expressions evaluated here take a dummy u32 argument because otherwise +// const fn memoisation is able to eliminate a lot of the work. // And without support for loops. macro_rules! const_repeat { @@ -17,27 +19,27 @@ macro_rules! const_repeat { }}; // Recursive case: Take a 16 ([16 $($n: tt)*] $e: expr, $T: ty) => {{ - const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } - e(); e(); e(); e(); - e(); e(); e(); e(); - e(); e(); e(); e(); - e(); e(); e(); e() + const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) } + e(0); e(0); e(0); e(0); + e(0); e(0); e(0); e(0); + e(0); e(0); e(0); e(0); + e(0); e(0); e(0); e(0) }}; // Recursive case: Take a 8 ([8 $($n: tt)*] $e: expr, $T: ty) => {{ - const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } - e(); e(); e(); e(); - e(); e(); e(); e() + const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) } + e(0); e(0); e(0); e(0); + e(0); e(0); e(0); e(0) }}; // Recursive case: Take a 4 ([4 $($n: tt)*] $e: expr, $T: ty) => {{ - const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } - e(); e(); e(); e() + const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) } + e(0); e(0); e(0); e(0) }}; // Recursive case: Take a 2 ([2 $($n: tt)*] $e: expr, $T: ty) => {{ - const fn e() -> $T { const_repeat!([$($n)*] $e, $T) } - e(); e() + const fn e(_: u32) -> $T { const_repeat!([$($n)*] $e, $T) } + e(0); e(0) }}; } macro_rules! expensive_static {