Skip to content

Commit

Permalink
get_blocks and new yml
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejdfinity committed Jan 10, 2025
1 parent b457824 commit 05549c0
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 38 deletions.
48 changes: 32 additions & 16 deletions rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u256.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
benches:
bench_icrc1_transfers:
total:
instructions: 13798815361
heap_increase: 172
stable_memory_increase: 128
instructions: 63359785465
heap_increase: 307
stable_memory_increase: 256
scopes:
before_upgrade:
instructions: 13630531777
heap_increase: 43
approvals:
instructions: 20413485760
heap_increase: 41
stable_memory_increase: 128
get_blocks:
instructions: 131091462
heap_increase: 32
stable_memory_increase: 0
post_upgrade:
instructions: 118601062
icrc3_get_blocks:
instructions: 7825633
heap_increase: 0
stable_memory_increase: 0
post_upgrade:
instructions: 383013664
heap_increase: 57
stable_memory_increase: 0
pre_upgrade:
instructions: 49679478
instructions: 161987478
heap_increase: 129
stable_memory_increase: 128
transfers:
instructions: 13635001695
heap_increase: 43
stable_memory_increase: 0
transfers_from:
instructions: 24042619927
heap_increase: 5
stable_memory_increase: 0
upgrade:
instructions: 168282130
heap_increase: 129
instructions: 545003475
heap_increase: 186
stable_memory_increase: 128
bench_upgrade_baseline:
total:
instructions: 8684974
instructions: 8684182
heap_increase: 258
stable_memory_increase: 128
scopes:
post_upgrade:
instructions: 8606422
instructions: 8605997
heap_increase: 129
stable_memory_increase: 0
pre_upgrade:
instructions: 76145
instructions: 75778
heap_increase: 129
stable_memory_increase: 128
upgrade:
instructions: 8684285
instructions: 8683493
heap_increase: 258
stable_memory_increase: 128
version: 0.1.7
version: 0.1.8
48 changes: 32 additions & 16 deletions rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u64.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
benches:
bench_icrc1_transfers:
total:
instructions: 13237283790
heap_increase: 171
stable_memory_increase: 128
instructions: 61255319729
heap_increase: 307
stable_memory_increase: 256
scopes:
before_upgrade:
instructions: 13068913917
heap_increase: 42
approvals:
instructions: 19627513485
heap_increase: 29
stable_memory_increase: 128
get_blocks:
instructions: 124150117
heap_increase: 31
stable_memory_increase: 0
post_upgrade:
instructions: 118797275
icrc3_get_blocks:
instructions: 7515525
heap_increase: 0
stable_memory_increase: 0
post_upgrade:
instructions: 380882715
heap_increase: 58
stable_memory_increase: 0
pre_upgrade:
instructions: 49569466
instructions: 161460494
heap_increase: 129
stable_memory_increase: 128
transfers:
instructions: 13071791984
heap_increase: 42
stable_memory_increase: 0
transfers_from:
instructions: 23404082941
heap_increase: 18
stable_memory_increase: 0
upgrade:
instructions: 168368331
heap_increase: 129
instructions: 542345542
heap_increase: 187
stable_memory_increase: 128
bench_upgrade_baseline:
total:
instructions: 8686052
instructions: 8683394
heap_increase: 258
stable_memory_increase: 128
scopes:
post_upgrade:
instructions: 8606533
instructions: 8604304
heap_increase: 129
stable_memory_increase: 0
pre_upgrade:
instructions: 77112
instructions: 76683
heap_increase: 129
stable_memory_increase: 128
upgrade:
instructions: 8685363
instructions: 8682705
heap_increase: 258
stable_memory_increase: 128
version: 0.1.7
version: 0.1.8
38 changes: 35 additions & 3 deletions rs/ledger_suite/icrc1/ledger/src/benches/benches_u256.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use crate::{
benches::{
assert_has_num_balances, emulate_archive_blocks, icrc_transfer, max_length_principal,
mint_tokens, upgrade, NUM_APPROVALS, NUM_TRANSFERS, NUM_TRANSFERS_FROM,
mint_tokens, upgrade, NUM_APPROVALS, NUM_GET_BLOCKS, NUM_TRANSFERS, NUM_TRANSFERS_FROM,
},
icrc2_approve_not_async, init_state, Access, Account, LOG,
get_blocks, icrc2_approve_not_async, icrc3_get_blocks, init_state, Access, Account, LOG,
};
use assert_matches::assert_matches;
use canbench_rs::{bench, BenchResult};
use candid::Principal;
use candid::{Nat, Principal};
use ic_icrc1_ledger::{FeatureFlags, InitArgs, InitArgsBuilder};
use ic_ledger_canister_core::archive::ArchiveOptions;
use icrc_ledger_types::icrc1::transfer::TransferArg;
use icrc_ledger_types::icrc2::approve::ApproveArgs;
use icrc_ledger_types::icrc3::blocks::GetBlocksRequest;

const MINTER_PRINCIPAL: Principal = Principal::from_slice(&[0_u8, 0, 0, 0, 2, 48, 0, 156, 1, 1]);

Expand Down Expand Up @@ -93,6 +94,37 @@ fn bench_icrc1_transfers() -> BenchResult {
}
assert_has_num_balances(NUM_TRANSFERS_FROM + NUM_TRANSFERS + 2);
}
for i in 0..NUM_GET_BLOCKS {
let spender = Account {
owner: max_length_principal(i),
subaccount: Some([11_u8; 32]),
};
let transfer = TransferArg {
from_subaccount: account_with_tokens.subaccount,
to: Account {
owner: max_length_principal(1_000_000_000 + i),
subaccount: Some([11_u8; 32]),
},
created_at_time: Some(1_000_000_000 + start_time + i as u64),
..cketh_transfer()
};
let result = icrc_transfer(account_with_tokens.owner, Some(spender), transfer.clone());
assert_matches!(result, Ok(_));
}
let req = GetBlocksRequest {
start: Nat::from(NUM_TRANSFERS_FROM + NUM_TRANSFERS + NUM_APPROVALS),
length: Nat::from(NUM_GET_BLOCKS),
};
{
let _p = canbench_rs::bench_scope("get_blocks");
let blocks_res = get_blocks(req.clone());
assert_eq!(blocks_res.blocks.len(), NUM_GET_BLOCKS as usize);
}
{
let _p = canbench_rs::bench_scope("icrc3_get_blocks");
let blocks_res = icrc3_get_blocks(vec![req]);
assert_eq!(blocks_res.blocks.len(), 100usize); // this is the max for `icrc3_get_blocks`
}
upgrade();
})
}
Expand Down
38 changes: 35 additions & 3 deletions rs/ledger_suite/icrc1/ledger/src/benches/benches_u64.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use crate::benches::{
assert_has_num_balances, emulate_archive_blocks, icrc_transfer, max_length_principal,
mint_tokens, upgrade, NUM_APPROVALS, NUM_TRANSFERS, NUM_TRANSFERS_FROM,
mint_tokens, upgrade, NUM_APPROVALS, NUM_GET_BLOCKS, NUM_TRANSFERS, NUM_TRANSFERS_FROM,
};
use crate::{icrc2_approve_not_async, init_state, Access, LOG};
use crate::{get_blocks, icrc2_approve_not_async, icrc3_get_blocks, init_state, Access, LOG};
use assert_matches::assert_matches;
use canbench_rs::{bench, BenchResult};
use candid::Principal;
use candid::{Nat, Principal};
use ic_icrc1_ledger::{FeatureFlags, InitArgs, InitArgsBuilder};
use ic_ledger_canister_core::archive::ArchiveOptions;
use icrc_ledger_types::icrc1::account::Account;
use icrc_ledger_types::icrc1::transfer::TransferArg;
use icrc_ledger_types::icrc2::approve::ApproveArgs;
use icrc_ledger_types::icrc3::blocks::GetBlocksRequest;

const MINTER_PRINCIPAL: Principal = Principal::from_slice(&[0_u8, 0, 0, 0, 2, 48, 0, 7, 1, 1]);

Expand Down Expand Up @@ -92,6 +93,37 @@ fn bench_icrc1_transfers() -> BenchResult {
}
assert_has_num_balances(NUM_TRANSFERS_FROM + NUM_TRANSFERS + 2);
}
for i in 0..NUM_GET_BLOCKS {
let spender = Account {
owner: max_length_principal(i),
subaccount: Some([11_u8; 32]),
};
let transfer = TransferArg {
from_subaccount: account_with_tokens.subaccount,
to: Account {
owner: max_length_principal(1_000_000_000 + i),
subaccount: Some([11_u8; 32]),
},
created_at_time: Some(1_000_000_000 + start_time + i as u64),
..ckbtc_transfer()
};
let result = icrc_transfer(account_with_tokens.owner, Some(spender), transfer.clone());
assert_matches!(result, Ok(_));
}
let req = GetBlocksRequest {
start: Nat::from(NUM_TRANSFERS_FROM + NUM_TRANSFERS + NUM_APPROVALS),
length: Nat::from(NUM_GET_BLOCKS),
};
{
let _p = canbench_rs::bench_scope("get_blocks");
let blocks_res = get_blocks(req.clone());
assert_eq!(blocks_res.blocks.len(), NUM_GET_BLOCKS as usize);
}
{
let _p = canbench_rs::bench_scope("icrc3_get_blocks");
let blocks_res = icrc3_get_blocks(vec![req]);
assert_eq!(blocks_res.blocks.len(), 100usize); // this is the max for `icrc3_get_blocks`
}
upgrade();
})
}
Expand Down
1 change: 1 addition & 0 deletions rs/ledger_suite/icrc1/ledger/src/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod benches_u64;
pub const NUM_TRANSFERS: u32 = 10_000;
pub const NUM_APPROVALS: u32 = 10_000;
pub const NUM_TRANSFERS_FROM: u32 = 10_000;
pub const NUM_GET_BLOCKS: u32 = 2_000;

pub fn upgrade() {
let _p = canbench_rs::bench_scope("upgrade");
Expand Down

0 comments on commit 05549c0

Please sign in to comment.