Skip to content

fix(wasm): lift hostcall fuel limit for large component outputs - #111

Merged
oglassdev merged 1 commit into
mainfrom
fix/hostcall-fuel
Oct 6, 2026
Merged

oglassdev merged 1 commit into
mainfrom
fix/hostcall-fuel

Conversation

@oglassdev

Copy link
Copy Markdown
Contributor

Fixes #97.

Wasmtime's default hostcall fuel (128 MiB) charges a whole Val (32 bytes) for each lifted list element. That capped a component call's list<u8> output at about 4 MiB. Window builds hit the cap somewhere between 10x and 12x the jsx golden case and failed with fuel allocated for hostcalls has been exhausted.

new_store now sets hostcall fuel to memory_bytes × size_of::<Val>(). That's the cost of lifting the largest list<u8> that fits in guest memory, so any real output can be returned. Lists that alias the same guest buffer still hit a finite cap, which wouldn't hold with usize::MAX.

  • Fuel resets for each lift, so reused stores don't run out over time. Host→guest arguments aren't charged.
  • new_store is the only place stores are created.
  • The new test lifts_byte_list_beyond_default_hostcall_fuel lifts 5 MiB through a new bytes export on the fixture. It fails without the fix.

Window bench/authoring cold builds, which failed at 12x/15x before this change:

Scale jsx wall / build (ms) fn wall / build (ms)
12x 310 / 241 302 / 234
15x 366 / 286 359 / 289
30x 620 / 517 597 / 504

Each lifted byte still costs about 32 bytes of host memory. A typed byte-list fast path is listed in chunkzero/window#58.

🤖 Generated with Claude Code

Wasmtime's default hostcall fuel (128 MiB) charges a whole `Val` per lifted
list element, capping a single call's `list<u8>` output at about 4 MiB and
failing large Window builds with "fuel allocated for hostcalls has been
exhausted". Scale the fuel by the store's memory limit so any output that
fits in guest memory can be lifted, while aliased lists stay bounded.

Fixes #97
@oglassdev
oglassdev merged commit 283c4a1 into main Oct 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rpp-wasm: large component results exhaust wasmtime's hostcall fuel

1 participant