Skip to content
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

Add CLI flags for instance limits #8027

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ wasmtime_option_group! {
/// Configure attempting to initialize linear memory via a
/// copy-on-write mapping (default: yes)
pub memory_init_cow: Option<bool>,

/// The maximum number of WebAssembly instances which can be created.
pub total_core_instances: Option<u32>,

/// The maximum number of WebAssembly components which can be created.
pub total_component_instances: Option<u32>,

/// The maximum number of WebAssembly memories which can be created.
pub total_memories: Option<u32>,

/// The maximum number of WebAssembly tables which can be created.
pub total_tables: Option<u32>,

/// The maximum number of WebAssembly stacks which can be created.
pub total_stacks: Option<u32>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option here, since all of these default to the same number currently, is to have a single flag --total-pool-slots or the like that sets all of these together. But maybe someone wants to control these in a bit more fine-grained way, so I went down this route instead.

}

enum Optimize {
Expand Down Expand Up @@ -528,6 +543,21 @@ impl CommonOptions {
if let Some(size) = self.opts.pooling_table_keep_resident {
cfg.table_keep_resident(size);
}
if let Some(limit) = self.opts.total_core_instances {
cfg.total_core_instances(limit);
}
if let Some(limit) = self.opts.total_component_instances {
cfg.total_component_instances(limit);
}
if let Some(limit) = self.opts.total_memories {
cfg.total_memories(limit);
}
if let Some(limit) = self.opts.total_tables {
cfg.total_tables(limit);
}
if let Some(limit) = self.opts.total_stacks {
cfg.total_stacks(limit);
}
if let Some(enable) = self.opts.memory_protection_keys {
if enable {
cfg.memory_protection_keys(wasmtime::MpkEnabled::Enable);
Expand Down