spinframework / spinframework/spin

Should max_instance_memory limit each memory or the whole instance?

Open
#3,705 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
6.5k
Forks
310
Avg merge
1d 20h
Merged PRs (30d)
24

Description

Question

Should max_instance_memory limit the total linear memory used by one instance, or should it apply separately to each linear memory?

I expected it to limit the total. The current behavior matches Wasmtime's normal per-memory limit, so this may be a difference in interpretation rather than a bug.

Spin's help describes the limit as being "for an instance." The original PR chose this name to distinguish it from a whole-server limit. SKIP 006 also calls it a per-invocation limit. Neither discusses instances that contain several memories.

Current behavior

I tested a real component with two 65,536-byte memories. With max_instance_memory set to 65,536 bytes, Spin accepts both memories and reports 131,072 bytes used by the instance.

That is surprising for users who treat this setting as a firm limit on one instance.

Compatibility

A total limit would be stricter for components with several memories. Components with one memory would behave the same.

The low-level StoreBuilder::max_memory_size method has historically applied its limit to each memory. It could keep that behavior while max_instance_memory uses a separate total limit.

Which behavior does the project want for max_instance_memory, and should StoreBuilder::max_memory_size keep its current behavior? I am happy to submit the implementation and the real two-memory regression test once that choice is clear.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the original PR #3135 and SKIP 006, then inspect StoreBuilder::max_memory_size and reproduce the two-memory component behavior described here. The project must first decide whether max_instance_memory is a total or per-memory limit; done means the chosen semantics are implemented and covered by the proposed real two-memory regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.