Skip to content

optimize Wasmtime engine configuration for performance improvements#121

Merged
ruslanti merged 3 commits intomainfrom
feat/wasmtime_engine_config_opts
Apr 6, 2026
Merged

optimize Wasmtime engine configuration for performance improvements#121
ruslanti merged 3 commits intomainfrom
feat/wasmtime_engine_config_opts

Conversation

@ruslanti
Copy link
Copy Markdown
Collaborator

@ruslanti ruslanti commented Apr 6, 2026

…ents

@ruslanti ruslanti requested a review from Copilot April 6, 2026 11:59
@ruslanti ruslanti self-assigned this Apr 6, 2026
@ruslanti ruslanti added the enhancement New feature or request label Apr 6, 2026
@ruslanti ruslanti changed the title optimize Wasmtime engine configuration for performance improvem… optimize Wasmtime engine configuration for performance improvements Apr 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve Wasmtime runtime performance by tuning the engine and pooling allocator configuration, and bumps the workspace version.

Changes:

  • Configure Wasmtime with explicit Cranelift optimization level and disable address-map generation.
  • Expand pooling allocator limits (tables/memories per module) and add keep-resident + decommit batching tuning.
  • Bump workspace/package versions from 0.15.0 → 0.15.1 (including Cargo.lock).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.

File Description
crates/runtime/src/lib.rs Adds Wasmtime Config and pooling allocator performance tuning in WasmConfigBuilder::build().
Cargo.toml Bumps workspace version to 0.15.1.
Cargo.lock Updates workspace crate versions to 0.15.1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +308 to +312
// Avoids madvise(MADV_DONTNEED) syscalls when a pooled slot is reused, replacing them
// with a cheaper memset up to the threshold — reducing per-request deallocation latency.
pooling_allocation_config.linear_memory_keep_resident(2 * MB);
pooling_allocation_config.table_keep_resident(512 * 1024);

Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

With the per-module maxima increased, the keep-resident thresholds (linear_memory_keep_resident, table_keep_resident) can materially increase steady-state RSS for warm pooled instances (threshold × number of memories/tables × warm slots). If this is intended, it would be safer to make these thresholds configurable/tunable or keep the per-module maxima conservative to avoid unexpected memory growth under load.

Copilot uses AI. Check for mistakes.
Comment on lines +302 to +303
pooling_allocation_config.max_tables_per_module(10);
pooling_allocation_config.max_memories_per_module(10);
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

max_tables_per_module(10) / max_memories_per_module(10) can require substantially higher pool capacity. When max_execution_stacks is set, this builder still sizes total_tables(total) and total_memories(total) to total, which may underprovision if modules actually use >1 table/memory and cause instantiation failures due to pool exhaustion. Consider scaling pool totals accordingly (or keeping per-module maxima at 1 unless required).

Copilot uses AI. Check for mistakes.
ruslanti and others added 2 commits April 6, 2026 15:06
configured by env generate address map

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
revert dumping version

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ruslanti ruslanti requested a review from qrdl April 6, 2026 12:10
@ruslanti ruslanti marked this pull request as ready for review April 6, 2026 12:10
@ruslanti ruslanti merged commit d12e378 into main Apr 6, 2026
1 of 3 checks passed
@ruslanti ruslanti deleted the feat/wasmtime_engine_config_opts branch April 6, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants