Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into 'master'

feat(FI): FI-1314: Use ic_cdk::api::stable::stable64_size() instead of stable_size() for canister metrics

When determining the amount of stable memory used by the canister, call `ic_cdk::api::stable::stable64_size()` instead of `ic_cdk::api::stable::stable_size()` in order to support canisters that use more than 4GB. 

See merge request dfinity-lab/public/ic!19620
  • Loading branch information
mbjorkqvist committed Jun 4, 2024
2 parents 2c83ea8 + a5c8d79 commit c717533
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rs/bitcoin/ckbtc/kyt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ fn http_request(req: http::HttpRequest) -> http::HttpResponse {
writer
.encode_gauge(
"stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64 * 65536.0,
ic_cdk::api::stable::stable64_size() as f64 * 65536.0,
"Size of the stable memory allocated by this canister.",
)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/ckbtc/minter/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn encode_metrics(

metrics.encode_gauge(
"ckbtc_minter_stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
ic_cdk::api::stable::stable64_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
2 changes: 1 addition & 1 deletion rs/ethereum/cketh/minter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ fn http_request(req: HttpRequest) -> HttpResponse {
read_state(|s| {
w.encode_gauge(
"cketh_minter_stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
ic_cdk::api::stable::stable64_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
2 changes: 1 addition & 1 deletion rs/ethereum/ledger-suite-orchestrator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn http_request(

w.encode_gauge(
"ledger_suite_orchestrator_stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
ic_cdk::api::stable::stable64_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
4 changes: 2 additions & 2 deletions rs/rosetta-api/icp_ledger/index/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ fn get_oldest_tx_id(account_identifier: AccountIdentifier) -> Option<BlockIndex>
pub fn encode_metrics(w: &mut ic_metrics_encoder::MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
w.encode_gauge(
"index_stable_memory_pages",
ic_cdk::api::stable::stable_size() as f64,
ic_cdk::api::stable::stable64_size() as f64,
"Size of the stable memory allocated by this canister measured in 64K Wasm pages.",
)?;
w.encode_gauge(
"index_stable_memory_bytes",
(ic_cdk::api::stable::stable_size() * 64 * 1024) as f64,
(ic_cdk::api::stable::stable64_size() * 64 * 1024) as f64,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
4 changes: 2 additions & 2 deletions rs/rosetta-api/icrc1/archive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ fn __get_candid_interface_tmp_hack() -> &'static str {
fn encode_metrics(w: &mut ic_metrics_encoder::MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
w.encode_gauge(
"archive_stable_memory_pages",
ic_cdk::api::stable::stable_size() as f64,
ic_cdk::api::stable::stable64_size() as f64,
"Size of the stable memory allocated by this canister measured in 64K Wasm pages.",
)?;
w.encode_gauge(
"archive_stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64 * 65536f64,
ic_cdk::api::stable::stable64_size() as f64 * 65536f64,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
2 changes: 1 addition & 1 deletion rs/rosetta-api/icrc1/benchmark/generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn encode_metrics(
) -> std::io::Result<()> {
metrics.encode_gauge(
"icrc1_benchmark_generator_stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64,
ic_cdk::api::stable::stable64_size() as f64,
"Size of the stable memory allocated by this canister.",
)?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions rs/rosetta-api/icrc1/index-ng/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,12 +1107,12 @@ fn http_request(req: HttpRequest) -> HttpResponse {
pub fn encode_metrics(w: &mut ic_metrics_encoder::MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
w.encode_gauge(
"index_stable_memory_pages",
ic_cdk::api::stable::stable_size() as f64,
ic_cdk::api::stable::stable64_size() as f64,
"Size of the stable memory allocated by this canister measured in 64K Wasm pages.",
)?;
w.encode_gauge(
"index_stable_memory_bytes",
(ic_cdk::api::stable::stable_size() * 64 * 1024) as f64,
(ic_cdk::api::stable::stable64_size() * 64 * 1024) as f64,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
4 changes: 2 additions & 2 deletions rs/rosetta-api/icrc1/index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ fn get_oldest_txid(account: &Account) -> Option<Nat> {
pub fn encode_metrics(w: &mut ic_metrics_encoder::MetricsEncoder<Vec<u8>>) -> std::io::Result<()> {
w.encode_gauge(
"index_stable_memory_pages",
ic_cdk::api::stable::stable_size() as f64,
ic_cdk::api::stable::stable64_size() as f64,
"Size of the stable memory allocated by this canister measured in 64K Wasm pages.",
)?;
w.encode_gauge(
"index_stable_memory_bytes",
(ic_cdk::api::stable::stable_size() * 64 * 1024) as f64,
(ic_cdk::api::stable::stable64_size() * 64 * 1024) as f64,
"Size of the stable memory allocated by this canister.",
)?;

Expand Down
4 changes: 2 additions & 2 deletions rs/rosetta-api/tvl/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pub fn encode_metrics(w: &mut ic_metrics_encoder::MetricsEncoder<Vec<u8>>) -> st

w.encode_gauge(
"tvl_stable_memory_pages",
ic_cdk::api::stable::stable_size() as f64,
ic_cdk::api::stable::stable64_size() as f64,
"Size of the stable memory allocated by this canister measured in 64K Wasm pages.",
)?;
w.encode_gauge(
"tvl_stable_memory_bytes",
ic_cdk::api::stable::stable_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
ic_cdk::api::stable::stable64_size() as f64 * WASM_PAGE_SIZE_IN_BYTES,
"Size of the stable memory allocated by this canister.",
)?;
w.encode_gauge(
Expand Down

0 comments on commit c717533

Please sign in to comment.