bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.37k stars 1.3k forks source link

Add support for per-component limits in the pooling allocator #6628

Open fitzgen opened 1 year ago

fitzgen commented 1 year ago

That is, we should be able to reject allocation/instantiation for a component with more instances/tables/etc than a pre-configured limit, even when we actually have that much capacity in the pooling allocator.

fitzgen commented 1 year ago

This might exist in InstancePre, need to double check.

fitzgen commented 1 year ago

Either way, we should have typed errors for when you try to instantiate a component that lets you determine whether instantiation failed because there is not enough capacity for the component currently, or because the component is statically above the configured per-component limits on tables/memories/etc.

alexcrichton commented 1 year ago

Right now this exists for modules as InstanceAllocator::validate and I think the solution here is "just" adding a component version of that. Note though that this is a compile-time check as opposed to a instantiation-time check, so you'd never run into a situation where a component could never be instantiated due to its limits.

That being said I think a descriptive error here is still good to have, since even if a component fits within the limits configured it can still fail to instantiate and it'd be good to understand why.