Skip to content

Compilation parameter: number of linear-memory pages to allocate (Inference.toml + CLI) #210

@0xGeorgii

Description

@0xGeorgii

Summary

Provide a compilation parameter that sets the number of WebAssembly linear-memory pages a program allocates at startup. Today this is hardcoded.

Today codegen declares linear memory as a fixed single page and never grows it:

// core/wasm-codegen/src/compiler.rs
memory_section.memory(MemoryType {
    minimum: 1,
    maximum: Some(1),   // exactly one 64 KiB page, fixed — no memory.grow
    ...
});

Proposal

Allow the page count to be specified per project/build, surfaced two ways:

  1. Project manifest — an Inference.toml key (e.g. under a [build] / [memory] table, pages = N).
  2. CLI parameter — a flag on infs build (and infc) that overrides the manifest value for a single build.

Codegen would then emit MemoryType { minimum: N, maximum: Some(N) } (fixed, no growth) so the memory footprint stays deterministic and reproducible. The resolved page count becomes the budget consumed by the footprint check in the companion issue.

Notes / open questions

  • Default stays at 1 page when unset, preserving current behaviour and byte-identical output.
  • Decide the precedence order (CLI overrides manifest overrides default) and the key name/location in Inference.toml.
  • Keep minimum == maximum (fixed, non-growable) to retain the "no memory.grow, deterministic footprint" property; a growable variant would be a separate decision.

Relationship

  • Feeds the budget for the memory-footprint static check (companion issue).
  • Context: spun out of the array-bounds work in Array Bounds Checking #164 during a design discussion on memory safety.

Future work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCommand line interface relatedcodegenBytecode emittinginfsInference Start relatedmemory managementRelated to how memory is tracked and manipulated

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions