pchickey opened issue #15140:
For historical reasons, Wasmtime's pooling allocator and the Engine struct are joined at the hip. Some aspects that affect pooling are indeed linked to codegen and therefore an Engine, but other aspects are not necessarily linked and, in fact this makes some kinds of configurations - the reasonable problem statement "I want a pooling allocator which can provide N instances of Component X" - unnecessarily difficult, or require crude hacks (e.g. serializing and deserializing a Component to move it between code-compatible Engines).
My rough design sketch:
- Engine construction still locks in all aspects of a Module and Component's compilation that affect codegen. This is a very important design principle of Wasmtime we should consider basically set in stone.
- There can be more than one allocator of Stores/Instances associated with an Engine, and the lifetime of those can be shorter than the Engine.
- An Engine can be used for Component::new, and then a pooling allocator (as a new struct wasmtime::Pool) can be constructed based on Component::required_resources and the number of slots desired - basically, we separate out all aspects of
PoolingAllocatorConfigthat do not affect codegen, and make that construct a Pool, not an Engine. Notionally,Pool::new_store(&self, data) -> Result<Store<T>>works likeStore::new(&Engine, data) -> Store<T>, failing when the pool does not have available slots.- In the absence of Pool use, all of the existing Engine machinery works with the on-demand allocator.
rvolosatovs commented on issue #15140:
The proposal sounds great to me - it is not always obvious how to correctly configure the pooling allocator, and it seems that this approach would improve that experience.
More importantly, it sounds like embedders would be able to choose an appropriate allocator configuration per workload, for example use pooling allocator for some workloads and prefer on-demand for others, all while reusing the same engine for codegen, which I would be largely in favor of.
fitzgen commented on issue #15140:
Yeah, seems like a good idea at a high level to me. I have nitpicks about naming and such, but I don't think that makes sense to get into quite yet.
In theory we _could_ even mix instances from different allocators within the same store, but I think that would be more of a headache than actually unlocking any benefit.
Last updated: Nov 19 2026 at 20:05 UTC