-
Notifications
You must be signed in to change notification settings - Fork 147
feat: add ability to configure static memory size #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Nice! What happens if this limit is exceeded? And is it only upon instantiation? |
If the limit is exceeded then it switches to dynamic memory, where more memory is allocated and the old memory is copied over - so there is some performance downside to growing memory at that point. More information here: https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.static_memory_maximum_size |
pub fn with_fuel_limit(mut self, fuel: u64) -> Self { | ||
self.fuel = Some(fuel); | ||
self | ||
} | ||
|
||
/// Limit the size of the memory allocated up-front when | ||
/// instantiating a module | ||
pub fn with_static_memory_size(mut self, size: u64) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the potential performance implications, and the big warnings from the underlaying wasmtime function's documentation, maybe it would be worth it to add a link to https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.static_memory_maximum_size in this function's documentation.
Just so people not aware don't accidently change that setting without understanding
I just opened #764, which solves the same problem in a more general way |
An alternative to #763, this PR allows an initial `wasmtime::Config` to be passed in when building a plugin. Some of these values may be overwritten by the Extism runtime, but it allows for things like static memory size and other low-level details to be handled directly instead of us having to wrap every option ourselves.
Closing this after merging #764 |
This makes it possible to configure the amount of memory that's allocated up front when instantiating a plugin.
Also adds a default static memory size of 4GB to the C API.