From e32292c95a1b6af14faa5ce853e7f81df81ab498 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 20 Nov 2024 12:25:55 -0700 Subject: [PATCH] Speed up a "big stack" test, and test Winch (#9636) * Speed up a "big stack" test, and test Winch This test currently takes 50s locally in debug mode locally so optimize it by disabling optimizations in Cranelift and additionally using the single-pass register allocator. This drops the test time to ~3s locally. * Fix test comments --- tests/all/stack_overflow.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/all/stack_overflow.rs b/tests/all/stack_overflow.rs index 791d481d8870..5868feefd8a3 100644 --- a/tests/all/stack_overflow.rs +++ b/tests/all/stack_overflow.rs @@ -2,6 +2,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use wasmtime::*; +use wasmtime_test_macros::wasmtime_test; #[test] fn host_always_has_some_stack() -> Result<()> { @@ -119,8 +120,8 @@ fn host_always_has_some_stack() -> Result<()> { } } -#[test] -fn big_stack_works_ok() -> Result<()> { +#[wasmtime_test] +fn big_stack_works_ok(config: &mut Config) -> Result<()> { const N: usize = 10000; // Build a module with a function that uses a very large amount of stack space, @@ -143,7 +144,13 @@ fn big_stack_works_ok() -> Result<()> { s.push_str("(func $get (result i64) i64.const 0)\n"); s.push_str(")\n"); - let mut store = Store::<()>::default(); + // Disable cranelift optimizations to ensure that this test doesn't take too + // long in debug mode due to the large size of its code. + config.cranelift_opt_level(OptLevel::None); + config.cranelift_regalloc_algorithm(RegallocAlgorithm::SinglePass); + let engine = Engine::new(config)?; + + let mut store = Store::new(&engine, ()); let module = Module::new(store.engine(), &s)?; let instance = Instance::new(&mut store, &module, &[])?; let func = instance.get_typed_func::<(), i64>(&mut store, "")?;