fix/host response double clone#219
Merged
Merged
Conversation
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>
pkedy
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_lenand again for__host_response, on every host callback.This PR adds
host_response_len()andwith_host_response()methods toModuleState/ModuleStateAsync(inside ofwapccrate) for clone-free access.The it uses them in
wasmtime-providerandwasm3-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 thewapccreate.This PR also does a minor bump of the
wapcandwasmtime-providercrates. I'll take care of that once this gets merged.