Skip to content

Commit 3038583

Browse files
committed
chore: Second pass on wasmtime config
1 parent 17072f1 commit 3038583

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

fvm/src/machine/engine.rs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use anyhow::{anyhow, Context};
77
use cid::Cid;
88
use fvm_ipld_blockstore::Blockstore;
99
use fvm_wasm_instrument::gas_metering::GAS_COUNTER_NAME;
10+
use wasmtime::OptLevel::Speed;
1011
use wasmtime::{Global, GlobalType, Linker, Memory, MemoryType, Module, Mutability, Val, ValType};
1112

1213
use crate::gas::WasmGasPrices;
@@ -69,9 +70,12 @@ pub fn default_wasmtime_config() -> wasmtime::Config {
6970
let mut c = wasmtime::Config::default();
7071

7172
// wasmtime default: false
73+
// We don't want threads, there is no way to ensure determisism
7274
c.wasm_threads(false);
7375

7476
// wasmtime default: true
77+
// simd isn't supported in wasm-instrument, but if we add support there, we can probably enable this.
78+
// Note: stack limits may need adjusting after this is enabled
7579
c.wasm_simd(false);
7680

7781
// wasmtime default: false
@@ -81,18 +85,23 @@ pub fn default_wasmtime_config() -> wasmtime::Config {
8185
c.wasm_memory64(false);
8286

8387
// wasmtime default: true
88+
// Note: wasm-instrument only supports this at a basic level, for M2 we will
89+
// need to add more advanced support
8490
c.wasm_bulk_memory(true);
8591

8692
// wasmtime default: false
8793
c.wasm_module_linking(false);
8894

8995
// wasmtime default: true
90-
c.wasm_multi_value(false); // ??
96+
// we should be able to enable this for M2, just need to make sure that it's
97+
// handled correctly in wasm-instrument
98+
c.wasm_multi_value(false);
9199

92100
// wasmtime default: depends on the arch
93101
// > This is true by default on x86-64, and false by default on other architectures.
94102
//
95-
// Not supported in wasm-instrument/parity-wasm
103+
// Not supported in wasm-instrument/parity-wasm; adding support will be complicated.
104+
// Note: stack limits may need adjusting after this is enabled
96105
c.wasm_reference_types(false);
97106

98107
// wasmtime default: false
@@ -105,13 +114,29 @@ pub fn default_wasmtime_config() -> wasmtime::Config {
105114
// > not enabled by default.
106115
c.cranelift_nan_canonicalization(true);
107116

117+
// wasmtime default: 512KiB
108118
// Set to something much higher than the instrumented limiter.
109-
c.max_wasm_stack(64 << 20).unwrap();
119+
// Note: This is in bytes, while the instrumented limit is in stack elements
120+
c.max_wasm_stack(4 << 20).unwrap();
110121

111122
// Execution cost accouting is done through wasm instrumentation,
112123
c.consume_fuel(false);
113-
114-
// c.cranelift_opt_level(Speed); ?
124+
c.epoch_interruption(false);
125+
126+
// Disable debug-related things, wasm-instrument doesn't fix debug info
127+
// yet, so those aren't useful, just add overhead
128+
c.debug_info(false);
129+
c.generate_address_map(false);
130+
c.cranelift_debug_verifier(false);
131+
132+
// Reiterate some defaults
133+
c.guard_before_linear_memory(true);
134+
c.interruptable(false);
135+
c.parallel_compilation(true);
136+
137+
// Doesn't seem to have significant impact on the time it takes to load code
138+
// todo(M2): make sure this is guaranteed to run in linear time.
139+
c.cranelift_opt_level(Speed);
115140

116141
c
117142
}

0 commit comments

Comments
 (0)