Stream: wasmtime

Topic: in-memory keyvalue resets initial data per bucket access


view this post on Zulip Mark Fisher (Aug 20 2024 at 23:57):

I was excited to try out the new in-memory keyvalue support today! It did however raise a question, and even though I think it's relatively simple, I apologize if my articulation of it is not:

I have a Component C that imports wasi:keyvalue and exports its own function F that is imported by a cli/run Component. If the run Component invokes F multiple times, I expect a counter to change, but because C must get access to the Bucket via store::open, the data is reset to the initial state per invocation. That happens because a new Bucket struct is not just accessed, but (re)created here. Is this the intended behavior, or should the in-memory state be scoped with the lifecycle of wasmtime run itself?

I guess this also raises a question as to the meaning of "identifier" since an empty-string is being used to indicate "in-memory" which is more like an identifier for the backing provider of a store. I would expect that identifier would map to a named Bucket and within a store there could be multiple Buckets. As the wasi:keyvalue wit spec mentions, the exact mapping of Bucket will vary across different backing providers.

Thanks!

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.
Contribute to WebAssembly/wasi-keyvalue development by creating an account on GitHub.

Last updated: Dec 23 2024 at 14:03 UTC