feat(wasix): Improve module loading performance and API correctness #5526
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.
This commit contains two notable changes:
The VirtualFile trait is extended with a new as_owned_buffer() method.
This allows cheap copying of file data if the file is already fully in
memory, and enables optimisations for code that is aware of this
functionality by allowing zero-copy cloning.
This is especially useful for data that is already mmaped.
The new method has an empty default impl, but is implemented for
appropriate files (ReadOnlyFile, webc volume files).
Modifies the Runtime::load_module method to take a new
HashedModuleData
structThis has multiple benefits:
so the hash it contains will always be valid for the module data.
This removes a source of bugs due to passing a wrong hash for module
data to module loaders etc.
BinaryPackageCommand, preventing redundant cloning of data
clonable.
Previously it received a slice, which introduces the neccessity of
cloning the data if it needs to be passed on to a different thread.
In combination this PR can significantly reduce memory usage for
high-concurrency scenarios.
Closes #5527