0

In sp-core it is defined the maximum memory that can be allocated by the runtime. The current max possible allocation is 32 MiB:

// substrate/primitives/core/src/lib.rs (snip)

/// The maximum number of bytes that can be allocated at one time.
// The maximum possible allocation size was chosen rather arbitrary, 32 MiB should be enough for
// everybody.
pub const MAX_POSSIBLE_ALLOCATION: u32 = 33554432; // 2^25 bytes, 32 MiB

Although the comments state that the 32MiB limit is arbitrary, I wonder if there is any reason to limit the WASM allocation memory so much given that the limit imposed by WASM is 4GiB?

As a follow-up question, is there anything preventing us from increasing this value further if needed?

2
  • I can think of a couple of reasons for the limit to be this low: 1. make sure the spec requirements for validators remain low and 2. the idea that if a blockchain runtime requires too much memory to compute a block, probably the runtime implementation should be optimised or broken down into multiple blocks.
    – gpestana
    Commented Sep 3 at 9:40
  • I think the number is pretty arbitrary, but remember also we can't simply just use the "max limit" as a Polkadot SDK node may have multiple wasm instances running at once. For example, syncing multiple forks at once, contracts being run, etc etc... so increasing the memory limit here to something like 4 GB would actually make running a node require much more than that.
    – Shawn Tabrizi
    Commented Sep 6 at 16:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.