Stream: wasmtime

Topic: component memory consumption


view this post on Zulip Ryan Levick (rylev) (May 11 2023 at 17:06):

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?

view this post on Zulip Alex Crichton (May 11 2023 at 17:07):

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)

view this post on Zulip Ryan Levick (rylev) (May 11 2023 at 17:28):

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

view this post on Zulip Lann Martin (May 11 2023 at 20:12):

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?

view this post on Zulip Alex Crichton (May 11 2023 at 20:18):

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

view this post on Zulip Alex Crichton (May 11 2023 at 20:18):

which should allow you to either reject it or otherwise account for it

view this post on Zulip Alex Crichton (May 11 2023 at 20:18):

definitely worth updating the docs though as they're somewhat limited right now

view this post on Zulip Ryan Levick (rylev) (May 11 2023 at 20:33):

One other question: is desired always guaranteed to be greater than current in ResourceLimiter::memory_growing?

view this post on Zulip Alex Crichton (May 11 2023 at 20:38):

I'm pretty certain it's never less than

view this post on Zulip Alex Crichton (May 11 2023 at 20:38):

I'm hesitating on saying whether it's equal-to

view this post on Zulip Alex Crichton (May 11 2023 at 20:38):

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