Stream: git-wasmtime

Topic: wasmtime / issue #6116 how to access Memory in component-...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 29 2023 at 07:17):

Sherlock-Holo opened issue #6116:

I'm using component-model feature to write a host function, however I can't get the Caller or Store to access the wasm memory through https://docs.rs/wasmtime/latest/wasmtime/struct.Memory.html#method.data_mut

view this post on Zulip Wasmtime GitHub notifications bot (Mar 29 2023 at 15:08):

alexcrichton commented on issue #6116:

At the component model layer of abstraction embedders don't have access to core wasm primitives such as Memory or Func. That means that the answer to your question is that the Memory cannot be accessed.

Could you perhaps elaborate though the intention for accessing memory? We can try to help out with the problem at hand via an alternative means.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2023 at 02:37):

Sherlock-Holo commented on issue #6116:

I'm writing my udp/tcp helper, allow wasm codes can read write tcp/udp
I want to let wasm codes pass the buffer offset and length to the host function, then rust codes can write data into the wasm linear memory directly or read from linear memory directly
but with component-model feature, rust codes can't access the linear memory through Caller for now

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 14:59):

alexcrichton commented on issue #6116:

Ah ok, thanks for the info! For that you'll probably want to take a look at the stream type that WASI is working on. Otherwise with the component model you need to model operations with list<u8> for now. Eventually the component model will have a native stream type for these sorts of operations, but that's not available and/or designed yet.

Given though that the lack of access to linear memory is an intentional design decision I'm going to close this issue. If you're having trouble with streams from WASI it might be best to wait for some of the WASI bits to settle to have more examples to draw from. Otherwise though feel free to open an issue.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 05 2023 at 14:59):

alexcrichton closed issue #6116:

I'm using component-model feature to write a host function, however I can't get the Caller or Store to access the wasm memory through https://docs.rs/wasmtime/latest/wasmtime/struct.Memory.html#method.data_mut

view this post on Zulip Wasmtime GitHub notifications bot (Feb 26 2024 at 06:24):

BrytonLee commented on issue #6116:

@alexcrichton , I have some huge data structs want to be send from host side to wasm module, can I intercept wasi file operation and encapsulate data that can be passed via file descriptor? Do you think that WASI stream type would help?

Thank you for your guidance.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 26 2024 at 15:41):

alexcrichton commented on issue #6116:

@BrytonLee that cannot be easily done today as far as I'm aware. Nowadays we'd recommend using a resource to model your large structure. That way the guest can have a handle on it and only request the parts it needs.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 27 2024 at 01:55):

BrytonLee commented on issue #6116:

Thank you very much, @alexcrichton .

I think most developer care about accessing memory is due to performance concerns. Is there any other suggestion for reducing memory copy cost?

From my best knowledge, 1). wasmtime component module doesn't allow to upper code access wasm module memory (return area and linear memory). 2). stream type implementation in wasmtime doesn't directly access linear memory neither, so it also need to copy data in/out from wasm modue. 3). resource is more suitable for wasm module when it only consumes part of whole data. Are they true?

I saw that wasmedge rust-sdk async-wasi support VFS, it seems that async-wasi allows developer to build a virtual memory file for WASI file I/O, does wasmtime have simillar ones? Also would wasm module develop to use something like mmap to share memory with wasmtime?

Thanks,
Bryton

view this post on Zulip Wasmtime GitHub notifications bot (Feb 27 2024 at 01:57):

BrytonLee edited a comment on issue #6116:

Thank you very much, @alexcrichton .

I think most developer care about accessing memory is due to performance concerns. Is there any other suggestion for reducing memory copy cost?

From my best knowledge, 1). wasmtime component module doesn't allow to upper code access wasm module memory (return area and linear memory). 2). stream type implementation in wasmtime doesn't directly access linear memory neither, so it also need to copy data in/out from wasm modue. 3). resource is more suitable for wasm module when it only consumes part of whole data. Are they true?

I saw that wasmedge rust-sdk async-wasi support VFS, it seems that async-wasi allows developer to build a virtual memory file for WASI file I/O, does wasmtime have simillar ones? Also would wasm module developer can use something like mmap to share memory with wasmtime?

Thanks,
Bryton

view this post on Zulip Wasmtime GitHub notifications bot (Feb 28 2024 at 16:20):

alexcrichton commented on issue #6116:

Ah I see that this discussion has been taken to zulip, so dropping a link here for context.


Last updated: Nov 22 2024 at 16:03 UTC