Always allocate Instance memory with malloc (#5656)
This commit removes the pooling of `Instance` allocations from the pooling instance allocator. This means that the allocation of `Instance` (and `VMContext`) memory, now always happens through the system `malloc` and `free` instead of optionally being part of the pooling instance allocator. Along the way this refactors the `InstanceAllocator` trait so the pooling and on-demand allocators can share more structure with this new property of the implementation. The main rationale for this commit is to reduce the RSS of long-lived programs which allocate instances with the pooling instance allocator and aren't using the "next available" allocation strategy. In this situation the memory for an instance is never decommitted until the end of the program, meaning that eventually all instance slots will become occupied and resident. This has the effect of Wasmtime slowly eating more and more memory over time as each slot gets an instance allocated. By switching to the system allocator this should reduce the current RSS workload from O(used slots) to O(active slots), which is more in line with expectations.
This commit is contained in:
@@ -51,8 +51,8 @@ pub use crate::export::*;
|
||||
pub use crate::externref::*;
|
||||
pub use crate::imports::Imports;
|
||||
pub use crate::instance::{
|
||||
allocate_single_memory_instance, InstanceAllocationRequest, InstanceAllocator, InstanceHandle,
|
||||
OnDemandInstanceAllocator, StorePtr,
|
||||
InstanceAllocationRequest, InstanceAllocator, InstanceHandle, OnDemandInstanceAllocator,
|
||||
StorePtr,
|
||||
};
|
||||
#[cfg(feature = "pooling-allocator")]
|
||||
pub use crate::instance::{
|
||||
|
||||
Reference in New Issue
Block a user