diff --git a/lib/src/execute.rs b/lib/src/execute.rs index 4057f617..fd490953 100644 --- a/lib/src/execute.rs +++ b/lib/src/execute.rs @@ -675,9 +675,7 @@ fn configure_wasmtime( allow_components: bool, profiling_strategy: ProfilingStrategy, ) -> wasmtime::Config { - use wasmtime::{ - Config, InstanceAllocationStrategy, PoolingAllocationConfig, WasmBacktraceDetails, - }; + use wasmtime::{Config, InstanceAllocationStrategy, WasmBacktraceDetails}; let mut config = Config::new(); config.debug_info(false); // Keep this disabled - wasmtime will hang if enabled @@ -686,41 +684,7 @@ fn configure_wasmtime( config.epoch_interruption(true); config.profiler(profiling_strategy); - const MB: usize = 1 << 20; - let mut pooling_allocation_config = PoolingAllocationConfig::default(); - - // This number matches Compute production - pooling_allocation_config.max_core_instance_size(MB); - - // Core wasm programs have 1 memory - pooling_allocation_config.total_memories(100); - pooling_allocation_config.max_memories_per_module(1); - - // allow for up to 128MiB of linear memory. Wasm pages are 64k - pooling_allocation_config.memory_pages(128 * (MB as u64) / (64 * 1024)); - - // Core wasm programs have 1 table - pooling_allocation_config.max_tables_per_module(1); - - // Some applications create a large number of functions, in particular - // when compiled in debug mode or applications written in swift. Every - // function can end up in the table - pooling_allocation_config.table_elements(98765); - - // Maximum number of slots in the pooling allocator to keep "warm", or those - // to keep around to possibly satisfy an affine allocation request or an - // instantiation of a module previously instantiated within the pool. - pooling_allocation_config.max_unused_warm_slots(10); - - // Use a large pool, but one smaller than the default of 1000 to avoid runnign out of virtual - // memory space if multiple engines are spun up in a single process. We'll likely want to move - // to the on-demand allocator eventually for most purposes; see - // https://github.com/fastly/Viceroy/issues/255 - pooling_allocation_config.total_core_instances(100); - - config.allocation_strategy(InstanceAllocationStrategy::Pooling( - pooling_allocation_config, - )); + config.allocation_strategy(InstanceAllocationStrategy::OnDemand); if allow_components { config.wasm_component_model(true); diff --git a/lib/src/linking.rs b/lib/src/linking.rs index 24675aac..cf08038a 100644 --- a/lib/src/linking.rs +++ b/lib/src/linking.rs @@ -28,7 +28,10 @@ impl wasmtime::ResourceLimiter for Limiter { // gradually resize, this will track the total allocations throughout the lifetime of the // instance. self.memory_allocated += desired - current; - Ok(true) + // limit the amount of memory that an instance can use to (roughly) 128MB, erring on + // the side of letting things run that might get killed on Compute, because we are not + // tracking some runtime factors in this count. + Ok(self.memory_allocated < (128 * 1024 * 1024)) } fn table_growing(