Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the pooling-allocator feature. #3514

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ jobs:
- run: cargo check -p wasmtime --no-default-features --features cache
- run: cargo check -p wasmtime --no-default-features --features async
- run: cargo check -p wasmtime --no-default-features --features uffd
- run: cargo check -p wasmtime --no-default-features --features pooling-allocator
- run: cargo check -p wasmtime --no-default-features --features cranelift
- run: cargo check -p wasmtime --no-default-features --features cranelift,wat,async,cache

Expand Down
5 changes: 4 additions & 1 deletion crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ default = []

async = ["wasmtime-fiber"]

# Enables support for the pooling instance allocator
pooling-allocator = []

# Enables support for userfaultfd in the pooling allocator when building on Linux
uffd = ["userfaultfd"]
uffd = ["userfaultfd", "pooling-allocator"]

# Enables trap handling using POSIX signals instead of Mach exceptions on MacOS.
# It is useful for applications that do not bind their own exception ports and
Expand Down
2 changes: 2 additions & 0 deletions crates/runtime/src/instance/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ use wasmtime_environ::{
SignatureIndex, TableInitializer, TrapCode, VMOffsets, WasmType, WASM_PAGE_SIZE,
};

#[cfg(feature = "pooling-allocator")]
mod pooling;

#[cfg(feature = "pooling-allocator")]
pub use self::pooling::{
InstanceLimits, ModuleLimits, PoolingAllocationStrategy, PoolingInstanceAllocator,
};
Expand Down
9 changes: 6 additions & 3 deletions crates/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ pub use crate::export::*;
pub use crate::externref::*;
pub use crate::imports::Imports;
pub use crate::instance::{
InstanceAllocationRequest, InstanceAllocator, InstanceHandle, InstanceLimits,
InstantiationError, LinkError, ModuleLimits, OnDemandInstanceAllocator,
PoolingAllocationStrategy, PoolingInstanceAllocator, StorePtr,
InstanceAllocationRequest, InstanceAllocator, InstanceHandle, InstantiationError, LinkError,
OnDemandInstanceAllocator, StorePtr,
};
#[cfg(feature = "pooling-allocator")]
pub use crate::instance::{
InstanceLimits, ModuleLimits, PoolingAllocationStrategy, PoolingInstanceAllocator,
};
pub use crate::jit_int::GdbJitImageRegistration;
pub use crate::memory::{Memory, RuntimeLinearMemory, RuntimeMemoryCreator};
Expand Down
1 change: 1 addition & 0 deletions crates/runtime/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ impl Memory {
}

/// Returns whether or not the underlying storage of the memory is "static".
#[cfg(feature = "pooling-allocator")]
pub(crate) fn is_static(&self) -> bool {
if let Memory::Static { .. } = self {
true
Expand Down
1 change: 1 addition & 0 deletions crates/runtime/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ impl Table {
}

/// Returns whether or not the underlying storage of the table is "static".
#[cfg(feature = "pooling-allocator")]
pub(crate) fn is_static(&self) -> bool {
if let Table::Static { .. } = self {
true
Expand Down
7 changes: 5 additions & 2 deletions crates/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" }
maintenance = { status = "actively-developed" }

[features]
default = ['async', 'cache', 'wat', 'jitdump', 'parallel-compilation', 'cranelift']
default = ['async', 'cache', 'wat', 'jitdump', 'parallel-compilation', 'cranelift', 'pooling-allocator']

# An on-by-default feature enabling runtime compilation of WebAssembly modules
# with the Cranelift compiler. Cranelift is the default compilation backend of
Expand All @@ -76,8 +76,11 @@ cache = ["wasmtime-cache"]
# `async fn` and calling functions asynchronously.
async = ["wasmtime-fiber", "wasmtime-runtime/async", "async-trait"]

# Enables support for the pooling instance allocation strategy
pooling-allocator = ["wasmtime-runtime/pooling-allocator"]

# Enables userfaultfd support in the runtime's pooling allocator when building on Linux
uffd = ["wasmtime-runtime/uffd"]
uffd = ["wasmtime-runtime/uffd", "pooling-allocator"]

# Enables support for all architectures in Cranelift, allowing
# cross-compilation using the `wasmtime` crate's API, notably the
Expand Down
Loading