Implement the pooling instance allocator.
This commit implements the pooling instance allocator. The allocation strategy can be set with `Config::with_allocation_strategy`. The pooling strategy uses the pooling instance allocator to preallocate a contiguous region of memory for instantiating modules that adhere to various limits. The intention of the pooling instance allocator is to reserve as much of the host address space needed for instantiating modules ahead of time and to reuse committed memory pages wherever possible.
This commit is contained in:
@@ -26,6 +26,12 @@ use wasmtime_environ::{
|
||||
ir, Module, ModuleTranslation, ModuleType, OwnedDataInitializer, TableElements, VMOffsets,
|
||||
};
|
||||
|
||||
mod pooling;
|
||||
|
||||
pub use self::pooling::{
|
||||
InstanceLimits, ModuleLimits, PoolingAllocationStrategy, PoolingInstanceAllocator,
|
||||
};
|
||||
|
||||
/// Represents a request for a new runtime instance.
|
||||
pub struct InstanceAllocationRequest<'a> {
|
||||
/// The module being instantiated.
|
||||
@@ -72,11 +78,18 @@ pub enum InstantiationError {
|
||||
/// A trap ocurred during instantiation, after linking.
|
||||
#[error("Trap occurred during instantiation")]
|
||||
Trap(Trap),
|
||||
|
||||
/// A limit on how many instances are supported has been reached.
|
||||
#[error("Limit of {0} concurrent instances has been reached")]
|
||||
Limit(u32),
|
||||
}
|
||||
|
||||
/// An error while creating a fiber stack.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum FiberStackError {
|
||||
/// Insufficient resources available for the request.
|
||||
#[error("Insufficient resources: {0}")]
|
||||
Resource(String),
|
||||
/// An error for when the allocator doesn't support custom fiber stacks.
|
||||
#[error("Custom fiber stacks are not supported by the allocator")]
|
||||
NotSupported,
|
||||
@@ -218,7 +231,7 @@ unsafe fn initialize_vmcontext(
|
||||
globals.len(),
|
||||
);
|
||||
|
||||
// Initialize the defined functions
|
||||
// Initialize the functions
|
||||
for (index, sig) in instance.module.functions.iter() {
|
||||
let type_index = lookup_shared_signature(*sig);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user