Skip to content

Commit

Permalink
use only icrc3_get_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejdfinity committed Jan 10, 2025
1 parent 05549c0 commit 5686004
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 50 deletions.
20 changes: 8 additions & 12 deletions rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u256.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
benches:
bench_icrc1_transfers:
total:
instructions: 63359785465
heap_increase: 307
instructions: 58832813883
heap_increase: 271
stable_memory_increase: 256
scopes:
approvals:
instructions: 20413485760
heap_increase: 41
stable_memory_increase: 128
get_blocks:
instructions: 131091462
heap_increase: 32
stable_memory_increase: 0
icrc3_get_blocks:
instructions: 7825633
instructions: 7877258
heap_increase: 0
stable_memory_increase: 0
post_upgrade:
instructions: 383013664
heap_increase: 57
instructions: 354777092
heap_increase: 53
stable_memory_increase: 0
pre_upgrade:
instructions: 161987478
instructions: 149556765
heap_increase: 129
stable_memory_increase: 128
transfers:
Expand All @@ -34,8 +30,8 @@ benches:
heap_increase: 5
stable_memory_increase: 0
upgrade:
instructions: 545003475
heap_increase: 186
instructions: 504336032
heap_increase: 182
stable_memory_increase: 128
bench_upgrade_baseline:
total:
Expand Down
26 changes: 11 additions & 15 deletions rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u64.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
benches:
bench_icrc1_transfers:
total:
instructions: 61255319729
heap_increase: 307
instructions: 56837536044
heap_increase: 271
stable_memory_increase: 256
scopes:
approvals:
instructions: 19627513485
heap_increase: 29
stable_memory_increase: 128
get_blocks:
instructions: 124150117
heap_increase: 31
stable_memory_increase: 0
icrc3_get_blocks:
instructions: 7515525
instructions: 7540214
heap_increase: 0
stable_memory_increase: 0
post_upgrade:
instructions: 380882715
heap_increase: 58
instructions: 353134588
heap_increase: 53
stable_memory_increase: 0
pre_upgrade:
instructions: 161460494
instructions: 149315334
heap_increase: 129
stable_memory_increase: 128
transfers:
Expand All @@ -34,12 +30,12 @@ benches:
heap_increase: 18
stable_memory_increase: 0
upgrade:
instructions: 542345542
heap_increase: 187
instructions: 502452097
heap_increase: 182
stable_memory_increase: 128
bench_upgrade_baseline:
total:
instructions: 8683394
instructions: 8683414
heap_increase: 258
stable_memory_increase: 128
scopes:
Expand All @@ -48,11 +44,11 @@ benches:
heap_increase: 129
stable_memory_increase: 0
pre_upgrade:
instructions: 76683
instructions: 76703
heap_increase: 129
stable_memory_increase: 128
upgrade:
instructions: 8682705
instructions: 8682725
heap_increase: 258
stable_memory_increase: 128
version: 0.1.8
17 changes: 6 additions & 11 deletions rs/ledger_suite/icrc1/ledger/src/benches/benches_u256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
assert_has_num_balances, emulate_archive_blocks, icrc_transfer, max_length_principal,
mint_tokens, upgrade, NUM_APPROVALS, NUM_GET_BLOCKS, NUM_TRANSFERS, NUM_TRANSFERS_FROM,
},
get_blocks, icrc2_approve_not_async, icrc3_get_blocks, init_state, Access, Account, LOG,
icrc2_approve_not_async, icrc3_get_blocks, init_state, Access, Account, LOG,
};
use assert_matches::assert_matches;
use canbench_rs::{bench, BenchResult};
Expand Down Expand Up @@ -111,19 +111,14 @@ fn bench_icrc1_transfers() -> BenchResult {
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 req = GetBlocksRequest {
start: Nat::from(NUM_TRANSFERS_FROM + NUM_TRANSFERS + NUM_APPROVALS),
length: Nat::from(NUM_GET_BLOCKS),
};
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`
assert_eq!(blocks_res.blocks.len(), NUM_GET_BLOCKS as usize);
}
upgrade();
})
Expand Down
17 changes: 6 additions & 11 deletions rs/ledger_suite/icrc1/ledger/src/benches/benches_u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::benches::{
assert_has_num_balances, emulate_archive_blocks, icrc_transfer, max_length_principal,
mint_tokens, upgrade, NUM_APPROVALS, NUM_GET_BLOCKS, NUM_TRANSFERS, NUM_TRANSFERS_FROM,
};
use crate::{get_blocks, icrc2_approve_not_async, icrc3_get_blocks, init_state, Access, LOG};
use crate::{icrc2_approve_not_async, icrc3_get_blocks, init_state, Access, LOG};
use assert_matches::assert_matches;
use canbench_rs::{bench, BenchResult};
use candid::{Nat, Principal};
Expand Down Expand Up @@ -110,19 +110,14 @@ fn bench_icrc1_transfers() -> BenchResult {
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 req = GetBlocksRequest {
start: Nat::from(NUM_TRANSFERS_FROM + NUM_TRANSFERS + NUM_APPROVALS),
length: Nat::from(NUM_GET_BLOCKS),
};
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`
assert_eq!(blocks_res.blocks.len(), NUM_GET_BLOCKS as usize);
}
upgrade();
})
Expand Down
2 changes: 1 addition & 1 deletion rs/ledger_suite/icrc1/ledger/src/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +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 const NUM_GET_BLOCKS: u32 = 100;

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

0 comments on commit 5686004

Please sign in to comment.