I'm looking to track metrics on memory consumption from the host side. If I have a wasmtime::component::instance::Instance
, is there a way to tell how much memory has been allocated in that instance?
This can be tracked at the Store<T>
level with a ResourceLimiter
, but not on a more granular per-instance basis right now (although you as the embedder can probably correlate per-instance if necessary)
We should be fine to get the data from the store I think since we don't _really_ care about it at the instance level - we have only one instance in this case. Thanks! I'll let you know if I run into any issues
I remember looking at ResourceLimiter::memory_growing
for this and thinking that it wouldn't apply to data segment initialization. Would it make sense to update the docs there?
Indeed! It does take into account the initial growth for a memory, modeled as a growth from 0 to the requested size of the initial memory
which should allow you to either reject it or otherwise account for it
definitely worth updating the docs though as they're somewhat limited right now
One other question: is desired
always guaranteed to be greater than current
in ResourceLimiter::memory_growing
?
I'm pretty certain it's never less than
I'm hesitating on saying whether it's equal-to
I'd have to check the code, but I would say it should only ever be called when desired > current
Last updated: Nov 22 2024 at 16:03 UTC