memfd: make "dense image" heuristic limit configurable. (#3831)
In #3820 we see an issue with the new heuristics that control use of memfd: it's entirely possible for a reasonable Wasm module produced by a snapshotting system to have a relatively sparse heap (less than 50% filled). A system that avoids memfd because of this would have an undesirable performance reduction on such modules. Ultimately we should try to implement a hybrid scheme where we support outlier/leftover initializers, but for now this PR makes the "always allow dense" limit configurable. This way, embedders that want to ensure that memfd is used can do so, if they have other knowledge about the maximum heap size allowed in their system. (Partially addresses #3820 but let's leave it open to track the hybrid idea)
This commit is contained in:
@@ -257,6 +257,7 @@ pub struct WasmtimeConfig {
|
||||
pub memory_config: MemoryConfig,
|
||||
force_jump_veneers: bool,
|
||||
memfd: bool,
|
||||
memfd_guaranteed_dense_image_size: u64,
|
||||
use_precompiled_cwasm: bool,
|
||||
/// Configuration for the instance allocation strategy to use.
|
||||
pub strategy: InstanceAllocationStrategy,
|
||||
@@ -440,6 +441,12 @@ impl Config {
|
||||
.interruptable(self.wasmtime.interruptable)
|
||||
.consume_fuel(self.wasmtime.consume_fuel)
|
||||
.memfd(self.wasmtime.memfd)
|
||||
.memfd_guaranteed_dense_image_size(std::cmp::min(
|
||||
// Clamp this at 16MiB so we don't get huge in-memory
|
||||
// images during fuzzing.
|
||||
16 << 20,
|
||||
self.wasmtime.memfd_guaranteed_dense_image_size,
|
||||
))
|
||||
.allocation_strategy(self.wasmtime.strategy.to_wasmtime());
|
||||
|
||||
self.wasmtime.codegen.configure(&mut cfg);
|
||||
|
||||
Reference in New Issue
Block a user