Skip to content

Commit

Permalink
Add CLI flags for instance limits (#8027)
Browse files Browse the repository at this point in the history
* Add CLI flags for instance limits

While experimenting with `wasmtime serve`, I found it helpful to be able
to configure some of the maximum limits of the various objects stored in
the pooling allocator. This change surfaces some new `-O total-*` flags
for controlling these limits from the command line.

* review: prepend flags with `pooling_*`
  • Loading branch information
abrown authored Mar 1, 2024
1 parent 391ddfb commit 480fb0e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ 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
/// with the pooling allocator.
pub pooling_total_core_instances: Option<u32>,

/// The maximum number of WebAssembly components which can be created
/// with the pooling allocator.
pub pooling_total_component_instances: Option<u32>,

/// The maximum number of WebAssembly memories which can be created with
/// the pooling allocator.
pub pooling_total_memories: Option<u32>,

/// The maximum number of WebAssembly tables which can be created with
/// the pooling allocator.
pub pooling_total_tables: Option<u32>,

/// The maximum number of WebAssembly stacks which can be created with
/// the pooling allocator.
pub pooling_total_stacks: Option<u32>,
}

enum Optimize {
Expand Down Expand Up @@ -528,6 +548,21 @@ impl CommonOptions {
if let Some(size) = self.opts.pooling_table_keep_resident {
cfg.table_keep_resident(size);
}
if let Some(limit) = self.opts.pooling_total_core_instances {
cfg.total_core_instances(limit);
}
if let Some(limit) = self.opts.pooling_total_component_instances {
cfg.total_component_instances(limit);
}
if let Some(limit) = self.opts.pooling_total_memories {
cfg.total_memories(limit);
}
if let Some(limit) = self.opts.pooling_total_tables {
cfg.total_tables(limit);
}
if let Some(limit) = self.opts.pooling_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

0 comments on commit 480fb0e

Please # to comment.