Stream: wasmtime

Topic: Limit size of stdout and stderr files


view this post on Zulip wsta (Aug 08 2023 at 16:05):

I am using the WasiCtxBuilder class of the wasmtime-rb gem to set stdout and stderr files using set_stdout_file and set_stderr_file respectively. I was wondering if there is any way to limit the max size of these files, i.e. the amount of bytes that the Wasm module is allowed to write to them? I also noticed the ResourceLimiter rust trait, is this feature planned for wasmtime-rb?

view this post on Zulip Pat Hickey (Aug 08 2023 at 16:08):

no, there is no limiting on those files. it would be possible to implement some limiting on those files with a lower level interface than provided by that ruby class, but I don't actually know much about how the ruby bindings work

view this post on Zulip Pat Hickey (Aug 08 2023 at 16:09):

the resource limiter trait is about limiting the sizes of linear memories and tables created in a Store

view this post on Zulip wsta (Aug 09 2023 at 07:44):

Thanks for your reply. By lower level interface, do you mean in the base wasmtime rust crate? Or do you mean use something like a tmpfs file system with a max capacity instead?

I know about the ResourceLimiter, I am also interested in limiting the memory usage of Wasm modules using wasmtime-rb, hence my question.

view this post on Zulip Lann Martin (Aug 09 2023 at 12:03):

The wasmtime wasi rust implementation would let you hook into the stdout/stderr write calls, which means you could add pretty much whatever logic you want. See: https://docs.rs/wasi-common/11.0.1/wasi_common/pipe/struct.WritePipe.html

You could probably find some outside solution that would work on a particular OS (like a tmpfs), but making it work cross-platform might be tricky if that is a goal.


Last updated: Nov 22 2024 at 17:03 UTC