Skip to content

GC: Allow single-byte memory pages #14523

Open

Description

@simolus3

Feature

Wasmtime supports 1-byte pages for linear memory via the custom-page-sizes proposal, but the GC heap wasmtime uses unconditionally needs 64KiB pages for its backing memory.

Benefit

The motivation for that proposal includes:

Allow Wasm to better target resource-constrained embedded environments, including those with less than 64 KiB memory available.

This is an environment I want to target, except that my modules use GC instead of linear memory.

Implementation

Given that linear memories already support 1-byte pages, adding a tunable + config to support this for GC heaps as well isn't that complicated. While testing, I noticed a few issues where the bytes to grow the heap didn't take alignment into consideration. This is masked by 64KiB pages, but requires minor extra fixes.

I'm happy to open a PR for this if this sounds like a feature worth having.

Alternatives

Maybe there could also be an option to supply a pre-allocated buffer to use as a GC heap instead; that is generally easier to allocate at once. But given that the buffer would likely not have a multiple of 64KiB as a size, I think we still need one-byte pages for that.

Activity

  1. pchickey commented on Oct 5, 2026

    @pchickey
    Contributor

    Tagging @fitzgen

  2. fitzgen commented on Oct 6, 2026

    @fitzgen
    Member

    Adding a tunable+config knob for the GC heap page size seems reasonable to me.

    The most conservative thing to do would be to only allow 1B and 64KiB page sizes. However, we could in theory allow for any power of two (e.g. the platform's natural page size), but this would require checking that all of our memory growth and size and all that code handles this correctly (which it generally should, modulo a few asserts that would become outdated). Easy to do the conservative thing first and the other bit after that.

    Maybe there could also be an option to supply a pre-allocated buffer to use as a GC heap instead

    I think that we use the MemoryCreator, if one is configured, for GC heaps' memories. If we don't we should. But either way, the page size changes code generation (which bounds checks can be elided or not) so bringing your own memory on its own is not enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementwasm-proposal:gcIssues with the implementation of the gc wasm proposal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions