GerardSmit opened issue #11617:
Currently
list<..>is being passed through asWASMTIME_COMPONENT_LISTwithwasmtime_component_vallist_tas union type.In
wasmtime_component_vallist_teach item is awasmtime_component_val. This struct has a size of 32 bytes.In WASI,
list<u8>is used as an byte array, for example inwasi:sockets/udp.
With the implementation in C-API would this need way more memory than needed.For example, lets say you pass 512 bytes to the component.
Instead of 512 bytes you need to create awasmtime_component_vallist_tof 512 items, that use 16384 bytes in total.Suggestion
Create a new type, e.g.
WASMTIME_COMPONENT_LIST_U8that uses the union typewasm_byte_vec_t.Whenever
list<u8>is used, the new value type should be used:WASMTIME_COMPONENT_LIST_U8withwasm_byte_vec_t
For other types, the current type should be used:WASMTIME_COMPONENT_LISTwithwasmtime_component_vallist_tBenefit
Less memory is being passed through C-API.
Implementation
N/A
Alternatives
Accept the fact that every byte is actually 32 bytes when using
list<u8>Or use
stringinstead oflist<u8>in WIT, since this useswasm_byte_vec_tas union type, where the data is a simplebyte.
GerardSmit edited issue #11617:
Currently
list<..>is being passed through asWASMTIME_COMPONENT_LISTwithwasmtime_component_vallist_tas union type.In
wasmtime_component_vallist_teach item is awasmtime_component_val. This struct has a size of 32 bytes.In WASI,
list<u8>is used as an byte array, for example inwasi:sockets/udp.
With the implementation in C-API would this need way more memory than needed.For example, lets say you pass 512 bytes to the component.
Instead of 512 bytes you need to create awasmtime_component_vallist_tof 512 items, that use 16384 bytes in total.You also need to transform the bytes to
wasmtime_component_valitems, which is an additional step you need to do before passing the byte array.Suggestion
Create a new type, e.g.
WASMTIME_COMPONENT_LIST_U8that uses the union typewasm_byte_vec_t.Whenever
list<u8>is used, the new value type should be used:WASMTIME_COMPONENT_LIST_U8withwasm_byte_vec_t
For other types, the current type should be used:WASMTIME_COMPONENT_LISTwithwasmtime_component_vallist_tBenefit
Less memory is being passed through C-API.
Implementation
N/A
Alternatives
Accept the fact that every byte is actually 32 bytes when using
list<u8>Or use
stringinstead oflist<u8>in WIT, since this useswasm_byte_vec_tas union type, where the data is a simplebyte.
GerardSmit edited issue #11617:
Currently
list<..>is being passed through asWASMTIME_COMPONENT_LISTwithwasmtime_component_vallist_tas union type.In
wasmtime_component_vallist_teach item is awasmtime_component_val. This struct has a size of 32 bytes.In WASI,
list<u8>is used as an byte array, for example inwasi:sockets/udp.
With the implementation in C-API would this need way more memory than needed.For example, lets say you pass 512 bytes to the component.
Instead of 512 bytes you need to create awasmtime_component_vallist_tof 512 items, that use 16384 bytes in total.You also need to transform the bytes to
wasmtime_component_valitems, which is an additional step you need to do before passing the byte array.Suggestion
Create a new type, e.g.
WASMTIME_COMPONENT_LIST_U8that uses the union typewasm_byte_vec_t.Whenever
list<u8>is used, the new value type should be used:WASMTIME_COMPONENT_LIST_U8withwasm_byte_vec_t
For other types, the current type should be used:WASMTIME_COMPONENT_LISTwithwasmtime_component_vallist_tBenefit
Less memory is being passed through C-API, and less overhead (by not transforming the bytes to
wasmtime_component_val's)Implementation
N/A
Alternatives
Accept the fact that every byte is actually 32 bytes when using
list<u8>Or use
stringinstead oflist<u8>in WIT, since this useswasm_byte_vec_tas union type, where the data is a simplebyte.
Last updated: Dec 06 2025 at 07:03 UTC