Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiltd committed Nov 25, 2024
1 parent 9649fde commit a22b0b0
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions crates/containerd-shim-wasmtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ impl<T: WasiConfig> Default for WasmtimeEngine<T> {
let mut config = T::new_config();
config.async_support(true); // must be on

if let Some(true) = use_pooling_allocator_by_default()
.context("failed to determine allocation strategy")
.unwrap()
{
if use_pooling_allocator_by_default().unwrap_or_default() {
let cfg = wasmtime::PoolingAllocationConfig::default();
config.allocation_strategy(wasmtime::InstanceAllocationStrategy::Pooling(cfg));
}
Expand Down Expand Up @@ -450,18 +447,15 @@ async fn wait_for_signal() -> Result<i32> {
/// The pooling allocator is tailor made for the `wasi/http` use case. Check if we can use it.
///
/// For more details refer to: <https://github.com/bytecodealliance/wasmtime/blob/v27.0.0/src/commands/serve.rs#L641>
fn use_pooling_allocator_by_default() -> Result<Option<bool>> {
fn use_pooling_allocator_by_default() -> Result<bool> {
const BITS_TO_TEST: u32 = 42;
let mut config = Config::new();
config.wasm_memory64(true);
let engine = wasmtime::Engine::new(&config)?;
let mut store = Store::new(&engine, ());
let ty = wasmtime::MemoryType::new64(0, Some(1 << (BITS_TO_TEST - 16)));
if wasmtime::Memory::new(&mut store, ty).is_ok() {
Ok(Some(true))
} else {
Ok(None)
}

Ok(wasmtime::Memory::new(&mut store, ty).is_ok())
}

pub trait IntoErrorCode {
Expand Down

0 comments on commit a22b0b0

Please sign in to comment.