Skip to content

fix/host response double clone#219

Merged
flavio merged 2 commits into
wapc:masterfrom
flavio:fix/host-response-double-clone
Jul 13, 2026
Merged

fix/host response double clone#219
flavio merged 2 commits into
wapc:masterfrom
flavio:fix/host-response-double-clone

Conversation

@flavio

@flavio flavio commented Jul 9, 2026

Copy link
Copy Markdown
Member

While assessing a review comment on a project making use of waPC, I realised we could do a minor optimization when dealing with the host response.

The get_host_response() cloned the response Vec once for __host_response_len and again for __host_response, on every host callback.

This PR adds host_response_len() and with_host_response() methods to ModuleState/ModuleStateAsync (inside of wapc crate) for clone-free access.
The it uses them in wasmtime-provider and wasm3-provider (which I know, is currently disabled but it was a cheap edit) callbacks, cutting copies per callback from 3 to 1. This can be significant when the host response is a big.

This PR deprecates get_host_response() in favor of the new accessors, keeping it for backward compatibility. We can remove this legacy API in a future major release of the wapc create.

This PR also does a minor bump of the wapc and wasmtime-provider crates. I'll take care of that once this gets merged.

flavio added 2 commits July 9, 2026 19:01
get_host_response() cloned the response Vec once for
__host_response_len and again for __host_response, on every host
callback. Add host_response_len()/with_host_response() to
ModuleState/ModuleStateAsync for clone-free access, and use them in
wasmtime-provider and wasm3-provider callbacks, cutting copies per
callback from 3 to 1.

Deprecate get_host_response() in favor of the new accessors, keeping
it for backward compatibility. Add rstest-parameterized unit tests
covering both.

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Assisted-by: Claude Sonnet 5.0
Prepare a minor release of wapc and wasmtime-provider to include the
performance fix.

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
@flavio flavio merged commit ea77e18 into wapc:master Jul 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants