fitzgen opened PR #13080 from fitzgen:wasmtime-gc-heap-tunables to bytecodealliance:main:
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, andgc_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 andConfigmethods. 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 https://github.com/bytecodealliance/wasmtime/issues/11256
fitzgen requested wasmtime-fuzz-reviewers for a review on PR #13080.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13080.
fitzgen requested alexcrichton for a review on PR #13080.
fitzgen requested wasmtime-core-reviewers for a review on PR #13080.
fitzgen updated PR #13080.
alexcrichton created PR review comment:
I think that this is a duplication of
MemoryType's equivalent method. In the spirit of keeping things together, could this be refactored to share the same code there like I mentioned above?That might necessitate a
WhichTunables::{Memory,Gc}argument to some internal helper, but I'd imagine that public-facing methods (e.g.gc_heap_memory_may_movehere) would not take extra arguments and would just delegate internally
alexcrichton created PR review comment:
Personally I'm pretty hesitant to duplicate this sort of logic (same for
may_moveas aboolrather than a function call.Would it be possible to store a
MemoryTypewithin the heap itself, in addition to the guard/reservation as necessary? I'd ideally like to ensure that everything always unconditionally funnels thruogh theMemoryTypemethods so we've only got one place to look.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
This makes sense to me, but the user experience here is going to be pretty annoying on the CLI unfortunately. For example if you're manually twiddling things locally you might pass
-Opooling-allocatorand configure a guard size, and that'll fail with "ok but also pass the gc guard size".One option might be to broadcast all the memory options to the GC options by default (e.g. if GC opts aren't specified), but that has a minor downside of making it a bit surprising and difficult to test just memories in isolation (would require passing both memory/gc options). Another option is to broadcast the options only when the pooling allocator is enabled, but that also makes things pretty surprising.
Personally given the niche nature of these configuration options I'd lean towards broadcasting the memory options to the GC options by default. What do you think about that? (that wouldn't remove the need for this validation, it'd just improve the user experience IMO)
alexcrichton created PR review comment:
Could this and the above block be refactored as:
if signals_based_traps && pulley { if memory_needs_adjusting { /* .. */ } if gc_needs_adjusting { /* ... */ } }
github-actions[bot] added the label fuzzing on PR #13080.
github-actions[bot] added the label wasmtime:api on PR #13080.
github-actions[bot] added the label wasmtime:config on PR #13080.
github-actions[bot] commented on PR #13080:
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 <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
github-actions[bot] commented on PR #13080:
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
Configmethod, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
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.
```</details>
[ ] If you added a new
Configmethod, 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][fuzzing-config] (or one
of its nestedstructs).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</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.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
fitzgen edited a comment on PR #13080:
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
Configmethod, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
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.
```</details>
[x] If you added a new
Configmethod, 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][fuzzing-config] (or one
of its nestedstructs).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</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.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
fitzgen edited a comment on PR #13080:
Label Messager: wasmtime:config
It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:
[x] If you added a new
Configmethod, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
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.
```</details>
[x] If you added a new
Configmethod, 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][fuzzing-config] (or one
of its nestedstructs).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</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.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
fitzgen edited a comment on PR #13080:
Label Messager: wasmtime:config
It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:
[x] If you added a new
Configmethod, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
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.
```</details>
[x] If you added a new
Configmethod, 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][fuzzing-config] (or one
of its nestedstructs).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</details>
[x] 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.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
fitzgen updated PR #13080.
fitzgen commented on PR #13080:
@alexcrichton okay I created a
MemoryTunablestype that brings together aenum MemoryKind { LinearMemory, GcHeap }and a&Tunablesand then exposes methods to get eitherself.tunables.gc_heap_*orself.tunables.memory_*depending on theMemoryKind. Then I plumbed this through everywhere we were usingTunablesin 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 commented on PR #13080:
(Probably easiest to just view the diff against
main, rather than on a per-commit basis)
fitzgen updated PR #13080.
alexcrichton submitted PR review:
:+1:
alexcrichton added PR #13080 Add separate GC heap tunables to the merge queue.
github-merge-queue[bot] removed PR #13080 Add separate GC heap tunables from the merge queue.
fitzgen updated PR #13080.
fitzgen requested dicej for a review on PR #13080.
fitzgen requested wasmtime-default-reviewers for a review on PR #13080.
fitzgen updated PR #13080.
fitzgen has enabled auto merge for PR #13080.
fitzgen added PR #13080 Add separate GC heap tunables to the merge queue.
github-merge-queue[bot] removed PR #13080 Add separate GC heap tunables from the merge queue.
github-actions[bot] added the label winch on PR #13080.
fitzgen updated PR #13080.
fitzgen has enabled auto merge for PR #13080.
fitzgen added PR #13080 Add separate GC heap tunables to the merge queue.
fitzgen merged PR #13080.
fitzgen removed PR #13080 Add separate GC heap tunables from the merge queue.
Last updated: May 03 2026 at 22:13 UTC