Stream: git-wasmtime

Topic: wasmtime / issue #4178 Memory usage of a wasm program


view this post on Zulip Wasmtime GitHub notifications bot (May 21 2022 at 00:51):

hainsdominic opened issue #4178:

Greetings,

Is there a way of knowing how many pages a wasm program used during its execution? I did not find references to this on the documentation. Would it be possible to use the data method of the Store in order to do this?

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (May 21 2022 at 04:55):

alexcrichton commented on issue #4178:

For this you can use the ResourceLimiter trait combined with Store::limiter to sum up all memories grown within a Store. That will indicate memory that wasm had accessible but not necessarily the memory that wasm used (e.g. reserved address space but it it may not all be paged in by the OS). If you're curious about actual page usage you'd need to get the actual Memory object to use APIs like mincore to see if it's actually paged in.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 20:09):

alexcrichton commented on issue #4178:

I think this is solved with what I mentioned above so I'm going to close this, but if it doesn't work for you feel free to reopen and we can try to continue helping.

view this post on Zulip Wasmtime GitHub notifications bot (May 24 2022 at 20:09):

alexcrichton closed issue #4178:

Greetings,

Is there a way of knowing how many pages a wasm program used during its execution? I did not find references to this on the documentation. Would it be possible to use the data method of the Store in order to do this?

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (May 25 2022 at 14:45):

hainsdominic commented on issue #4178:

Thank you! I'll try to implement it soon

view this post on Zulip Wasmtime GitHub notifications bot (May 26 2022 at 14:49):

hainsdominic commented on issue #4178:

Would memory.data_size work in this use case?

view this post on Zulip Wasmtime GitHub notifications bot (May 26 2022 at 14:50):

hainsdominic edited a comment on issue #4178:

Would memory.data_size work in this use case? It seems like a simpler implementation than using the trait and the limiter. But correct me if I'm wrong.

view this post on Zulip Wasmtime GitHub notifications bot (May 26 2022 at 14:59):

alexcrichton commented on issue #4178:

Yes if you have access to the Memory then the data_size reported will be the size of memory that wasm was allowed to use.


Last updated: Dec 23 2024 at 12:05 UTC