Skip to content

Commit e2d622c

Browse files
authored
feat: increase MAX_MEMORY_SIZE from ~1 GiB to ~16 GiB (#1340)
The previous limit of 0x4000_0000 - BASE_ADDRESS (~1 GiB) was arbitrary and insufficient for some nanvix related cases. Bump to (16 GiB - BASE_ADDRESS) which is large enough for most use cases while still preventing accidental resource exhaustion. The BASE_ADDRESS subtraction is preserved for consistency with the original definition. Update test to validate the new ~16 GiB boundary. Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent 7b06312 commit e2d622c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/hyperlight_host/src/mem/layout.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,10 @@ impl Debug for SandboxMemoryLayout {
170170
impl SandboxMemoryLayout {
171171
/// The maximum amount of memory a single sandbox will be allowed.
172172
///
173-
/// Currently, both the scratch region and the snapshot region are
174-
/// bounded by this size. The current value is essentially
175-
/// arbitrary and chosen for historical reasons; the modern
176-
/// sandbox virtual memory layout can support much more, so this
177-
/// could be increased should use cases for larger sandboxes
178-
/// arise.
179-
const MAX_MEMORY_SIZE: usize = 0x4000_0000 - Self::BASE_ADDRESS;
173+
/// Both the scratch region and the snapshot region are bounded by
174+
/// this size. The value is arbitrary but chosen to be large enough
175+
/// for most workloads while preventing accidental resource exhaustion.
176+
const MAX_MEMORY_SIZE: usize = (16 * 1024 * 1024 * 1024) - Self::BASE_ADDRESS; // 16 GiB - BASE_ADDRESS
180177

181178
/// The base address of the sandbox's memory.
182179
#[cfg(not(feature = "nanvix-unstable"))]
@@ -690,8 +687,9 @@ mod tests {
690687
#[test]
691688
fn test_max_memory_sandbox() {
692689
let mut cfg = SandboxConfiguration::default();
693-
cfg.set_scratch_size(0x40004000);
694-
cfg.set_input_data_size(0x40000000);
690+
// scratch_size exceeds 16 GiB limit
691+
cfg.set_scratch_size(17 * 1024 * 1024 * 1024);
692+
cfg.set_input_data_size(16 * 1024 * 1024 * 1024);
695693
let layout = SandboxMemoryLayout::new(cfg, 4096, 4096, None);
696694
assert!(matches!(layout.unwrap_err(), MemoryRequestTooBig(..)));
697695
}

0 commit comments

Comments
 (0)