Skip to content

Add separate GC heap tunables#13080

Merged
fitzgen merged 8 commits intobytecodealliance:mainfrom
fitzgen:wasmtime-gc-heap-tunables
Apr 14, 2026
Merged

Add separate GC heap tunables#13080
fitzgen merged 8 commits intobytecodealliance:mainfrom
fitzgen:wasmtime-gc-heap-tunables

Conversation

@fitzgen
Copy link
Copy Markdown
Member

@fitzgen fitzgen commented Apr 13, 2026

Before this commit, the GC heap used a memory with identical tunables as regular Wasm linear memories.

After this commit, the GC heap now uses a memory with its own tunables (gc_heap_reservation, gc_heap_guard_size, gc_heap_reservation_for_growth, and gc_heap_may_move) so that GC heaps can be configured independently from linear memories. These new GC heap tunables are also exposed as CLI flags and Config methods. We also generate pseudorandom values for these tunables in our fuzzing config generator.

The pooling allocator uses the same pool for memories and GC heaps, so we validate that if you are using GC and the pooling allocator, then the new tunables must match the memory tunables.

cc #11256

@fitzgen fitzgen requested review from a team as code owners April 13, 2026 20:15
@fitzgen fitzgen requested review from alexcrichton and removed request for a team April 13, 2026 20:15
Comment thread crates/cranelift/src/bounds_checks.rs Outdated
Comment thread crates/environ/src/tunables.rs Outdated
Comment thread crates/fuzzing/src/generators/config.rs Outdated
Comment thread crates/wasmtime/src/config.rs
@github-actions github-actions bot added fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown

Subscribe to Label Action

cc @fitzgen

Details This issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:config"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

  • If you added a new Config method, you wrote extensive documentation for
    it.

    Details

    Our documentation should be of the following form:

    Short, simple summary sentence.
    
    More details. These details can be multiple paragraphs. There should be
    information about not just the method, but its parameters and results as
    well.
    
    Is this method fallible? If so, when can it return an error?
    
    Can this method panic? If so, when does it panic?
    
    # Example
    
    Optional example here.
    
  • If you added a new Config method, or modified an existing one, you
    ensured that this configuration is exercised by the fuzz targets.

    Details

    For example, if you expose a new strategy for allocating the next instance
    slot inside the pooling allocator, you should ensure that at least one of our
    fuzz targets exercises that new strategy.

    Often, all that is required of you is to ensure that there is a knob for this
    configuration option in wasmtime_fuzzing::Config (or one
    of its nested structs).

    Rarely, this may require authoring a new fuzz target to specifically test this
    configuration. See our docs on fuzzing for more details.

  • If you are enabling a configuration option by default, make sure that it
    has been fuzzed for at least two weeks before turning it on by default.


Details

To modify this label's message, edit the .github/label-messager/wasmtime-config.md file.

To add new label messages or remove existing label messages, edit the
.github/label-messager.json configuration file.

Learn more.

fitzgen added 3 commits April 14, 2026 07:02
Before this commit, the GC heap used a memory with identical tunables as regular
Wasm linear memories.

After this commit, the GC heap now uses a memory with its own
tunables (`gc_heap_reservation`, `gc_heap_guard_size`,
`gc_heap_reservation_for_growth`, and `gc_heap_may_move`) so that GC heaps can
be configured independently from linear memories. These new GC heap tunables are
also exposed as CLI flags and `Config` methods. We also generate pseudorandom
values for these tunables in our fuzzing config generator.

The pooling allocator uses the same pool for memories and GC heaps, so we
validate that if you are using GC and the pooling allocator, then the new
tunables must match the memory tunables.
@fitzgen fitzgen force-pushed the wasmtime-gc-heap-tunables branch from 2c290c2 to 24d0484 Compare April 14, 2026 14:03
@fitzgen
Copy link
Copy Markdown
Member Author

fitzgen commented Apr 14, 2026

@alexcrichton okay I created a MemoryTunables type that brings together a enum MemoryKind { LinearMemory, GcHeap } and a &Tunables and then exposes methods to get either self.tunables.gc_heap_* or self.tunables.memory_* depending on the MemoryKind. Then I plumbed this through everywhere we were using Tunables in memory-related code. The hope is that this should make it so that we can't ever access the wrong tunable, and have completely unified handling/code paths with no duplication between GC heap vs linear memory.

Mind taking another look?

@fitzgen
Copy link
Copy Markdown
Member Author

fitzgen commented Apr 14, 2026

(Probably easiest to just view the diff against main, rather than on a per-commit basis)

Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

👍

@alexcrichton alexcrichton added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@fitzgen fitzgen requested a review from a team as a code owner April 14, 2026 15:44
@fitzgen fitzgen requested review from dicej and removed request for a team April 14, 2026 15:44
@fitzgen fitzgen enabled auto-merge April 14, 2026 15:45
@fitzgen fitzgen added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@github-actions github-actions bot added the winch Winch issues or pull requests label Apr 14, 2026
@fitzgen fitzgen enabled auto-merge April 14, 2026 17:25
@fitzgen fitzgen added this pull request to the merge queue Apr 14, 2026
Merged via the queue into bytecodealliance:main with commit 13b6270 Apr 14, 2026
48 checks passed
@fitzgen fitzgen deleted the wasmtime-gc-heap-tunables branch April 14, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime winch Winch issues or pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants