Skip to main content

MAX_SHARDS

Constant MAX_SHARDS 

Source
pub const MAX_SHARDS: usize = _; // 65_536usize
Expand description

Largest shard count any arena may be configured with.

A shard count arrives from an untrusted snapshot, and Arena::new turns it straight into three vectors plus a page pool — so it is an allocation size taken from a file, and those need a ceiling. This one is derived, not picked:

  • MAX_SHARDS * PAGE_BYTES is 256 MiB, which fits a 32-bit usize, so page arithmetic cannot overflow on wasm32;
  • per-shard runtime metadata stays bounded at MAX_SHARDS * SHARD_META_BYTES (768 KiB) per arena;
  • it cannot bind on a database that can actually exist: the default 2 GiB pool ceiling at SHARD_TARGET_BYTES per shard justifies at most 2 GiB / SHARD_TARGET_BYTES ≈ 43690 shards, which rounds up to exactly this value. Anything larger describes a database no pool could hold.