Skip to content

Commit

Permalink
feat: Bump the state size limit to 1 TiB and stable memory limit to 5…
Browse files Browse the repository at this point in the history
…00 GiB (#2465)
  • Loading branch information
pakhomov-dfinity authored Nov 6, 2024
1 parent 43739c1 commit 41af49d
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 40 deletions.
3 changes: 2 additions & 1 deletion rs/config/src/execution_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{str::FromStr, time::Duration};

const MIB: u64 = 1024 * 1024;
const GIB: u64 = MIB * 1024;
const TIB: u64 = GIB * 1024;

/// This specifies the threshold in bytes at which the subnet memory usage is
/// considered to be high. If this value is greater or equal to the subnet
Expand All @@ -21,7 +22,7 @@ const SUBNET_MEMORY_THRESHOLD: NumBytes = NumBytes::new(450 * GIB);
/// Logical storage is the amount of storage being used from the point of view
/// of the canister. The actual storage used by the nodes can be higher as the
/// IC protocol requires storing copies of the canister state.
const SUBNET_MEMORY_CAPACITY: NumBytes = NumBytes::new(700 * GIB);
const SUBNET_MEMORY_CAPACITY: NumBytes = NumBytes::new(TIB);

/// This is the upper limit on how much memory can be used by all guaranteed
/// response canister messages on a given subnet.
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__app.snap
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ expression: out
i32.sub
)
(memory (;0;) 17)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__app2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__basic.snap
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ expression: out
i32.sub
)
(memory (;0;) 1)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__element.snap
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ expression: out
i32.sub
)
(table (;0;) 5 5 funcref)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i32) i32.const 0)
(global (;1;) i32 i32.const 1)
(global (;2;) i32 i32.const 2)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__fac.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__fizzbuzz.snap
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ expression: out
i32.sub
)
(memory (;0;) 1)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ expression: out
i32.sub
)
(memory (;0;) 1)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ expression: out
i32.sub
)
(memory (;0;) 17 100)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__nested_ifs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__recursive.snap
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ expression: out
i32.sub
)
(memory $memory (;0;) 1)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/tests/snapshots/instrumentation__start.snap
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ expression: out
)
(table (;0;) 0 1 funcref)
(memory (;0;) 1 1)
(memory (;1;) i64 0 6553600)
(memory (;2;) 1600 1600)
(memory (;1;) i64 0 8192000)
(memory (;2;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ expression: out
local.get 5
i32.sub
)
(memory (;0;) i64 0 6553600)
(memory (;1;) 1600 1600)
(memory (;0;) i64 0 8192000)
(memory (;1;) 2000 2000)
(global (;0;) (mut i64) i64.const 0)
(global (;1;) (mut i64) i64.const 0)
(global (;2;) (mut i64) i64.const 0)
Expand Down
4 changes: 2 additions & 2 deletions rs/rust_canisters/canister_creator/test/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ fn install_code_works() {
assert_eq!(result, WasmResult::Reply("null".as_bytes().to_vec()));

// Assert there are 1_001 canisters running with the memory usage below the
// subnet storage capacity, which is currently 700 GiB.
// subnet storage capacity, which is currently 1 TiB
assert_eq!(env.num_running_canisters(), 1_001);
assert!(
env.canister_memory_usage_bytes() < 700 * 1024 * 1024 * 1024,
env.canister_memory_usage_bytes() < 1024 * 1024 * 1024 * 1024,
"Actual: {} bytes",
env.canister_memory_usage_bytes()
);
Expand Down
6 changes: 3 additions & 3 deletions rs/types/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,17 +477,17 @@ pub struct InvalidMemoryAllocationError {
pub given: candid::Nat,
}

const GB: u64 = 1024 * 1024 * 1024;
const GIB: u64 = 1024 * 1024 * 1024;

/// The upper limit on the stable memory size.
/// This constant is used by other crates to define other constants, that's why
/// it is public and `u64` (`NumBytes` cannot be used in const expressions).
pub const MAX_STABLE_MEMORY_IN_BYTES: u64 = 400 * GB;
pub const MAX_STABLE_MEMORY_IN_BYTES: u64 = 500 * GIB;

/// The upper limit on the Wasm memory size.
/// This constant is used by other crates to define other constants, that's why
/// it is public and `u64` (`NumBytes` cannot be used in const expressions).
pub const MAX_WASM_MEMORY_IN_BYTES: u64 = 4 * GB;
pub const MAX_WASM_MEMORY_IN_BYTES: u64 = 4 * GIB;

const MIN_MEMORY_ALLOCATION: NumBytes = NumBytes::new(0);
pub const MAX_MEMORY_ALLOCATION: NumBytes =
Expand Down

0 comments on commit 41af49d

Please sign in to comment.