Merge pull request #3738 from cfallin/pooling-affinity
Pooling allocator: add a reuse-affinity policy.
This commit is contained in:
@@ -249,6 +249,10 @@ pub enum PoolingAllocationStrategy {
|
||||
NextAvailable,
|
||||
/// Allocate from a random available instance.
|
||||
Random,
|
||||
/// Try to allocate an instance slot that was previously used for
|
||||
/// the same module, potentially enabling faster instantiation by
|
||||
/// reusing e.g. memory mappings.
|
||||
ReuseAffinity,
|
||||
}
|
||||
|
||||
impl Default for PoolingAllocationStrategy {
|
||||
@@ -256,6 +260,7 @@ impl Default for PoolingAllocationStrategy {
|
||||
match wasmtime_runtime::PoolingAllocationStrategy::default() {
|
||||
wasmtime_runtime::PoolingAllocationStrategy::NextAvailable => Self::NextAvailable,
|
||||
wasmtime_runtime::PoolingAllocationStrategy::Random => Self::Random,
|
||||
wasmtime_runtime::PoolingAllocationStrategy::ReuseAffinity => Self::ReuseAffinity,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,6 +273,7 @@ impl Into<wasmtime_runtime::PoolingAllocationStrategy> for PoolingAllocationStra
|
||||
match self {
|
||||
Self::NextAvailable => wasmtime_runtime::PoolingAllocationStrategy::NextAvailable,
|
||||
Self::Random => wasmtime_runtime::PoolingAllocationStrategy::Random,
|
||||
Self::ReuseAffinity => wasmtime_runtime::PoolingAllocationStrategy::ReuseAffinity,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,6 +707,7 @@ impl<'a> Instantiator<'a> {
|
||||
.allocator()
|
||||
.allocate(InstanceAllocationRequest {
|
||||
module: compiled_module.module().clone(),
|
||||
unique_id: Some(compiled_module.unique_id()),
|
||||
memfds: self.cur.module.memfds().clone(),
|
||||
image_base: compiled_module.code().as_ptr() as usize,
|
||||
functions: compiled_module.functions(),
|
||||
|
||||
@@ -426,6 +426,7 @@ impl<T> Store<T> {
|
||||
shared_signatures: None.into(),
|
||||
imports: Default::default(),
|
||||
module: Arc::new(wasmtime_environ::Module::default()),
|
||||
unique_id: None,
|
||||
memfds: None,
|
||||
store: StorePtr::empty(),
|
||||
wasm_data: &[],
|
||||
|
||||
@@ -41,6 +41,7 @@ fn create_handle(
|
||||
let handle = OnDemandInstanceAllocator::new(config.mem_creator.clone(), 0).allocate(
|
||||
InstanceAllocationRequest {
|
||||
module: Arc::new(module),
|
||||
unique_id: None,
|
||||
memfds: None,
|
||||
functions,
|
||||
image_base: 0,
|
||||
|
||||
@@ -161,6 +161,7 @@ pub unsafe fn create_raw_function(
|
||||
Ok(
|
||||
OnDemandInstanceAllocator::default().allocate(InstanceAllocationRequest {
|
||||
module: Arc::new(module),
|
||||
unique_id: None,
|
||||
memfds: None,
|
||||
functions: &functions,
|
||||
image_base: (*func).as_ptr() as usize,
|
||||
|
||||
Reference in New Issue
Block a user