Skip to content

Commit

Permalink
Speed up a "big stack" test, and test Winch (bytecodealliance#9636)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alexcrichton authored Nov 20, 2024
1 parent 4f386b7 commit e32292c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/all/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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,
Expand All @@ -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, "")?;
Expand Down

0 comments on commit e32292c

Please sign in to comment.