Skip to content
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

Decrease default wasm stack to 512k from 1M #3861

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Decrease default wasm stack to 512k from 1M
This commit aims to achieve the goal of being able to run the test suite
on Windows with `--test-threads 1`, or more notably allowing Wasmtime's
defaults to work better with the main thread on Windows which appears to
have a smaller stack by default than Linux by comparison. In decreasing
the default wasm stack size a test is also update to probe for less
stack to work on Windows' main thread by default, ideally allowing the
full test suite to work with `--test-threads 1` (although this isn't
added to CI as it's not really critical).

Closes #3857
  • Loading branch information
alexcrichton committed Feb 28, 2022
commit a890d8d4cd783d2ea4b0eb3a0f5145160ba33b19
12 changes: 10 additions & 2 deletions crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ impl Config {
profiler: Arc::new(NullProfilerAgent),
mem_creator: None,
allocation_strategy: InstanceAllocationStrategy::OnDemand,
max_wasm_stack: 1 << 20,
// 512k of stack -- note that this is chosen currently to not be too
// big, not be too small, and be a good default for most platforms.
// One platform of particular note is Windows where the stack size
// of the main thread seems to, by default, be smaller than that of
// Linux and macOS. This 512k value at least lets our current test
// suite pass on the main thread of Windows (using `--test-threads
// 1` forces this), or at least it passed when this change was
// committed.
max_wasm_stack: 512 * 1024,
wasm_backtrace_details_env_used: false,
features: WasmFeatures::default(),
#[cfg(feature = "async")]
Expand Down Expand Up @@ -444,7 +452,7 @@ impl Config {
/// on stack overflow, a host function that overflows the stack will
/// abort the process.
///
/// By default this option is 1 MiB.
/// By default this option is 512 KiB.
pub fn max_wasm_stack(&mut self, size: usize) -> Result<&mut Self> {
#[cfg(feature = "async")]
if size > self.async_stack_size {
Expand Down
4 changes: 2 additions & 2 deletions tests/all/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use wasmtime::*;
#[test]
fn host_always_has_some_stack() -> anyhow::Result<()> {
static HITS: AtomicUsize = AtomicUsize::new(0);
// assume hosts always have at least 512k of stack
const HOST_STACK: usize = 512 * 1024;
// assume hosts always have at least 128k of stack
const HOST_STACK: usize = 128 * 1024;

let mut store = Store::<()>::default();

Expand Down