From 4a3b93a3977f14b29cbf74fef910d2d5243966c2 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 11:44:05 +0200 Subject: [PATCH 01/25] compare btreemap vs stable memory --- benchmarks/btreemap/src/main.rs | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 6c348ca2..ad258a6a 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -785,4 +785,51 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { }) } +use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; +const SIZE: usize = 100 * 1024 * 1024; // 100MB +const CHUNK: usize = 4 * 1024; // 4KiB +const VALUE: u8 = 37; + +#[bench] +fn stable_memory_write_100mb() { + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(1)); + let buf = vec![VALUE; SIZE]; + + bench_fn(|| { + let required = ((SIZE + WASM_PAGE_SIZE_IN_BYTES - 1) / WASM_PAGE_SIZE_IN_BYTES) as u64; + if memory.size() < required { + memory.grow(required - memory.size()); + } + memory.write(0, &buf); + }); +} + +#[bench] +fn btreemap_write_100mb_single_chunk() { + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(2)); + let mut map = BTreeMap::init(memory); + let buf = vec![VALUE; SIZE]; + + bench_fn(|| { + map.insert(0_u32, buf); + }); +} + +#[bench] +fn btreemap_write_100mb_chunked() { + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(3)); + let mut map = BTreeMap::init(memory); + + let chunks: Vec> = vec![VALUE; SIZE] + .chunks(CHUNK) + .map(|chunk| chunk.to_vec()) + .collect(); + + bench_fn(|| { + for (i, chunk) in chunks.into_iter().enumerate() { + map.insert(i as u32, chunk); + } + }); +} + fn main() {} From 12f13e73dac2e9c627ee8ab5a4b080030bb545e2 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 11:44:59 +0200 Subject: [PATCH 02/25] . --- benchmarks/btreemap/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index ad258a6a..32c215e4 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -796,7 +796,7 @@ fn stable_memory_write_100mb() { let buf = vec![VALUE; SIZE]; bench_fn(|| { - let required = ((SIZE + WASM_PAGE_SIZE_IN_BYTES - 1) / WASM_PAGE_SIZE_IN_BYTES) as u64; + let required = SIZE.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64; if memory.size() < required { memory.grow(required - memory.size()); } From 5e35fc65df3dea94e8fd6f78ea030bb2e03cd033 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 11:56:49 +0200 Subject: [PATCH 03/25] . --- benchmarks/btreemap/src/main.rs | 81 +++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 32c215e4..fb1779f3 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,17 +786,21 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; + const SIZE: usize = 100 * 1024 * 1024; // 100MB -const CHUNK: usize = 4 * 1024; // 4KiB const VALUE: u8 = 37; +fn page_align(bytes: usize) -> u64 { + bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64 +} + #[bench] -fn stable_memory_write_100mb() { +fn write_stable_1_elem() { let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(1)); let buf = vec![VALUE; SIZE]; bench_fn(|| { - let required = SIZE.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64; + let required = page_align(SIZE); if memory.size() < required { memory.grow(required - memory.size()); } @@ -805,24 +809,83 @@ fn stable_memory_write_100mb() { } #[bench] -fn btreemap_write_100mb_single_chunk() { +fn write_stable_1k_elems() { + const N: usize = 1_000; let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(2)); + let chunk_size = SIZE / N; + let chunks: Vec> = vec![VALUE; SIZE] + .chunks(chunk_size) + .map(|c| c.to_vec()) + .collect(); + + bench_fn(|| { + let required = page_align(SIZE); + if memory.size() < required { + memory.grow(required - memory.size()); + } + for (i, chunk) in chunks.iter().enumerate() { + memory.write((i * chunk_size) as u64, chunk); + } + }); +} + +#[bench] +fn write_stable_1m_elems() { + const N: usize = 1_000_000; + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(3)); + let chunk_size = SIZE / N; + let chunks: Vec = vec![VALUE; SIZE]; + + bench_fn(|| { + let required = page_align(SIZE); + if memory.size() < required { + memory.grow(required - memory.size()); + } + for i in 0..N { + let offset = i * chunk_size; + memory.write(offset as u64, &chunks[offset..offset + chunk_size]); + } + }); +} + +#[bench] +fn write_btreemap_1_elem() { + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(4)); let mut map = BTreeMap::init(memory); let buf = vec![VALUE; SIZE]; bench_fn(|| { - map.insert(0_u32, buf); + map.insert(0_u32, buf.clone()); }); } #[bench] -fn btreemap_write_100mb_chunked() { - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(3)); +fn write_btreemap_1k_elems() { + const N: usize = 1_000; + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(5)); let mut map = BTreeMap::init(memory); + let chunk_size = SIZE / N; + let chunks: Vec> = vec![VALUE; SIZE] + .chunks(chunk_size) + .map(|c| c.to_vec()) + .collect(); + bench_fn(|| { + for (i, chunk) in chunks.into_iter().enumerate() { + map.insert(i as u32, chunk); + } + }); +} + +#[bench] +fn write_btreemap_1m_elems() { + const N: usize = 1_000_000; + let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(6)); + let mut map = BTreeMap::init(memory); + let chunk_size = SIZE / N; let chunks: Vec> = vec![VALUE; SIZE] - .chunks(CHUNK) - .map(|chunk| chunk.to_vec()) + .chunks(chunk_size) + .map(|c| c.to_vec()) .collect(); bench_fn(|| { From eb3e611013708adaac10ef8f9dd9b83b2243639f Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 11:58:02 +0200 Subject: [PATCH 04/25] . --- benchmarks/btreemap/src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index fb1779f3..661f751a 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -785,6 +785,18 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { }) } +/* +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|-------------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_1_elem | | 1.49B | | 4.83K | | 1.67K | | +| new | write_btreemap_1k_elems | | 5.49B | | 3.20K | | 1.67K | | +| new | write_btreemap_1m_elems | | 93.30B | | 3.51K | | 3.20K | | +| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | +| new | write_stable_1k_elems | | 977.14M | | 3.20K | | 1.67K | | +| new | write_stable_1m_elems | | 553.86M | | 1.60K | | 1.67K | | + +ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change +*/ use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; const SIZE: usize = 100 * 1024 * 1024; // 100MB From 816f5463d1f696f45a9823c00bb4d98f3626401f Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 12:15:19 +0200 Subject: [PATCH 05/25] . --- benchmarks/btreemap/src/main.rs | 160 ++++++++++++++++---------------- 1 file changed, 78 insertions(+), 82 deletions(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 661f751a..3c99cbb9 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,14 +786,10 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } /* -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|-------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_1_elem | | 1.49B | | 4.83K | | 1.67K | | -| new | write_btreemap_1k_elems | | 5.49B | | 3.20K | | 1.67K | | -| new | write_btreemap_1m_elems | | 93.30B | | 3.51K | | 3.20K | | -| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | -| new | write_stable_1k_elems | | 977.14M | | 3.20K | | 1.67K | | -| new | write_stable_1m_elems | | 553.86M | | 1.60K | | 1.67K | | +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|-----------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_1_elem | | 1.49B | | 4.83K | | 1.67K | | +| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change */ @@ -820,45 +816,45 @@ fn write_stable_1_elem() { }); } -#[bench] -fn write_stable_1k_elems() { - const N: usize = 1_000; - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(2)); - let chunk_size = SIZE / N; - let chunks: Vec> = vec![VALUE; SIZE] - .chunks(chunk_size) - .map(|c| c.to_vec()) - .collect(); - - bench_fn(|| { - let required = page_align(SIZE); - if memory.size() < required { - memory.grow(required - memory.size()); - } - for (i, chunk) in chunks.iter().enumerate() { - memory.write((i * chunk_size) as u64, chunk); - } - }); -} - -#[bench] -fn write_stable_1m_elems() { - const N: usize = 1_000_000; - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(3)); - let chunk_size = SIZE / N; - let chunks: Vec = vec![VALUE; SIZE]; - - bench_fn(|| { - let required = page_align(SIZE); - if memory.size() < required { - memory.grow(required - memory.size()); - } - for i in 0..N { - let offset = i * chunk_size; - memory.write(offset as u64, &chunks[offset..offset + chunk_size]); - } - }); -} +// #[bench] +// fn write_stable_1k_elems() { +// const N: usize = 1_000; +// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(2)); +// let chunk_size = SIZE / N; +// let chunks: Vec> = vec![VALUE; SIZE] +// .chunks(chunk_size) +// .map(|c| c.to_vec()) +// .collect(); + +// bench_fn(|| { +// let required = page_align(SIZE); +// if memory.size() < required { +// memory.grow(required - memory.size()); +// } +// for (i, chunk) in chunks.iter().enumerate() { +// memory.write((i * chunk_size) as u64, chunk); +// } +// }); +// } + +// #[bench] +// fn write_stable_1m_elems() { +// const N: usize = 1_000_000; +// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(3)); +// let chunk_size = SIZE / N; +// let chunks: Vec = vec![VALUE; SIZE]; + +// bench_fn(|| { +// let required = page_align(SIZE); +// if memory.size() < required { +// memory.grow(required - memory.size()); +// } +// for i in 0..N { +// let offset = i * chunk_size; +// memory.write(offset as u64, &chunks[offset..offset + chunk_size]); +// } +// }); +// } #[bench] fn write_btreemap_1_elem() { @@ -871,40 +867,40 @@ fn write_btreemap_1_elem() { }); } -#[bench] -fn write_btreemap_1k_elems() { - const N: usize = 1_000; - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(5)); - let mut map = BTreeMap::init(memory); - let chunk_size = SIZE / N; - let chunks: Vec> = vec![VALUE; SIZE] - .chunks(chunk_size) - .map(|c| c.to_vec()) - .collect(); - - bench_fn(|| { - for (i, chunk) in chunks.into_iter().enumerate() { - map.insert(i as u32, chunk); - } - }); -} - -#[bench] -fn write_btreemap_1m_elems() { - const N: usize = 1_000_000; - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(6)); - let mut map = BTreeMap::init(memory); - let chunk_size = SIZE / N; - let chunks: Vec> = vec![VALUE; SIZE] - .chunks(chunk_size) - .map(|c| c.to_vec()) - .collect(); - - bench_fn(|| { - for (i, chunk) in chunks.into_iter().enumerate() { - map.insert(i as u32, chunk); - } - }); -} +// #[bench] +// fn write_btreemap_1k_elems() { +// const N: usize = 1_000; +// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(5)); +// let mut map = BTreeMap::init(memory); +// let chunk_size = SIZE / N; +// let chunks: Vec> = vec![VALUE; SIZE] +// .chunks(chunk_size) +// .map(|c| c.to_vec()) +// .collect(); + +// bench_fn(|| { +// for (i, chunk) in chunks.into_iter().enumerate() { +// map.insert(i as u32, chunk); +// } +// }); +// } + +// #[bench] +// fn write_btreemap_1m_elems() { +// const N: usize = 1_000_000; +// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(6)); +// let mut map = BTreeMap::init(memory); +// let chunk_size = SIZE / N; +// let chunks: Vec> = vec![VALUE; SIZE] +// .chunks(chunk_size) +// .map(|c| c.to_vec()) +// .collect(); + +// bench_fn(|| { +// for (i, chunk) in chunks.into_iter().enumerate() { +// map.insert(i as u32, chunk); +// } +// }); +// } fn main() {} From 42d34a26e973e423da7d58d21d6309316c5bdfd7 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 12:37:40 +0200 Subject: [PATCH 06/25] fix scopes deps --- Cargo.toml | 2 +- benchmarks/Cargo.toml | 2 +- benchmarks/btreemap/src/main.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e4122f67..24904650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ tempfile = "3.3.0" test-strategy = "0.3.1" [features] -bench_scope = [] # May add significant overhead. +bench_scope = ["dep:canbench-rs"] # May add significant overhead. [workspace] members = ["benchmarks"] diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index 395463dc..8a6a5194 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -10,7 +10,7 @@ canbench-rs.workspace = true candid.workspace = true ic-cdk.workspace = true ic-cdk-macros.workspace = true -ic-stable-structures = { path = "../", features = [] } +ic-stable-structures = { path = "../", features = ["bench_scope"] } maplit = "1.0.2" serde = "1.0" tiny-rng = "0.2.0" diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 3c99cbb9..4fa5bfcb 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,10 +786,12 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } /* -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|-----------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_1_elem | | 1.49B | | 4.83K | | 1.67K | | -| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|-------------------------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_1_elem | | 1.49B | | 4.83K | | 1.67K | | +| new | write_btreemap_1_elem::insert_entry | 1 | 684 | | 0 | | 0 | | +| new | write_btreemap_1_elem::node_save_v2 | 1 | 361.30M | | 31 | | 1.54K | | +| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change */ From 7428bf615cb68e54ca6b332d49a04e2d9380bc71 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 12:45:53 +0200 Subject: [PATCH 07/25] dbg --- benchmarks/btreemap/src/main.rs | 17 +++++++++-------- src/btreemap.rs | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 4fa5bfcb..6587db6a 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,18 +786,19 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } /* -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|-------------------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_1_elem | | 1.49B | | 4.83K | | 1.67K | | -| new | write_btreemap_1_elem::insert_entry | 1 | 684 | | 0 | | 0 | | -| new | write_btreemap_1_elem::node_save_v2 | 1 | 361.30M | | 31 | | 1.54K | | -| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|---------------------------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_1_elem | | 1.07B | | 3.23K | | 1.67K | | +| new | write_btreemap_1_elem::insert | 1 | 780.74M | | 1.63K | | 1.54K | | +| new | write_btreemap_1_elem::insert_nonfull | 1 | 361.30M | | 31 | | 1.54K | | +| new | write_btreemap_1_elem::node_save_v2 | 1 | 361.30M | | 31 | | 1.54K | | +| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change */ use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; -const SIZE: usize = 100 * 1024 * 1024; // 100MB +const SIZE: usize = 100 * 1024 * 1024; const VALUE: u8 = 37; fn page_align(bytes: usize) -> u64 { @@ -865,7 +866,7 @@ fn write_btreemap_1_elem() { let buf = vec![VALUE; SIZE]; bench_fn(|| { - map.insert(0_u32, buf.clone()); + map.insert(0_u32, buf); }); } diff --git a/src/btreemap.rs b/src/btreemap.rs index b0a86620..473978dd 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -492,6 +492,9 @@ where /// key.to_bytes().len() <= max_size(Key) /// value.to_bytes().len() <= max_size(Value) pub fn insert(&mut self, key: K, value: V) -> Option { + #[cfg(feature = "bench_scope")] + let _p = canbench_rs::bench_scope("insert"); // May add significant overhead. + let value = value.to_bytes_checked().into_owned(); let root = if self.root_addr == NULL { @@ -544,6 +547,9 @@ where /// Inserts an entry into a node that is *not full*. fn insert_nonfull(&mut self, mut node: Node, key: K, value: Vec) -> Option> { + #[cfg(feature = "bench_scope")] + let _p = canbench_rs::bench_scope("insert_nonfull"); // May add significant overhead. + // We're guaranteed by the caller that the provided node is not full. assert!(!node.is_full()); From 6fac00cad05dbf662289969ff0feede768ad8362 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 12:50:50 +0200 Subject: [PATCH 08/25] . --- benchmarks/btreemap/src/main.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 6587db6a..f9a903f7 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,13 +786,16 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } /* -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|---------------------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_1_elem | | 1.07B | | 3.23K | | 1.67K | | -| new | write_btreemap_1_elem::insert | 1 | 780.74M | | 1.63K | | 1.54K | | -| new | write_btreemap_1_elem::insert_nonfull | 1 | 361.30M | | 31 | | 1.54K | | -| new | write_btreemap_1_elem::node_save_v2 | 1 | 361.30M | | 31 | | 1.54K | | -| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|---------------------------------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_1_elem | | 1.07B | | 3.23K | | 1.67K | | +| new | write_btreemap_1_elem::insert | 1 | 780.74M | | 1.63K | | 1.54K | | +| new | write_btreemap_1_elem::insert_allocate_node | 1 | 1.48K | | 0 | | 0 | | +| new | write_btreemap_1_elem::insert_nonfull | 1 | 361.30M | | 31 | | 1.54K | | +| new | write_btreemap_1_elem::insert_value | 1 | 419.43M | | 1.60K | | 0 | | +| new | write_btreemap_1_elem::node_save_v2 | 1 | 361.30M | | 31 | | 1.54K | | +| new | write_btreemap_1_elem::to_bytes_checked | 2 | 761 | | 0 | | 0 | | +| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change */ From f264676a473e8ff0eb69a38cde7214d8fe76cbec Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 13:45:34 +0200 Subject: [PATCH 09/25] into_bytes --- src/btreemap.rs | 28 +++++++++++++-- src/storable.rs | 81 ++++++++++++++++++++++++++++++++++++++++++ src/storable/tuples.rs | 76 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 3 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 473978dd..4e3951eb 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -495,16 +495,26 @@ where #[cfg(feature = "bench_scope")] let _p = canbench_rs::bench_scope("insert"); // May add significant overhead. - let value = value.to_bytes_checked().into_owned(); + let value = { + #[cfg(feature = "bench_scope")] + let _p = canbench_rs::bench_scope("insert_value"); // May add significant overhead. + + //value.to_bytes_checked().into_owned() + value.into_bytes() + }; let root = if self.root_addr == NULL { - // No root present. Allocate one. + #[cfg(feature = "bench_scope")] + let _p = canbench_rs::bench_scope("insert_allocate_node"); // May add significant overhead. + // No root present. Allocate one. let node = self.allocate_node(NodeType::Leaf); self.root_addr = node.address(); self.save_header(); node } else { - // Load the root from memory. + #[cfg(feature = "bench_scope")] + let _p = canbench_rs::bench_scope("insert_load_node"); // May add significant overhead. + // Load the root from memory. let mut root = self.load_node(self.root_addr); // Check if the key already exists in the root. @@ -2986,6 +2996,10 @@ mod test { Cow::Borrowed(&[1, 2, 3, 4]) } + fn into_bytes(self) -> Vec { + vec![1, 2, 3, 4] + } + fn from_bytes(_: Cow<[u8]>) -> Self { unimplemented!(); } @@ -3125,6 +3139,10 @@ mod test { Cow::Owned(vec![1, 2, 3]) } + fn into_bytes(self) -> Vec { + vec![1, 2, 3] + } + fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.to_vec(), vec![1, 2, 3]); T @@ -3144,6 +3162,10 @@ mod test { Cow::Owned(vec![1, 2, 3]) } + fn into_bytes(self) -> Vec { + vec![1, 2, 3] + } + fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.to_vec(), vec![1, 2, 3]); T2 diff --git a/src/storable.rs b/src/storable.rs index 044ffa9a..1bc363eb 100644 --- a/src/storable.rs +++ b/src/storable.rs @@ -16,6 +16,8 @@ pub trait Storable { /// NOTE: `Cow` is used here to avoid unnecessary cloning. fn to_bytes(&self) -> Cow<[u8]>; + fn into_bytes(self) -> Vec; + /// Converts bytes into an element. fn from_bytes(bytes: Cow<[u8]>) -> Self; @@ -25,6 +27,9 @@ pub trait Storable { /// Like `to_bytes`, but includes additional checks to ensure the element's serialized bytes /// are within the element's bounds. fn to_bytes_checked(&self) -> Cow<[u8]> { + #[cfg(feature = "bench_scope")] + let _p = canbench_rs::bench_scope("to_bytes_checked"); // May add significant overhead. + let bytes = self.to_bytes(); if let Bound::Bounded { max_size, @@ -179,6 +184,10 @@ impl Storable for Blob { Cow::Borrowed(self.as_slice()) } + fn into_bytes(self) -> Vec { + self.as_slice().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::try_from(bytes.borrow()).unwrap() @@ -224,6 +233,10 @@ impl Storable for FixedVec { Cow::Owned(self.0.clone()) } + fn into_bytes(self) -> Vec { + self.0 + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { FixedVec(bytes.into_owned()) @@ -249,6 +262,10 @@ impl Storable for () { Cow::Borrowed(&[]) } + fn into_bytes(self) -> Vec { + Vec::new() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { assert!(bytes.is_empty()); @@ -267,6 +284,10 @@ impl Storable for Vec { Cow::Borrowed(self) } + fn into_bytes(self) -> Vec { + self + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { bytes.into_owned() @@ -280,6 +301,10 @@ impl Storable for String { Cow::Borrowed(self.as_bytes()) } + fn into_bytes(self) -> Vec { + self.into_bytes() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { String::from_utf8(bytes.into_owned()).unwrap() @@ -293,6 +318,10 @@ impl Storable for u128 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -309,6 +338,10 @@ impl Storable for u64 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -325,6 +358,10 @@ impl Storable for f64 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -341,6 +378,10 @@ impl Storable for u32 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -357,6 +398,10 @@ impl Storable for f32 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -373,6 +418,10 @@ impl Storable for u16 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -389,6 +438,10 @@ impl Storable for u8 { Cow::Owned(self.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + self.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -406,6 +459,11 @@ impl Storable for bool { Cow::Owned(num.to_be_bytes().to_vec()) } + fn into_bytes(self) -> Vec { + let num: u8 = if self { 1 } else { 0 }; + num.to_be_bytes().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.len(), 1); @@ -427,6 +485,10 @@ impl Storable for [u8; N] { Cow::Borrowed(&self[..]) } + fn into_bytes(self) -> Vec { + self.to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.len(), N); @@ -446,6 +508,10 @@ impl Storable for Reverse { self.0.to_bytes() } + fn into_bytes(self) -> Vec { + self.0.into_bytes() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self(T::from_bytes(bytes)) @@ -466,6 +532,17 @@ impl Storable for Option { } } + fn into_bytes(self) -> Vec { + match self { + Some(t) => { + let mut bytes = t.into_bytes(); + bytes.push(1); + bytes + } + None => vec![0], + } + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { match bytes.split_last() { @@ -500,6 +577,10 @@ impl Storable for Principal { Cow::Borrowed(self.as_slice()) } + fn into_bytes(self) -> Vec { + self.as_slice().to_vec() + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_slice(&bytes) diff --git a/src/storable/tuples.rs b/src/storable/tuples.rs index 180d5c88..354e8cf0 100644 --- a/src/storable/tuples.rs +++ b/src/storable/tuples.rs @@ -49,6 +49,47 @@ where } } + fn into_bytes(self) -> Vec { + match Self::BOUND { + Bound::Bounded { max_size, .. } => { + let mut bytes = vec![0; max_size as usize]; + let a_bytes = self.0.to_bytes(); + let b_bytes = self.1.to_bytes(); + + let a_bounds = bounds::(); + let b_bounds = bounds::(); + + let a_max_size = a_bounds.max_size as usize; + let b_max_size = b_bounds.max_size as usize; + + debug_assert!(a_bytes.len() <= a_max_size); + debug_assert!(b_bytes.len() <= b_max_size); + + bytes[0..a_bytes.len()].copy_from_slice(a_bytes.borrow()); + bytes[a_max_size..a_max_size + b_bytes.len()].copy_from_slice(b_bytes.borrow()); + + let a_size_len = bytes_to_store_size_bounded(&a_bounds) as usize; + let b_size_len = bytes_to_store_size_bounded(&b_bounds) as usize; + + let sizes_offset: usize = a_max_size + b_max_size; + + encode_size_of_bound( + &mut bytes[sizes_offset..sizes_offset + a_size_len], + a_bytes.len(), + &a_bounds, + ); + encode_size_of_bound( + &mut bytes[sizes_offset + a_size_len..sizes_offset + a_size_len + b_size_len], + b_bytes.len(), + &b_bounds, + ); + + bytes + } + _ => todo!("Serializing tuples with unbounded types is not yet supported."), + } + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { match Self::BOUND { @@ -295,6 +336,41 @@ where Cow::Owned(bytes) } + fn into_bytes(self) -> Vec { + let a_bytes = self.0.to_bytes(); + let a_size = a_bytes.len(); + + let b_bytes = self.1.to_bytes(); + let b_size = b_bytes.len(); + + let c_bytes = self.2.to_bytes(); + let c_size = c_bytes.len(); + + let sizes_overhead = sizes_overhead::(a_size, b_size); + + let output_size = a_size + b_size + c_size + sizes_overhead; + + let mut bytes_written = 0; + + let mut bytes = vec![0; output_size]; + + if sizes_overhead != 0 { + bytes[bytes_written] = encode_size_lengths(vec![a_size, b_size]); + bytes_written += 1; + } + + bytes_written += + encode_tuple_element::(&mut bytes[bytes_written..], a_bytes.borrow(), false); + bytes_written += + encode_tuple_element::(&mut bytes[bytes_written..], b_bytes.borrow(), false); + bytes_written += + encode_tuple_element::(&mut bytes[bytes_written..], c_bytes.borrow(), true); + + assert_eq!(bytes_written, output_size); + + bytes + } + #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { let mut bytes_read_total = 0; From cebf2374abae6f0adb73ccc45e28c96c63e60f21 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 13:48:44 +0200 Subject: [PATCH 10/25] rm feature --- benchmarks/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index 8a6a5194..395463dc 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -10,7 +10,7 @@ canbench-rs.workspace = true candid.workspace = true ic-cdk.workspace = true ic-cdk-macros.workspace = true -ic-stable-structures = { path = "../", features = ["bench_scope"] } +ic-stable-structures = { path = "../", features = [] } maplit = "1.0.2" serde = "1.0" tiny-rng = "0.2.0" From 9a267171861f18ca06cdd02432832ecbdac77be8 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 14:06:05 +0200 Subject: [PATCH 11/25] cleanup --- benchmarks/btreemap/src/main.rs | 171 ++++++++++++++------------------ 1 file changed, 76 insertions(+), 95 deletions(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index f9a903f7..be3615ef 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,16 +786,14 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } /* -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|---------------------------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_1_elem | | 1.07B | | 3.23K | | 1.67K | | -| new | write_btreemap_1_elem::insert | 1 | 780.74M | | 1.63K | | 1.54K | | -| new | write_btreemap_1_elem::insert_allocate_node | 1 | 1.48K | | 0 | | 0 | | -| new | write_btreemap_1_elem::insert_nonfull | 1 | 361.30M | | 31 | | 1.54K | | -| new | write_btreemap_1_elem::insert_value | 1 | 419.43M | | 1.60K | | 0 | | -| new | write_btreemap_1_elem::node_save_v2 | 1 | 361.30M | | 31 | | 1.54K | | -| new | write_btreemap_1_elem::to_bytes_checked | 2 | 761 | | 0 | | 0 | | -| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|-------------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_1_elem | | 651.69M | | 1.64K | | 1.67K | | +| new | write_btreemap_1k_elems | | 5.06B | | 3.20K | | 1.67K | | +| new | write_btreemap_1m_elems | | 92.43B | | 3.51K | | 3.20K | | +| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | +| new | write_stable_1k_elems | | 977.14M | | 3.20K | | 1.67K | | +| new | write_stable_1m_elems | | 1.55B | | 3.51K | | 1.67K | | ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change */ @@ -808,105 +806,88 @@ fn page_align(bytes: usize) -> u64 { bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64 } +fn init_memory(id: u8) -> impl ic_stable_structures::Memory { + MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(id)) +} + +fn ensure_memory_size(memory: &impl ic_stable_structures::Memory, size: usize) { + let required = page_align(size); + if memory.size() < required { + memory.grow(required - memory.size()); + } +} + +fn chunk_data(n: usize) -> Vec> { + let chunk_size = SIZE / n; + vec![VALUE; SIZE] + .chunks(chunk_size) + .map(|c| c.to_vec()) + .collect() +} + #[bench] -fn write_stable_1_elem() { - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(1)); +fn write_btreemap_1_elem() { + let mut map = BTreeMap::init(init_memory(4)); let buf = vec![VALUE; SIZE]; bench_fn(|| { - let required = page_align(SIZE); - if memory.size() < required { - memory.grow(required - memory.size()); - } - memory.write(0, &buf); + map.insert(0_u32, buf); }); } -// #[bench] -// fn write_stable_1k_elems() { -// const N: usize = 1_000; -// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(2)); -// let chunk_size = SIZE / N; -// let chunks: Vec> = vec![VALUE; SIZE] -// .chunks(chunk_size) -// .map(|c| c.to_vec()) -// .collect(); - -// bench_fn(|| { -// let required = page_align(SIZE); -// if memory.size() < required { -// memory.grow(required - memory.size()); -// } -// for (i, chunk) in chunks.iter().enumerate() { -// memory.write((i * chunk_size) as u64, chunk); -// } -// }); -// } - -// #[bench] -// fn write_stable_1m_elems() { -// const N: usize = 1_000_000; -// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(3)); -// let chunk_size = SIZE / N; -// let chunks: Vec = vec![VALUE; SIZE]; - -// bench_fn(|| { -// let required = page_align(SIZE); -// if memory.size() < required { -// memory.grow(required - memory.size()); -// } -// for i in 0..N { -// let offset = i * chunk_size; -// memory.write(offset as u64, &chunks[offset..offset + chunk_size]); -// } -// }); -// } +#[bench] +fn write_btreemap_1k_elems() { + write_btreemap_chunks(5, 1_000); +} #[bench] -fn write_btreemap_1_elem() { - let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(4)); - let mut map = BTreeMap::init(memory); +fn write_btreemap_1m_elems() { + write_btreemap_chunks(6, 1_000_000); +} + +fn write_btreemap_chunks(mem_id: u8, n: usize) { + let mut map = BTreeMap::init(init_memory(mem_id)); + let chunks = chunk_data(n); + + bench_fn(|| { + for (i, chunk) in chunks.into_iter().enumerate() { + map.insert(i as u32, chunk); + } + }); +} + +#[bench] +fn write_stable_1_elem() { + let memory = init_memory(1); let buf = vec![VALUE; SIZE]; bench_fn(|| { - map.insert(0_u32, buf); + ensure_memory_size(&memory, SIZE); + memory.write(0, &buf); }); } -// #[bench] -// fn write_btreemap_1k_elems() { -// const N: usize = 1_000; -// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(5)); -// let mut map = BTreeMap::init(memory); -// let chunk_size = SIZE / N; -// let chunks: Vec> = vec![VALUE; SIZE] -// .chunks(chunk_size) -// .map(|c| c.to_vec()) -// .collect(); - -// bench_fn(|| { -// for (i, chunk) in chunks.into_iter().enumerate() { -// map.insert(i as u32, chunk); -// } -// }); -// } - -// #[bench] -// fn write_btreemap_1m_elems() { -// const N: usize = 1_000_000; -// let memory = MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(6)); -// let mut map = BTreeMap::init(memory); -// let chunk_size = SIZE / N; -// let chunks: Vec> = vec![VALUE; SIZE] -// .chunks(chunk_size) -// .map(|c| c.to_vec()) -// .collect(); - -// bench_fn(|| { -// for (i, chunk) in chunks.into_iter().enumerate() { -// map.insert(i as u32, chunk); -// } -// }); -// } +#[bench] +fn write_stable_1k_elems() { + write_stable_chunks(2, 1_000); +} + +#[bench] +fn write_stable_1m_elems() { + write_stable_chunks(3, 1_000_000); +} + +fn write_stable_chunks(mem_id: u8, n: usize) { + let memory = init_memory(mem_id); + let chunks = chunk_data(n); + let chunk_size = SIZE / n; + + bench_fn(|| { + ensure_memory_size(&memory, SIZE); + for (i, chunk) in chunks.iter().enumerate() { + memory.write((i * chunk_size) as u64, chunk); + } + }); +} fn main() {} From 45377350ec90db88bd319f1875769e58ef18e0bd Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 17:31:13 +0200 Subject: [PATCH 12/25] rm into_bytes --- src/btreemap.rs | 20 +---------- src/storable.rs | 78 ------------------------------------------ src/storable/tuples.rs | 76 ---------------------------------------- 3 files changed, 1 insertion(+), 173 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 4e3951eb..850cbc61 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -495,13 +495,7 @@ where #[cfg(feature = "bench_scope")] let _p = canbench_rs::bench_scope("insert"); // May add significant overhead. - let value = { - #[cfg(feature = "bench_scope")] - let _p = canbench_rs::bench_scope("insert_value"); // May add significant overhead. - - //value.to_bytes_checked().into_owned() - value.into_bytes() - }; + let value = value.to_bytes_checked().into_owned(); let root = if self.root_addr == NULL { #[cfg(feature = "bench_scope")] @@ -2996,10 +2990,6 @@ mod test { Cow::Borrowed(&[1, 2, 3, 4]) } - fn into_bytes(self) -> Vec { - vec![1, 2, 3, 4] - } - fn from_bytes(_: Cow<[u8]>) -> Self { unimplemented!(); } @@ -3139,10 +3129,6 @@ mod test { Cow::Owned(vec![1, 2, 3]) } - fn into_bytes(self) -> Vec { - vec![1, 2, 3] - } - fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.to_vec(), vec![1, 2, 3]); T @@ -3162,10 +3148,6 @@ mod test { Cow::Owned(vec![1, 2, 3]) } - fn into_bytes(self) -> Vec { - vec![1, 2, 3] - } - fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.to_vec(), vec![1, 2, 3]); T2 diff --git a/src/storable.rs b/src/storable.rs index 1bc363eb..a9bb9750 100644 --- a/src/storable.rs +++ b/src/storable.rs @@ -16,8 +16,6 @@ pub trait Storable { /// NOTE: `Cow` is used here to avoid unnecessary cloning. fn to_bytes(&self) -> Cow<[u8]>; - fn into_bytes(self) -> Vec; - /// Converts bytes into an element. fn from_bytes(bytes: Cow<[u8]>) -> Self; @@ -184,10 +182,6 @@ impl Storable for Blob { Cow::Borrowed(self.as_slice()) } - fn into_bytes(self) -> Vec { - self.as_slice().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::try_from(bytes.borrow()).unwrap() @@ -233,10 +227,6 @@ impl Storable for FixedVec { Cow::Owned(self.0.clone()) } - fn into_bytes(self) -> Vec { - self.0 - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { FixedVec(bytes.into_owned()) @@ -262,10 +252,6 @@ impl Storable for () { Cow::Borrowed(&[]) } - fn into_bytes(self) -> Vec { - Vec::new() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { assert!(bytes.is_empty()); @@ -284,10 +270,6 @@ impl Storable for Vec { Cow::Borrowed(self) } - fn into_bytes(self) -> Vec { - self - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { bytes.into_owned() @@ -301,10 +283,6 @@ impl Storable for String { Cow::Borrowed(self.as_bytes()) } - fn into_bytes(self) -> Vec { - self.into_bytes() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { String::from_utf8(bytes.into_owned()).unwrap() @@ -318,10 +296,6 @@ impl Storable for u128 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -338,10 +312,6 @@ impl Storable for u64 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -358,10 +328,6 @@ impl Storable for f64 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -378,10 +344,6 @@ impl Storable for u32 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -398,10 +360,6 @@ impl Storable for f32 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -418,10 +376,6 @@ impl Storable for u16 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -438,10 +392,6 @@ impl Storable for u8 { Cow::Owned(self.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - self.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_be_bytes(bytes.as_ref().try_into().unwrap()) @@ -459,11 +409,6 @@ impl Storable for bool { Cow::Owned(num.to_be_bytes().to_vec()) } - fn into_bytes(self) -> Vec { - let num: u8 = if self { 1 } else { 0 }; - num.to_be_bytes().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.len(), 1); @@ -485,10 +430,6 @@ impl Storable for [u8; N] { Cow::Borrowed(&self[..]) } - fn into_bytes(self) -> Vec { - self.to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { assert_eq!(bytes.len(), N); @@ -508,10 +449,6 @@ impl Storable for Reverse { self.0.to_bytes() } - fn into_bytes(self) -> Vec { - self.0.into_bytes() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self(T::from_bytes(bytes)) @@ -532,17 +469,6 @@ impl Storable for Option { } } - fn into_bytes(self) -> Vec { - match self { - Some(t) => { - let mut bytes = t.into_bytes(); - bytes.push(1); - bytes - } - None => vec![0], - } - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { match bytes.split_last() { @@ -577,10 +503,6 @@ impl Storable for Principal { Cow::Borrowed(self.as_slice()) } - fn into_bytes(self) -> Vec { - self.as_slice().to_vec() - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { Self::from_slice(&bytes) diff --git a/src/storable/tuples.rs b/src/storable/tuples.rs index 354e8cf0..180d5c88 100644 --- a/src/storable/tuples.rs +++ b/src/storable/tuples.rs @@ -49,47 +49,6 @@ where } } - fn into_bytes(self) -> Vec { - match Self::BOUND { - Bound::Bounded { max_size, .. } => { - let mut bytes = vec![0; max_size as usize]; - let a_bytes = self.0.to_bytes(); - let b_bytes = self.1.to_bytes(); - - let a_bounds = bounds::(); - let b_bounds = bounds::(); - - let a_max_size = a_bounds.max_size as usize; - let b_max_size = b_bounds.max_size as usize; - - debug_assert!(a_bytes.len() <= a_max_size); - debug_assert!(b_bytes.len() <= b_max_size); - - bytes[0..a_bytes.len()].copy_from_slice(a_bytes.borrow()); - bytes[a_max_size..a_max_size + b_bytes.len()].copy_from_slice(b_bytes.borrow()); - - let a_size_len = bytes_to_store_size_bounded(&a_bounds) as usize; - let b_size_len = bytes_to_store_size_bounded(&b_bounds) as usize; - - let sizes_offset: usize = a_max_size + b_max_size; - - encode_size_of_bound( - &mut bytes[sizes_offset..sizes_offset + a_size_len], - a_bytes.len(), - &a_bounds, - ); - encode_size_of_bound( - &mut bytes[sizes_offset + a_size_len..sizes_offset + a_size_len + b_size_len], - b_bytes.len(), - &b_bounds, - ); - - bytes - } - _ => todo!("Serializing tuples with unbounded types is not yet supported."), - } - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { match Self::BOUND { @@ -336,41 +295,6 @@ where Cow::Owned(bytes) } - fn into_bytes(self) -> Vec { - let a_bytes = self.0.to_bytes(); - let a_size = a_bytes.len(); - - let b_bytes = self.1.to_bytes(); - let b_size = b_bytes.len(); - - let c_bytes = self.2.to_bytes(); - let c_size = c_bytes.len(); - - let sizes_overhead = sizes_overhead::(a_size, b_size); - - let output_size = a_size + b_size + c_size + sizes_overhead; - - let mut bytes_written = 0; - - let mut bytes = vec![0; output_size]; - - if sizes_overhead != 0 { - bytes[bytes_written] = encode_size_lengths(vec![a_size, b_size]); - bytes_written += 1; - } - - bytes_written += - encode_tuple_element::(&mut bytes[bytes_written..], a_bytes.borrow(), false); - bytes_written += - encode_tuple_element::(&mut bytes[bytes_written..], b_bytes.borrow(), false); - bytes_written += - encode_tuple_element::(&mut bytes[bytes_written..], c_bytes.borrow(), true); - - assert_eq!(bytes_written, output_size); - - bytes - } - #[inline] fn from_bytes(bytes: Cow<[u8]>) -> Self { let mut bytes_read_total = 0; From e2f53deb923ef1192632601768970987b2be3539 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 17:53:21 +0200 Subject: [PATCH 13/25] extend benchmarks --- benchmarks/btreemap/canbench_results.yml | 2003 +--------------------- benchmarks/btreemap/src/main.rs | 100 +- 2 files changed, 110 insertions(+), 1993 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 6abd993b..96dc4d3a 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -1,1997 +1,58 @@ benches: - btreemap_v2_contains_10mib_values: + read_btreemap_100_elems: total: calls: 1 - instructions: 142209883 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 5106651688 + heap_increase: 3216 + stable_memory_increase: 1665 scopes: {} - btreemap_v2_contains_blob8_u64: + read_btreemap_10k_elems: total: calls: 1 - instructions: 283243186 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 7660759692 + heap_increase: 3203 + stable_memory_increase: 1665 scopes: {} - btreemap_v2_contains_blob_1024_128: + read_btreemap_1_elem: total: calls: 1 - instructions: 4294894392 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 1640268014 + heap_increase: 3233 + stable_memory_increase: 1665 scopes: {} - btreemap_v2_contains_blob_128_128: + read_btreemap_1m_elems: total: calls: 1 - instructions: 840909876 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 137122763075 + heap_increase: 3507 + stable_memory_increase: 3201 scopes: {} - btreemap_v2_contains_blob_16_128: + read_stable_100_elems: total: calls: 1 - instructions: 300105736 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 946863281 + heap_increase: 3216 + stable_memory_increase: 1665 scopes: {} - btreemap_v2_contains_blob_256_128: + read_stable_10k_elems: total: calls: 1 - instructions: 1326771401 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 1091369965 + heap_increase: 3203 + stable_memory_increase: 1665 scopes: {} - btreemap_v2_contains_blob_32_1024: + read_stable_1_elems: total: calls: 1 - instructions: 337445350 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 1232207354 + heap_increase: 3202 + stable_memory_increase: 1665 scopes: {} - btreemap_v2_contains_blob_32_128: + read_stable_1m_elems: total: calls: 1 - instructions: 337242957 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_16: - total: - calls: 1 - instructions: 329500229 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_256: - total: - calls: 1 - instructions: 335682009 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_32: - total: - calls: 1 - instructions: 342487367 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_4: - total: - calls: 1 - instructions: 333741840 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_512: - total: - calls: 1 - instructions: 333192029 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_64: - total: - calls: 1 - instructions: 337617773 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_32_8: - total: - calls: 1 - instructions: 335387695 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_4_128: - total: - calls: 1 - instructions: 250355530 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_512_128: - total: - calls: 1 - instructions: 2298434691 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_64_128: - total: - calls: 1 - instructions: 419606574 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_blob_8_128: - total: - calls: 1 - instructions: 273336147 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_u64_blob8: - total: - calls: 1 - instructions: 225499211 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_u64_u64: - total: - calls: 1 - instructions: 230729851 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_u64_vec8: - total: - calls: 1 - instructions: 225499211 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec8_u64: - total: - calls: 1 - instructions: 373974679 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_1024_128: - total: - calls: 1 - instructions: 1847543843 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_128_128: - total: - calls: 1 - instructions: 562946697 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_16_128: - total: - calls: 1 - instructions: 432781519 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_256_128: - total: - calls: 1 - instructions: 916951505 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_1024: - total: - calls: 1 - instructions: 516345708 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_128: - total: - calls: 1 - instructions: 437597039 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_16: - total: - calls: 1 - instructions: 367092396 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_256: - total: - calls: 1 - instructions: 445726845 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_32: - total: - calls: 1 - instructions: 367166163 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_4: - total: - calls: 1 - instructions: 366267458 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_512: - total: - calls: 1 - instructions: 480959847 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_64: - total: - calls: 1 - instructions: 407119037 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_32_8: - total: - calls: 1 - instructions: 366285313 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_4_128: - total: - calls: 1 - instructions: 398219523 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_512_128: - total: - calls: 1 - instructions: 1276595171 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_64_128: - total: - calls: 1 - instructions: 512370490 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_contains_vec_8_128: - total: - calls: 1 - instructions: 398244279 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_10mib_values: - total: - calls: 1 - instructions: 388595742 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob8_u64: - total: - calls: 1 - instructions: 294497964 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_1024_128: - total: - calls: 1 - instructions: 4434041253 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_128_128: - total: - calls: 1 - instructions: 874096444 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_16_128: - total: - calls: 1 - instructions: 313526179 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_256_128: - total: - calls: 1 - instructions: 1373148630 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_1024: - total: - calls: 1 - instructions: 357155881 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_128: - total: - calls: 1 - instructions: 351535572 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_16: - total: - calls: 1 - instructions: 340461038 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_256: - total: - calls: 1 - instructions: 351061577 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_32: - total: - calls: 1 - instructions: 353942159 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_4: - total: - calls: 1 - instructions: 343418312 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_512: - total: - calls: 1 - instructions: 350194697 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_64: - total: - calls: 1 - instructions: 350423636 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_32_8: - total: - calls: 1 - instructions: 345686334 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_4_128: - total: - calls: 1 - instructions: 262413920 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_512_128: - total: - calls: 1 - instructions: 2375697187 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_64_128: - total: - calls: 1 - instructions: 443018386 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_blob_8_128: - total: - calls: 1 - instructions: 286466150 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_u64_blob8: - total: - calls: 1 - instructions: 235941207 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_u64_u64: - total: - calls: 1 - instructions: 242257567 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_u64_vec8: - total: - calls: 1 - instructions: 236688731 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec8_u64: - total: - calls: 1 - instructions: 383633031 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_1024_128: - total: - calls: 1 - instructions: 1895892021 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_128_128: - total: - calls: 1 - instructions: 575182491 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_16_128: - total: - calls: 1 - instructions: 442328780 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_256_128: - total: - calls: 1 - instructions: 929706179 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_1024: - total: - calls: 1 - instructions: 558668778 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_128: - total: - calls: 1 - instructions: 447698379 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_16: - total: - calls: 1 - instructions: 374638992 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_256: - total: - calls: 1 - instructions: 463244749 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_32: - total: - calls: 1 - instructions: 374845455 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_4: - total: - calls: 1 - instructions: 374022129 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_512: - total: - calls: 1 - instructions: 502894640 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_64: - total: - calls: 1 - instructions: 415510238 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_32_8: - total: - calls: 1 - instructions: 374044541 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_4_128: - total: - calls: 1 - instructions: 407171466 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_512_128: - total: - calls: 1 - instructions: 1289217055 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_64_128: - total: - calls: 1 - instructions: 523089683 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_get_vec_8_128: - total: - calls: 1 - instructions: 407684851 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_insert_10mib_values: - total: - calls: 1 - instructions: 5251792410 - heap_increase: 322 - stable_memory_increase: 3613 - scopes: {} - btreemap_v2_insert_blob8_u64: - total: - calls: 1 - instructions: 451032102 - heap_increase: 0 - stable_memory_increase: 4 - scopes: {} - btreemap_v2_insert_blob_1024_128: - total: - calls: 1 - instructions: 5525788624 - heap_increase: 0 - stable_memory_increase: 196 - scopes: {} - btreemap_v2_insert_blob_128_128: - total: - calls: 1 - instructions: 1208821724 - heap_increase: 0 - stable_memory_increase: 46 - scopes: {} - btreemap_v2_insert_blob_16_128: - total: - calls: 1 - instructions: 500591510 - heap_increase: 0 - stable_memory_increase: 24 - scopes: {} - btreemap_v2_insert_blob_256_128: - total: - calls: 1 - instructions: 1817436957 - heap_increase: 0 - stable_memory_increase: 67 - scopes: {} - btreemap_v2_insert_blob_32_1024: - total: - calls: 1 - instructions: 724849516 - heap_increase: 0 - stable_memory_increase: 173 - scopes: {} - btreemap_v2_insert_blob_32_128: - total: - calls: 1 - instructions: 563513821 - heap_increase: 0 - stable_memory_increase: 28 - scopes: {} - btreemap_v2_insert_blob_32_16: - total: - calls: 1 - instructions: 539411394 - heap_increase: 0 - stable_memory_increase: 11 - scopes: {} - btreemap_v2_insert_blob_32_256: - total: - calls: 1 - instructions: 592917952 - heap_increase: 0 - stable_memory_increase: 49 - scopes: {} - btreemap_v2_insert_blob_32_32: - total: - calls: 1 - instructions: 550204854 - heap_increase: 0 - stable_memory_increase: 13 - scopes: {} - btreemap_v2_insert_blob_32_4: - total: - calls: 1 - instructions: 530054248 - heap_increase: 0 - stable_memory_increase: 8 - scopes: {} - btreemap_v2_insert_blob_32_512: - total: - calls: 1 - instructions: 631334646 - heap_increase: 0 - stable_memory_increase: 91 - scopes: {} - btreemap_v2_insert_blob_32_64: - total: - calls: 1 - instructions: 556446417 - heap_increase: 0 - stable_memory_increase: 18 - scopes: {} - btreemap_v2_insert_blob_32_8: - total: - calls: 1 - instructions: 538691053 - heap_increase: 0 - stable_memory_increase: 9 - scopes: {} - btreemap_v2_insert_blob_4_128: - total: - calls: 1 - instructions: 421160972 - heap_increase: 0 - stable_memory_increase: 13 - scopes: {} - btreemap_v2_insert_blob_512_128: - total: - calls: 1 - instructions: 3070369278 - heap_increase: 0 - stable_memory_increase: 111 - scopes: {} - btreemap_v2_insert_blob_64_128: - total: - calls: 1 - instructions: 687224486 - heap_increase: 0 - stable_memory_increase: 34 - scopes: {} - btreemap_v2_insert_blob_8_128: - total: - calls: 1 - instructions: 473325576 - heap_increase: 0 - stable_memory_increase: 20 - scopes: {} - btreemap_v2_insert_u64_blob8: - total: - calls: 1 - instructions: 424856496 - heap_increase: 0 - stable_memory_increase: 5 - scopes: {} - btreemap_v2_insert_u64_u64: - total: - calls: 1 - instructions: 433078328 - heap_increase: 0 - stable_memory_increase: 6 - scopes: {} - btreemap_v2_insert_u64_vec8: - total: - calls: 1 - instructions: 433606280 - heap_increase: 0 - stable_memory_increase: 21 - scopes: {} - btreemap_v2_insert_vec8_u64: - total: - calls: 1 - instructions: 596675651 - heap_increase: 0 - stable_memory_increase: 16 - scopes: {} - btreemap_v2_insert_vec_1024_128: - total: - calls: 1 - instructions: 2791324761 - heap_increase: 0 - stable_memory_increase: 193 - scopes: {} - btreemap_v2_insert_vec_128_128: - total: - calls: 1 - instructions: 1043141925 - heap_increase: 0 - stable_memory_increase: 51 - scopes: {} - btreemap_v2_insert_vec_16_128: - total: - calls: 1 - instructions: 719668309 - heap_increase: 0 - stable_memory_increase: 31 - scopes: {} - btreemap_v2_insert_vec_256_128: - total: - calls: 1 - instructions: 1425303710 - heap_increase: 0 - stable_memory_increase: 71 - scopes: {} - btreemap_v2_insert_vec_32_1024: - total: - calls: 1 - instructions: 1245182314 - heap_increase: 0 - stable_memory_increase: 171 - scopes: {} - btreemap_v2_insert_vec_32_128: - total: - calls: 1 - instructions: 783650019 - heap_increase: 0 - stable_memory_increase: 33 - scopes: {} - btreemap_v2_insert_vec_32_16: - total: - calls: 1 - instructions: 688714475 - heap_increase: 0 - stable_memory_increase: 20 - scopes: {} - btreemap_v2_insert_vec_32_256: - total: - calls: 1 - instructions: 908090400 - heap_increase: 0 - stable_memory_increase: 54 - scopes: {} - btreemap_v2_insert_vec_32_32: - total: - calls: 1 - instructions: 684433848 - heap_increase: 0 - stable_memory_increase: 20 - scopes: {} - btreemap_v2_insert_vec_32_4: - total: - calls: 1 - instructions: 683382635 - heap_increase: 0 - stable_memory_increase: 20 - scopes: {} - btreemap_v2_insert_vec_32_512: - total: - calls: 1 - instructions: 1026429798 - heap_increase: 0 - stable_memory_increase: 91 - scopes: {} - btreemap_v2_insert_vec_32_64: - total: - calls: 1 - instructions: 717127989 - heap_increase: 0 - stable_memory_increase: 24 - scopes: {} - btreemap_v2_insert_vec_32_8: - total: - calls: 1 - instructions: 682695838 - heap_increase: 0 - stable_memory_increase: 20 - scopes: {} - btreemap_v2_insert_vec_4_128: - total: - calls: 1 - instructions: 621403101 - heap_increase: 0 - stable_memory_increase: 16 - scopes: {} - btreemap_v2_insert_vec_512_128: - total: - calls: 1 - instructions: 1902984657 - heap_increase: 0 - stable_memory_increase: 112 - scopes: {} - btreemap_v2_insert_vec_64_128: - total: - calls: 1 - instructions: 874468583 - heap_increase: 0 - stable_memory_increase: 41 - scopes: {} - btreemap_v2_insert_vec_8_128: - total: - calls: 1 - instructions: 680539918 - heap_increase: 0 - stable_memory_increase: 23 - scopes: {} - btreemap_v2_mem_manager_contains_blob512_u64: - total: - calls: 1 - instructions: 2393561731 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_contains_u64_blob512: - total: - calls: 1 - instructions: 301490930 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_contains_u64_u64: - total: - calls: 1 - instructions: 306627816 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_contains_u64_vec512: - total: - calls: 1 - instructions: 389757738 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_contains_vec512_u64: - total: - calls: 1 - instructions: 1263289436 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_get_blob512_u64: - total: - calls: 1 - instructions: 2480010677 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_get_u64_blob512: - total: - calls: 1 - instructions: 318984422 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_get_u64_u64: - total: - calls: 1 - instructions: 319753693 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_get_u64_vec512: - total: - calls: 1 - instructions: 416829257 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_get_vec512_u64: - total: - calls: 1 - instructions: 1307093929 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_insert_blob512_u64: - total: - calls: 1 - instructions: 3189283499 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_insert_u64_blob512: - total: - calls: 1 - instructions: 647090916 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_insert_u64_u64: - total: - calls: 1 - instructions: 560416018 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_insert_u64_vec512: - total: - calls: 1 - instructions: 900560613 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_insert_vec512_u64: - total: - calls: 1 - instructions: 2032213941 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_remove_blob512_u64: - total: - calls: 1 - instructions: 4412188235 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_remove_u64_blob512: - total: - calls: 1 - instructions: 950509465 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_remove_u64_u64: - total: - calls: 1 - instructions: 808272557 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_remove_u64_vec512: - total: - calls: 1 - instructions: 1289646675 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_mem_manager_remove_vec512_u64: - total: - calls: 1 - instructions: 3183910603 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob8_u64: - total: - calls: 1 - instructions: 622200615 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_1024_128: - total: - calls: 1 - instructions: 8431485310 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_128_128: - total: - calls: 1 - instructions: 1868788897 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_16_128: - total: - calls: 1 - instructions: 765976333 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_256_128: - total: - calls: 1 - instructions: 2807125761 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_1024: - total: - calls: 1 - instructions: 1151786004 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_128: - total: - calls: 1 - instructions: 895271314 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_16: - total: - calls: 1 - instructions: 830179005 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_256: - total: - calls: 1 - instructions: 924008113 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_32: - total: - calls: 1 - instructions: 844939941 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_4: - total: - calls: 1 - instructions: 813445762 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_512: - total: - calls: 1 - instructions: 988660808 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_64: - total: - calls: 1 - instructions: 853670232 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_32_8: - total: - calls: 1 - instructions: 831827208 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_4_128: - total: - calls: 1 - instructions: 382997168 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_512_128: - total: - calls: 1 - instructions: 4656589101 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_64_128: - total: - calls: 1 - instructions: 1070297882 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_blob_8_128: - total: - calls: 1 - instructions: 626229708 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_u64_blob8: - total: - calls: 1 - instructions: 704655932 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_u64_u64: - total: - calls: 1 - instructions: 716277147 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_u64_vec8: - total: - calls: 1 - instructions: 707209318 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec8_u64: - total: - calls: 1 - instructions: 798415678 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_1024_128: - total: - calls: 1 - instructions: 4088132406 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_128_128: - total: - calls: 1 - instructions: 1540235593 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_16_128: - total: - calls: 1 - instructions: 1038779442 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_256_128: - total: - calls: 1 - instructions: 2058259562 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_1024: - total: - calls: 1 - instructions: 1720412114 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_128: - total: - calls: 1 - instructions: 1121742438 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_16: - total: - calls: 1 - instructions: 965011199 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_256: - total: - calls: 1 - instructions: 1248136179 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_32: - total: - calls: 1 - instructions: 961152870 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_4: - total: - calls: 1 - instructions: 954455325 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_512: - total: - calls: 1 - instructions: 1404132606 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_64: - total: - calls: 1 - instructions: 1005109166 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_32_8: - total: - calls: 1 - instructions: 965763854 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_4_128: - total: - calls: 1 - instructions: 546598473 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_512_128: - total: - calls: 1 - instructions: 2756486259 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_64_128: - total: - calls: 1 - instructions: 1266073864 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_first_vec_8_128: - total: - calls: 1 - instructions: 859841368 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob8_u64: - total: - calls: 1 - instructions: 602347043 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_1024_128: - total: - calls: 1 - instructions: 8114668993 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_128_128: - total: - calls: 1 - instructions: 1802553212 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_16_128: - total: - calls: 1 - instructions: 742006771 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_256_128: - total: - calls: 1 - instructions: 2718413554 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_1024: - total: - calls: 1 - instructions: 1117676359 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_128: - total: - calls: 1 - instructions: 862736782 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_16: - total: - calls: 1 - instructions: 805611949 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_256: - total: - calls: 1 - instructions: 895496993 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_32: - total: - calls: 1 - instructions: 815542518 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_4: - total: - calls: 1 - instructions: 793647234 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_512: - total: - calls: 1 - instructions: 965231966 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_64: - total: - calls: 1 - instructions: 829954997 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_32_8: - total: - calls: 1 - instructions: 807341792 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_4_128: - total: - calls: 1 - instructions: 371628597 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_512_128: - total: - calls: 1 - instructions: 4497163453 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_64_128: - total: - calls: 1 - instructions: 1041943727 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_blob_8_128: - total: - calls: 1 - instructions: 622232886 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_u64_blob8: - total: - calls: 1 - instructions: 685762802 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_u64_u64: - total: - calls: 1 - instructions: 697134664 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_u64_vec8: - total: - calls: 1 - instructions: 688048693 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec8_u64: - total: - calls: 1 - instructions: 775814595 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_1024_128: - total: - calls: 1 - instructions: 4314793483 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_128_128: - total: - calls: 1 - instructions: 1554207923 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_16_128: - total: - calls: 1 - instructions: 1026108707 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_256_128: - total: - calls: 1 - instructions: 2131957975 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_1024: - total: - calls: 1 - instructions: 1703124978 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_128: - total: - calls: 1 - instructions: 1102777839 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_16: - total: - calls: 1 - instructions: 944211580 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_256: - total: - calls: 1 - instructions: 1231083615 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_32: - total: - calls: 1 - instructions: 943092699 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_4: - total: - calls: 1 - instructions: 940356614 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_512: - total: - calls: 1 - instructions: 1394468405 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_64: - total: - calls: 1 - instructions: 986545822 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_32_8: - total: - calls: 1 - instructions: 943858686 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_4_128: - total: - calls: 1 - instructions: 536437378 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_512_128: - total: - calls: 1 - instructions: 2876049568 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_64_128: - total: - calls: 1 - instructions: 1258690704 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_pop_last_vec_8_128: - total: - calls: 1 - instructions: 865694095 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_count_1k_0b: - total: - calls: 1 - instructions: 16745 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_count_1k_10kib: - total: - calls: 1 - instructions: 2599671 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_count_20_10mib: - total: - calls: 1 - instructions: 20576285 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_key_sum_1k_0b: - total: - calls: 1 - instructions: 17104 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_key_sum_1k_10kib: - total: - calls: 1 - instructions: 57215658 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_key_sum_20_10mib: - total: - calls: 1 - instructions: 1105826200 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_value_sum_1k_0b: - total: - calls: 1 - instructions: 17118 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_value_sum_1k_10kib: - total: - calls: 1 - instructions: 57227654 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_range_value_sum_20_10mib: - total: - calls: 1 - instructions: 1105826436 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_10mib_values: - total: - calls: 1 - instructions: 4737371950 - heap_increase: 0 - stable_memory_increase: 657 - scopes: {} - btreemap_v2_remove_blob8_u64: - total: - calls: 1 - instructions: 606056710 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_1024_128: - total: - calls: 1 - instructions: 7421888863 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_128_128: - total: - calls: 1 - instructions: 1635342144 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_16_128: - total: - calls: 1 - instructions: 690775087 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_256_128: - total: - calls: 1 - instructions: 2469317746 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_1024: - total: - calls: 1 - instructions: 1018120605 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_128: - total: - calls: 1 - instructions: 782398055 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_16: - total: - calls: 1 - instructions: 735719719 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_256: - total: - calls: 1 - instructions: 818891031 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_32: - total: - calls: 1 - instructions: 747183764 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_4: - total: - calls: 1 - instructions: 732221311 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_512: - total: - calls: 1 - instructions: 891432150 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_64: - total: - calls: 1 - instructions: 774120262 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_32_8: - total: - calls: 1 - instructions: 732105855 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_4_128: - total: - calls: 1 - instructions: 468000926 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_512_128: - total: - calls: 1 - instructions: 4122884697 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_64_128: - total: - calls: 1 - instructions: 950218276 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_blob_8_128: - total: - calls: 1 - instructions: 623528283 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_u64_blob8: - total: - calls: 1 - instructions: 601729363 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_u64_u64: - total: - calls: 1 - instructions: 623942722 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_u64_vec8: - total: - calls: 1 - instructions: 607719707 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec8_u64: - total: - calls: 1 - instructions: 767231405 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_1024_128: - total: - calls: 1 - instructions: 4558259611 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_128_128: - total: - calls: 1 - instructions: 1461626995 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_16_128: - total: - calls: 1 - instructions: 929190130 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_256_128: - total: - calls: 1 - instructions: 2290487523 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_1024: - total: - calls: 1 - instructions: 1731690539 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_128: - total: - calls: 1 - instructions: 1068571017 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_16: - total: - calls: 1 - instructions: 891426401 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_256: - total: - calls: 1 - instructions: 1279117440 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_32: - total: - calls: 1 - instructions: 898887522 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_4: - total: - calls: 1 - instructions: 897962086 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_512: - total: - calls: 1 - instructions: 1443964173 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_64: - total: - calls: 1 - instructions: 979405970 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_32_8: - total: - calls: 1 - instructions: 892013373 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_4_128: - total: - calls: 1 - instructions: 669117034 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_512_128: - total: - calls: 1 - instructions: 3127395739 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_64_128: - total: - calls: 1 - instructions: 1188794438 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_remove_vec_8_128: - total: - calls: 1 - instructions: 837942733 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_iter_1k_0b: - total: - calls: 1 - instructions: 1539248 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_iter_1k_10kib: - total: - calls: 1 - instructions: 57053250 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_iter_20_10mib: - total: - calls: 1 - instructions: 1103719338 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_iter_rev_1k_0b: - total: - calls: 1 - instructions: 1540243 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_iter_rev_1k_10kib: - total: - calls: 1 - instructions: 57034269 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_iter_rev_20_10mib: - total: - calls: 1 - instructions: 1103718903 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_keys_1k_0b: - total: - calls: 1 - instructions: 1179996 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_keys_1k_10kib: - total: - calls: 1 - instructions: 2586983 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_keys_20_10mib: - total: - calls: 1 - instructions: 18469912 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_keys_rev_1k_0b: - total: - calls: 1 - instructions: 1179911 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_keys_rev_1k_10kib: - total: - calls: 1 - instructions: 2568038 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_keys_rev_20_10mib: - total: - calls: 1 - instructions: 18469898 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_values_1k_0b: - total: - calls: 1 - instructions: 1515586 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_values_1k_10kib: - total: - calls: 1 - instructions: 57029588 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_values_20_10mib: - total: - calls: 1 - instructions: 1103718868 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_values_rev_1k_0b: - total: - calls: 1 - instructions: 1517245 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_values_rev_1k_10kib: - total: - calls: 1 - instructions: 57011271 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} - btreemap_v2_scan_values_rev_20_10mib: - total: - calls: 1 - instructions: 1103718445 - heap_increase: 0 - stable_memory_increase: 0 + instructions: 1776019804 + heap_increase: 3507 + stable_memory_increase: 1665 scopes: {} version: 0.1.15 diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index be3615ef..261847cb 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -786,14 +786,27 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { } /* +| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | +|--------|--------------------------|-------|---------|---------|-------|--------|-------|---------| +| new | write_btreemap_100_elems | | 4.72B | | 3.22K | | 1.67K | | +| new | write_btreemap_10k_elems | | 6.61B | | 3.20K | | 1.67K | | +| new | write_btreemap_1_elems | | 1.49B | | 3.23K | | 1.67K | | +| new | write_btreemap_1m_elems | | 93.33B | | 3.51K | | 3.20K | | +| new | write_stable_100_elems | | 838.47M | | 3.22K | | 1.67K | | +| new | write_stable_10k_elems | | 984.59M | | 3.20K | | 1.67K | | +| new | write_stable_1_elem | | 838.35M | | 3.20K | | 1.67K | | +| new | write_stable_1m_elems | | 1.55B | | 3.51K | | 1.67K | | + | status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | |--------|-------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_1_elem | | 651.69M | | 1.64K | | 1.67K | | -| new | write_btreemap_1k_elems | | 5.06B | | 3.20K | | 1.67K | | -| new | write_btreemap_1m_elems | | 92.43B | | 3.51K | | 3.20K | | -| new | write_stable_1_elem | | 418.92M | | 1.60K | | 1.67K | | -| new | write_stable_1k_elems | | 977.14M | | 3.20K | | 1.67K | | -| new | write_stable_1m_elems | | 1.55B | | 3.51K | | 1.67K | | +| new | read_btreemap_100_elems | | 5.11B | | 3.22K | | 1.67K | | +| new | read_btreemap_10k_elems | | 7.66B | | 3.20K | | 1.67K | | +| new | read_btreemap_1_elem | | 1.64B | | 3.23K | | 1.67K | | +| new | read_btreemap_1m_elems | | 137.12B | | 3.51K | | 3.20K | | +| new | read_stable_100_elems | | 946.86M | | 3.22K | | 1.67K | | +| new | read_stable_10k_elems | | 1.09B | | 3.20K | | 1.67K | | +| new | read_stable_1_elems | | 1.23B | | 3.20K | | 1.67K | | +| new | read_stable_1m_elems | | 1.78B | | 3.51K | | 1.67K | | ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change */ @@ -826,23 +839,18 @@ fn chunk_data(n: usize) -> Vec> { } #[bench] -fn write_btreemap_1_elem() { - let mut map = BTreeMap::init(init_memory(4)); - let buf = vec![VALUE; SIZE]; - - bench_fn(|| { - map.insert(0_u32, buf); - }); +fn write_btreemap_1_elems() { + write_btreemap_chunks(10, 1); } #[bench] fn write_btreemap_1k_elems() { - write_btreemap_chunks(5, 1_000); + write_btreemap_chunks(11, 1_000); } #[bench] fn write_btreemap_1m_elems() { - write_btreemap_chunks(6, 1_000_000); + write_btreemap_chunks(12, 1_000_000); } fn write_btreemap_chunks(mem_id: u8, n: usize) { @@ -857,24 +865,43 @@ fn write_btreemap_chunks(mem_id: u8, n: usize) { } #[bench] -fn write_stable_1_elem() { - let memory = init_memory(1); - let buf = vec![VALUE; SIZE]; +fn read_btreemap_1_elem() { + read_btreemap_chunks(20, 1); +} + +#[bench] +fn read_btreemap_1k_elems() { + read_btreemap_chunks(21, 1_000); +} +#[bench] +fn read_btreemap_1m_elems() { + read_btreemap_chunks(22, 1_000_000); +} + +fn read_btreemap_chunks(mem_id: u8, n: usize) { + write_btreemap_chunks(mem_id, n); + let map: BTreeMap<_, Vec, _> = BTreeMap::init(init_memory(mem_id)); bench_fn(|| { - ensure_memory_size(&memory, SIZE); - memory.write(0, &buf); + for i in 0..n { + let _ = map.get(&(i as u32)); + } }); } +#[bench] +fn write_stable_1_elem() { + write_stable_chunks(30, 1); +} + #[bench] fn write_stable_1k_elems() { - write_stable_chunks(2, 1_000); + write_stable_chunks(31, 1_000); } #[bench] fn write_stable_1m_elems() { - write_stable_chunks(3, 1_000_000); + write_stable_chunks(32, 1_000_000); } fn write_stable_chunks(mem_id: u8, n: usize) { @@ -890,4 +917,33 @@ fn write_stable_chunks(mem_id: u8, n: usize) { }); } +#[bench] +fn read_stable_1_elems() { + read_stable_chunks(40, 1); +} + +#[bench] +fn read_stable_1k_elems() { + read_stable_chunks(41, 1_000); +} + +#[bench] +fn read_stable_1m_elems() { + read_stable_chunks(44, 1_000_000); +} + +fn read_stable_chunks(mem_id: u8, n: usize) { + write_stable_chunks(mem_id, n); + + let memory = init_memory(mem_id); + let chunk_size = SIZE / n; + let mut buf = vec![0u8; chunk_size]; + + bench_fn(|| { + for i in 0..n { + memory.read((i * chunk_size) as u64, &mut buf); + } + }); +} + fn main() {} From e35a25c18cef6cad9b5d417d230e2f20fce45c9d Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 17:55:28 +0200 Subject: [PATCH 14/25] . --- src/btreemap.rs | 8 ++------ src/storable.rs | 3 --- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 850cbc61..473978dd 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -498,17 +498,13 @@ where let value = value.to_bytes_checked().into_owned(); let root = if self.root_addr == NULL { - #[cfg(feature = "bench_scope")] - let _p = canbench_rs::bench_scope("insert_allocate_node"); // May add significant overhead. - // No root present. Allocate one. + // No root present. Allocate one. let node = self.allocate_node(NodeType::Leaf); self.root_addr = node.address(); self.save_header(); node } else { - #[cfg(feature = "bench_scope")] - let _p = canbench_rs::bench_scope("insert_load_node"); // May add significant overhead. - // Load the root from memory. + // Load the root from memory. let mut root = self.load_node(self.root_addr); // Check if the key already exists in the root. diff --git a/src/storable.rs b/src/storable.rs index a9bb9750..044ffa9a 100644 --- a/src/storable.rs +++ b/src/storable.rs @@ -25,9 +25,6 @@ pub trait Storable { /// Like `to_bytes`, but includes additional checks to ensure the element's serialized bytes /// are within the element's bounds. fn to_bytes_checked(&self) -> Cow<[u8]> { - #[cfg(feature = "bench_scope")] - let _p = canbench_rs::bench_scope("to_bytes_checked"); // May add significant overhead. - let bytes = self.to_bytes(); if let Bound::Bounded { max_size, From 2adb37223a332e7e3dc1efdaf040b6e3d014c821 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 17:56:01 +0200 Subject: [PATCH 15/25] . --- src/btreemap.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 473978dd..b0a86620 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -492,9 +492,6 @@ where /// key.to_bytes().len() <= max_size(Key) /// value.to_bytes().len() <= max_size(Value) pub fn insert(&mut self, key: K, value: V) -> Option { - #[cfg(feature = "bench_scope")] - let _p = canbench_rs::bench_scope("insert"); // May add significant overhead. - let value = value.to_bytes_checked().into_owned(); let root = if self.root_addr == NULL { @@ -547,9 +544,6 @@ where /// Inserts an entry into a node that is *not full*. fn insert_nonfull(&mut self, mut node: Node, key: K, value: Vec) -> Option> { - #[cfg(feature = "bench_scope")] - let _p = canbench_rs::bench_scope("insert_nonfull"); // May add significant overhead. - // We're guaranteed by the caller that the provided node is not full. assert!(!node.is_full()); From b931677411ea4763d8d74f6d2c5090886ae371fb Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 18:13:40 +0200 Subject: [PATCH 16/25] mv compare --- .github/workflows/ci.yml | 1 + benchmarks/Cargo.toml | 4 + benchmarks/btreemap/canbench_results.yml | 2003 +++++++++++++++++++++- benchmarks/btreemap/src/main.rs | 162 -- benchmarks/compare/canbench.yml | 3 + benchmarks/compare/canbench_results.yml | 86 + benchmarks/compare/src/main.rs | 142 ++ 7 files changed, 2207 insertions(+), 194 deletions(-) create mode 100644 benchmarks/compare/canbench.yml create mode 100644 benchmarks/compare/canbench_results.yml create mode 100644 benchmarks/compare/src/main.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 075f8149..957629de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,6 +88,7 @@ jobs: - btreemap - memory-manager - vec + - compare include: - name: btreemap project_dir: ./benchmarks/btreemap diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index 395463dc..755d19bd 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -29,3 +29,7 @@ path = "memory_manager/src/main.rs" [[bin]] name = "vec" path = "vec/src/main.rs" + +[[bin]] +name = "compare" +path = "compare/src/main.rs" diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 96dc4d3a..6abd993b 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -1,58 +1,1997 @@ benches: - read_btreemap_100_elems: + btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 5106651688 - heap_increase: 3216 - stable_memory_increase: 1665 + instructions: 142209883 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_btreemap_10k_elems: + btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 7660759692 - heap_increase: 3203 - stable_memory_increase: 1665 + instructions: 283243186 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_btreemap_1_elem: + btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 1640268014 - heap_increase: 3233 - stable_memory_increase: 1665 + instructions: 4294894392 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_btreemap_1m_elems: + btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 137122763075 - heap_increase: 3507 - stable_memory_increase: 3201 + instructions: 840909876 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_stable_100_elems: + btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 946863281 - heap_increase: 3216 - stable_memory_increase: 1665 + instructions: 300105736 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_stable_10k_elems: + btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1091369965 - heap_increase: 3203 - stable_memory_increase: 1665 + instructions: 1326771401 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_stable_1_elems: + btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 1232207354 - heap_increase: 3202 - stable_memory_increase: 1665 + instructions: 337445350 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} - read_stable_1m_elems: + btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 1776019804 - heap_increase: 3507 - stable_memory_increase: 1665 + instructions: 337242957 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_16: + total: + calls: 1 + instructions: 329500229 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_256: + total: + calls: 1 + instructions: 335682009 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_32: + total: + calls: 1 + instructions: 342487367 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_4: + total: + calls: 1 + instructions: 333741840 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_512: + total: + calls: 1 + instructions: 333192029 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_64: + total: + calls: 1 + instructions: 337617773 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_8: + total: + calls: 1 + instructions: 335387695 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_4_128: + total: + calls: 1 + instructions: 250355530 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_512_128: + total: + calls: 1 + instructions: 2298434691 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_64_128: + total: + calls: 1 + instructions: 419606574 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_8_128: + total: + calls: 1 + instructions: 273336147 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_u64_blob8: + total: + calls: 1 + instructions: 225499211 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_u64_u64: + total: + calls: 1 + instructions: 230729851 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_u64_vec8: + total: + calls: 1 + instructions: 225499211 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec8_u64: + total: + calls: 1 + instructions: 373974679 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_1024_128: + total: + calls: 1 + instructions: 1847543843 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_128_128: + total: + calls: 1 + instructions: 562946697 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_16_128: + total: + calls: 1 + instructions: 432781519 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_256_128: + total: + calls: 1 + instructions: 916951505 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_1024: + total: + calls: 1 + instructions: 516345708 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_128: + total: + calls: 1 + instructions: 437597039 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_16: + total: + calls: 1 + instructions: 367092396 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_256: + total: + calls: 1 + instructions: 445726845 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_32: + total: + calls: 1 + instructions: 367166163 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_4: + total: + calls: 1 + instructions: 366267458 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_512: + total: + calls: 1 + instructions: 480959847 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_64: + total: + calls: 1 + instructions: 407119037 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_8: + total: + calls: 1 + instructions: 366285313 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_4_128: + total: + calls: 1 + instructions: 398219523 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_512_128: + total: + calls: 1 + instructions: 1276595171 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_64_128: + total: + calls: 1 + instructions: 512370490 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_8_128: + total: + calls: 1 + instructions: 398244279 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_10mib_values: + total: + calls: 1 + instructions: 388595742 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob8_u64: + total: + calls: 1 + instructions: 294497964 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_1024_128: + total: + calls: 1 + instructions: 4434041253 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_128_128: + total: + calls: 1 + instructions: 874096444 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_16_128: + total: + calls: 1 + instructions: 313526179 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_256_128: + total: + calls: 1 + instructions: 1373148630 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_1024: + total: + calls: 1 + instructions: 357155881 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_128: + total: + calls: 1 + instructions: 351535572 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_16: + total: + calls: 1 + instructions: 340461038 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_256: + total: + calls: 1 + instructions: 351061577 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_32: + total: + calls: 1 + instructions: 353942159 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_4: + total: + calls: 1 + instructions: 343418312 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_512: + total: + calls: 1 + instructions: 350194697 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_64: + total: + calls: 1 + instructions: 350423636 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_8: + total: + calls: 1 + instructions: 345686334 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_4_128: + total: + calls: 1 + instructions: 262413920 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_512_128: + total: + calls: 1 + instructions: 2375697187 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_64_128: + total: + calls: 1 + instructions: 443018386 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_8_128: + total: + calls: 1 + instructions: 286466150 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_u64_blob8: + total: + calls: 1 + instructions: 235941207 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_u64_u64: + total: + calls: 1 + instructions: 242257567 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_u64_vec8: + total: + calls: 1 + instructions: 236688731 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec8_u64: + total: + calls: 1 + instructions: 383633031 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_1024_128: + total: + calls: 1 + instructions: 1895892021 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_128_128: + total: + calls: 1 + instructions: 575182491 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_16_128: + total: + calls: 1 + instructions: 442328780 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_256_128: + total: + calls: 1 + instructions: 929706179 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_1024: + total: + calls: 1 + instructions: 558668778 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_128: + total: + calls: 1 + instructions: 447698379 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_16: + total: + calls: 1 + instructions: 374638992 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_256: + total: + calls: 1 + instructions: 463244749 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_32: + total: + calls: 1 + instructions: 374845455 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_4: + total: + calls: 1 + instructions: 374022129 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_512: + total: + calls: 1 + instructions: 502894640 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_64: + total: + calls: 1 + instructions: 415510238 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_8: + total: + calls: 1 + instructions: 374044541 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_4_128: + total: + calls: 1 + instructions: 407171466 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_512_128: + total: + calls: 1 + instructions: 1289217055 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_64_128: + total: + calls: 1 + instructions: 523089683 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_8_128: + total: + calls: 1 + instructions: 407684851 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_insert_10mib_values: + total: + calls: 1 + instructions: 5251792410 + heap_increase: 322 + stable_memory_increase: 3613 + scopes: {} + btreemap_v2_insert_blob8_u64: + total: + calls: 1 + instructions: 451032102 + heap_increase: 0 + stable_memory_increase: 4 + scopes: {} + btreemap_v2_insert_blob_1024_128: + total: + calls: 1 + instructions: 5525788624 + heap_increase: 0 + stable_memory_increase: 196 + scopes: {} + btreemap_v2_insert_blob_128_128: + total: + calls: 1 + instructions: 1208821724 + heap_increase: 0 + stable_memory_increase: 46 + scopes: {} + btreemap_v2_insert_blob_16_128: + total: + calls: 1 + instructions: 500591510 + heap_increase: 0 + stable_memory_increase: 24 + scopes: {} + btreemap_v2_insert_blob_256_128: + total: + calls: 1 + instructions: 1817436957 + heap_increase: 0 + stable_memory_increase: 67 + scopes: {} + btreemap_v2_insert_blob_32_1024: + total: + calls: 1 + instructions: 724849516 + heap_increase: 0 + stable_memory_increase: 173 + scopes: {} + btreemap_v2_insert_blob_32_128: + total: + calls: 1 + instructions: 563513821 + heap_increase: 0 + stable_memory_increase: 28 + scopes: {} + btreemap_v2_insert_blob_32_16: + total: + calls: 1 + instructions: 539411394 + heap_increase: 0 + stable_memory_increase: 11 + scopes: {} + btreemap_v2_insert_blob_32_256: + total: + calls: 1 + instructions: 592917952 + heap_increase: 0 + stable_memory_increase: 49 + scopes: {} + btreemap_v2_insert_blob_32_32: + total: + calls: 1 + instructions: 550204854 + heap_increase: 0 + stable_memory_increase: 13 + scopes: {} + btreemap_v2_insert_blob_32_4: + total: + calls: 1 + instructions: 530054248 + heap_increase: 0 + stable_memory_increase: 8 + scopes: {} + btreemap_v2_insert_blob_32_512: + total: + calls: 1 + instructions: 631334646 + heap_increase: 0 + stable_memory_increase: 91 + scopes: {} + btreemap_v2_insert_blob_32_64: + total: + calls: 1 + instructions: 556446417 + heap_increase: 0 + stable_memory_increase: 18 + scopes: {} + btreemap_v2_insert_blob_32_8: + total: + calls: 1 + instructions: 538691053 + heap_increase: 0 + stable_memory_increase: 9 + scopes: {} + btreemap_v2_insert_blob_4_128: + total: + calls: 1 + instructions: 421160972 + heap_increase: 0 + stable_memory_increase: 13 + scopes: {} + btreemap_v2_insert_blob_512_128: + total: + calls: 1 + instructions: 3070369278 + heap_increase: 0 + stable_memory_increase: 111 + scopes: {} + btreemap_v2_insert_blob_64_128: + total: + calls: 1 + instructions: 687224486 + heap_increase: 0 + stable_memory_increase: 34 + scopes: {} + btreemap_v2_insert_blob_8_128: + total: + calls: 1 + instructions: 473325576 + heap_increase: 0 + stable_memory_increase: 20 + scopes: {} + btreemap_v2_insert_u64_blob8: + total: + calls: 1 + instructions: 424856496 + heap_increase: 0 + stable_memory_increase: 5 + scopes: {} + btreemap_v2_insert_u64_u64: + total: + calls: 1 + instructions: 433078328 + heap_increase: 0 + stable_memory_increase: 6 + scopes: {} + btreemap_v2_insert_u64_vec8: + total: + calls: 1 + instructions: 433606280 + heap_increase: 0 + stable_memory_increase: 21 + scopes: {} + btreemap_v2_insert_vec8_u64: + total: + calls: 1 + instructions: 596675651 + heap_increase: 0 + stable_memory_increase: 16 + scopes: {} + btreemap_v2_insert_vec_1024_128: + total: + calls: 1 + instructions: 2791324761 + heap_increase: 0 + stable_memory_increase: 193 + scopes: {} + btreemap_v2_insert_vec_128_128: + total: + calls: 1 + instructions: 1043141925 + heap_increase: 0 + stable_memory_increase: 51 + scopes: {} + btreemap_v2_insert_vec_16_128: + total: + calls: 1 + instructions: 719668309 + heap_increase: 0 + stable_memory_increase: 31 + scopes: {} + btreemap_v2_insert_vec_256_128: + total: + calls: 1 + instructions: 1425303710 + heap_increase: 0 + stable_memory_increase: 71 + scopes: {} + btreemap_v2_insert_vec_32_1024: + total: + calls: 1 + instructions: 1245182314 + heap_increase: 0 + stable_memory_increase: 171 + scopes: {} + btreemap_v2_insert_vec_32_128: + total: + calls: 1 + instructions: 783650019 + heap_increase: 0 + stable_memory_increase: 33 + scopes: {} + btreemap_v2_insert_vec_32_16: + total: + calls: 1 + instructions: 688714475 + heap_increase: 0 + stable_memory_increase: 20 + scopes: {} + btreemap_v2_insert_vec_32_256: + total: + calls: 1 + instructions: 908090400 + heap_increase: 0 + stable_memory_increase: 54 + scopes: {} + btreemap_v2_insert_vec_32_32: + total: + calls: 1 + instructions: 684433848 + heap_increase: 0 + stable_memory_increase: 20 + scopes: {} + btreemap_v2_insert_vec_32_4: + total: + calls: 1 + instructions: 683382635 + heap_increase: 0 + stable_memory_increase: 20 + scopes: {} + btreemap_v2_insert_vec_32_512: + total: + calls: 1 + instructions: 1026429798 + heap_increase: 0 + stable_memory_increase: 91 + scopes: {} + btreemap_v2_insert_vec_32_64: + total: + calls: 1 + instructions: 717127989 + heap_increase: 0 + stable_memory_increase: 24 + scopes: {} + btreemap_v2_insert_vec_32_8: + total: + calls: 1 + instructions: 682695838 + heap_increase: 0 + stable_memory_increase: 20 + scopes: {} + btreemap_v2_insert_vec_4_128: + total: + calls: 1 + instructions: 621403101 + heap_increase: 0 + stable_memory_increase: 16 + scopes: {} + btreemap_v2_insert_vec_512_128: + total: + calls: 1 + instructions: 1902984657 + heap_increase: 0 + stable_memory_increase: 112 + scopes: {} + btreemap_v2_insert_vec_64_128: + total: + calls: 1 + instructions: 874468583 + heap_increase: 0 + stable_memory_increase: 41 + scopes: {} + btreemap_v2_insert_vec_8_128: + total: + calls: 1 + instructions: 680539918 + heap_increase: 0 + stable_memory_increase: 23 + scopes: {} + btreemap_v2_mem_manager_contains_blob512_u64: + total: + calls: 1 + instructions: 2393561731 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_contains_u64_blob512: + total: + calls: 1 + instructions: 301490930 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_contains_u64_u64: + total: + calls: 1 + instructions: 306627816 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_contains_u64_vec512: + total: + calls: 1 + instructions: 389757738 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_contains_vec512_u64: + total: + calls: 1 + instructions: 1263289436 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_get_blob512_u64: + total: + calls: 1 + instructions: 2480010677 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_get_u64_blob512: + total: + calls: 1 + instructions: 318984422 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_get_u64_u64: + total: + calls: 1 + instructions: 319753693 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_get_u64_vec512: + total: + calls: 1 + instructions: 416829257 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_get_vec512_u64: + total: + calls: 1 + instructions: 1307093929 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_insert_blob512_u64: + total: + calls: 1 + instructions: 3189283499 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_insert_u64_blob512: + total: + calls: 1 + instructions: 647090916 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_insert_u64_u64: + total: + calls: 1 + instructions: 560416018 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_insert_u64_vec512: + total: + calls: 1 + instructions: 900560613 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_insert_vec512_u64: + total: + calls: 1 + instructions: 2032213941 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_remove_blob512_u64: + total: + calls: 1 + instructions: 4412188235 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_remove_u64_blob512: + total: + calls: 1 + instructions: 950509465 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_remove_u64_u64: + total: + calls: 1 + instructions: 808272557 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_remove_u64_vec512: + total: + calls: 1 + instructions: 1289646675 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_mem_manager_remove_vec512_u64: + total: + calls: 1 + instructions: 3183910603 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob8_u64: + total: + calls: 1 + instructions: 622200615 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_1024_128: + total: + calls: 1 + instructions: 8431485310 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_128_128: + total: + calls: 1 + instructions: 1868788897 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_16_128: + total: + calls: 1 + instructions: 765976333 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_256_128: + total: + calls: 1 + instructions: 2807125761 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_1024: + total: + calls: 1 + instructions: 1151786004 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_128: + total: + calls: 1 + instructions: 895271314 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_16: + total: + calls: 1 + instructions: 830179005 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_256: + total: + calls: 1 + instructions: 924008113 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_32: + total: + calls: 1 + instructions: 844939941 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_4: + total: + calls: 1 + instructions: 813445762 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_512: + total: + calls: 1 + instructions: 988660808 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_64: + total: + calls: 1 + instructions: 853670232 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_8: + total: + calls: 1 + instructions: 831827208 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_4_128: + total: + calls: 1 + instructions: 382997168 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_512_128: + total: + calls: 1 + instructions: 4656589101 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_64_128: + total: + calls: 1 + instructions: 1070297882 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_8_128: + total: + calls: 1 + instructions: 626229708 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_u64_blob8: + total: + calls: 1 + instructions: 704655932 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_u64_u64: + total: + calls: 1 + instructions: 716277147 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_u64_vec8: + total: + calls: 1 + instructions: 707209318 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec8_u64: + total: + calls: 1 + instructions: 798415678 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_1024_128: + total: + calls: 1 + instructions: 4088132406 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_128_128: + total: + calls: 1 + instructions: 1540235593 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_16_128: + total: + calls: 1 + instructions: 1038779442 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_256_128: + total: + calls: 1 + instructions: 2058259562 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_1024: + total: + calls: 1 + instructions: 1720412114 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_128: + total: + calls: 1 + instructions: 1121742438 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_16: + total: + calls: 1 + instructions: 965011199 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_256: + total: + calls: 1 + instructions: 1248136179 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_32: + total: + calls: 1 + instructions: 961152870 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_4: + total: + calls: 1 + instructions: 954455325 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_512: + total: + calls: 1 + instructions: 1404132606 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_64: + total: + calls: 1 + instructions: 1005109166 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_8: + total: + calls: 1 + instructions: 965763854 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_4_128: + total: + calls: 1 + instructions: 546598473 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_512_128: + total: + calls: 1 + instructions: 2756486259 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_64_128: + total: + calls: 1 + instructions: 1266073864 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_8_128: + total: + calls: 1 + instructions: 859841368 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob8_u64: + total: + calls: 1 + instructions: 602347043 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_1024_128: + total: + calls: 1 + instructions: 8114668993 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_128_128: + total: + calls: 1 + instructions: 1802553212 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_16_128: + total: + calls: 1 + instructions: 742006771 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_256_128: + total: + calls: 1 + instructions: 2718413554 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_1024: + total: + calls: 1 + instructions: 1117676359 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_128: + total: + calls: 1 + instructions: 862736782 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_16: + total: + calls: 1 + instructions: 805611949 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_256: + total: + calls: 1 + instructions: 895496993 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_32: + total: + calls: 1 + instructions: 815542518 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_4: + total: + calls: 1 + instructions: 793647234 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_512: + total: + calls: 1 + instructions: 965231966 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_64: + total: + calls: 1 + instructions: 829954997 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_8: + total: + calls: 1 + instructions: 807341792 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_4_128: + total: + calls: 1 + instructions: 371628597 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_512_128: + total: + calls: 1 + instructions: 4497163453 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_64_128: + total: + calls: 1 + instructions: 1041943727 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_8_128: + total: + calls: 1 + instructions: 622232886 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_u64_blob8: + total: + calls: 1 + instructions: 685762802 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_u64_u64: + total: + calls: 1 + instructions: 697134664 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_u64_vec8: + total: + calls: 1 + instructions: 688048693 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec8_u64: + total: + calls: 1 + instructions: 775814595 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_1024_128: + total: + calls: 1 + instructions: 4314793483 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_128_128: + total: + calls: 1 + instructions: 1554207923 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_16_128: + total: + calls: 1 + instructions: 1026108707 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_256_128: + total: + calls: 1 + instructions: 2131957975 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_1024: + total: + calls: 1 + instructions: 1703124978 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_128: + total: + calls: 1 + instructions: 1102777839 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_16: + total: + calls: 1 + instructions: 944211580 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_256: + total: + calls: 1 + instructions: 1231083615 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_32: + total: + calls: 1 + instructions: 943092699 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_4: + total: + calls: 1 + instructions: 940356614 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_512: + total: + calls: 1 + instructions: 1394468405 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_64: + total: + calls: 1 + instructions: 986545822 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_8: + total: + calls: 1 + instructions: 943858686 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_4_128: + total: + calls: 1 + instructions: 536437378 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_512_128: + total: + calls: 1 + instructions: 2876049568 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_64_128: + total: + calls: 1 + instructions: 1258690704 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_8_128: + total: + calls: 1 + instructions: 865694095 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_count_1k_0b: + total: + calls: 1 + instructions: 16745 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_count_1k_10kib: + total: + calls: 1 + instructions: 2599671 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_count_20_10mib: + total: + calls: 1 + instructions: 20576285 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_key_sum_1k_0b: + total: + calls: 1 + instructions: 17104 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_key_sum_1k_10kib: + total: + calls: 1 + instructions: 57215658 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_key_sum_20_10mib: + total: + calls: 1 + instructions: 1105826200 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_value_sum_1k_0b: + total: + calls: 1 + instructions: 17118 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_value_sum_1k_10kib: + total: + calls: 1 + instructions: 57227654 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_range_value_sum_20_10mib: + total: + calls: 1 + instructions: 1105826436 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_10mib_values: + total: + calls: 1 + instructions: 4737371950 + heap_increase: 0 + stable_memory_increase: 657 + scopes: {} + btreemap_v2_remove_blob8_u64: + total: + calls: 1 + instructions: 606056710 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_1024_128: + total: + calls: 1 + instructions: 7421888863 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_128_128: + total: + calls: 1 + instructions: 1635342144 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_16_128: + total: + calls: 1 + instructions: 690775087 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_256_128: + total: + calls: 1 + instructions: 2469317746 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_1024: + total: + calls: 1 + instructions: 1018120605 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_128: + total: + calls: 1 + instructions: 782398055 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_16: + total: + calls: 1 + instructions: 735719719 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_256: + total: + calls: 1 + instructions: 818891031 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_32: + total: + calls: 1 + instructions: 747183764 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_4: + total: + calls: 1 + instructions: 732221311 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_512: + total: + calls: 1 + instructions: 891432150 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_64: + total: + calls: 1 + instructions: 774120262 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_8: + total: + calls: 1 + instructions: 732105855 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_4_128: + total: + calls: 1 + instructions: 468000926 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_512_128: + total: + calls: 1 + instructions: 4122884697 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_64_128: + total: + calls: 1 + instructions: 950218276 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_8_128: + total: + calls: 1 + instructions: 623528283 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_u64_blob8: + total: + calls: 1 + instructions: 601729363 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_u64_u64: + total: + calls: 1 + instructions: 623942722 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_u64_vec8: + total: + calls: 1 + instructions: 607719707 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec8_u64: + total: + calls: 1 + instructions: 767231405 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_1024_128: + total: + calls: 1 + instructions: 4558259611 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_128_128: + total: + calls: 1 + instructions: 1461626995 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_16_128: + total: + calls: 1 + instructions: 929190130 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_256_128: + total: + calls: 1 + instructions: 2290487523 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_1024: + total: + calls: 1 + instructions: 1731690539 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_128: + total: + calls: 1 + instructions: 1068571017 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_16: + total: + calls: 1 + instructions: 891426401 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_256: + total: + calls: 1 + instructions: 1279117440 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_32: + total: + calls: 1 + instructions: 898887522 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_4: + total: + calls: 1 + instructions: 897962086 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_512: + total: + calls: 1 + instructions: 1443964173 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_64: + total: + calls: 1 + instructions: 979405970 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_8: + total: + calls: 1 + instructions: 892013373 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_4_128: + total: + calls: 1 + instructions: 669117034 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_512_128: + total: + calls: 1 + instructions: 3127395739 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_64_128: + total: + calls: 1 + instructions: 1188794438 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_8_128: + total: + calls: 1 + instructions: 837942733 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_iter_1k_0b: + total: + calls: 1 + instructions: 1539248 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_iter_1k_10kib: + total: + calls: 1 + instructions: 57053250 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_iter_20_10mib: + total: + calls: 1 + instructions: 1103719338 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_iter_rev_1k_0b: + total: + calls: 1 + instructions: 1540243 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_iter_rev_1k_10kib: + total: + calls: 1 + instructions: 57034269 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_iter_rev_20_10mib: + total: + calls: 1 + instructions: 1103718903 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_keys_1k_0b: + total: + calls: 1 + instructions: 1179996 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_keys_1k_10kib: + total: + calls: 1 + instructions: 2586983 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_keys_20_10mib: + total: + calls: 1 + instructions: 18469912 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_keys_rev_1k_0b: + total: + calls: 1 + instructions: 1179911 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_keys_rev_1k_10kib: + total: + calls: 1 + instructions: 2568038 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_keys_rev_20_10mib: + total: + calls: 1 + instructions: 18469898 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_values_1k_0b: + total: + calls: 1 + instructions: 1515586 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_values_1k_10kib: + total: + calls: 1 + instructions: 57029588 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_values_20_10mib: + total: + calls: 1 + instructions: 1103718868 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_values_rev_1k_0b: + total: + calls: 1 + instructions: 1517245 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_values_rev_1k_10kib: + total: + calls: 1 + instructions: 57011271 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_scan_values_rev_20_10mib: + total: + calls: 1 + instructions: 1103718445 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} version: 0.1.15 diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 261847cb..fb1867b4 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -784,166 +784,4 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { .count() }) } - -/* -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|--------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | write_btreemap_100_elems | | 4.72B | | 3.22K | | 1.67K | | -| new | write_btreemap_10k_elems | | 6.61B | | 3.20K | | 1.67K | | -| new | write_btreemap_1_elems | | 1.49B | | 3.23K | | 1.67K | | -| new | write_btreemap_1m_elems | | 93.33B | | 3.51K | | 3.20K | | -| new | write_stable_100_elems | | 838.47M | | 3.22K | | 1.67K | | -| new | write_stable_10k_elems | | 984.59M | | 3.20K | | 1.67K | | -| new | write_stable_1_elem | | 838.35M | | 3.20K | | 1.67K | | -| new | write_stable_1m_elems | | 1.55B | | 3.51K | | 1.67K | | - -| status | name | calls | ins | ins Δ% | HI | HI Δ% | SMI | SMI Δ% | -|--------|-------------------------|-------|---------|---------|-------|--------|-------|---------| -| new | read_btreemap_100_elems | | 5.11B | | 3.22K | | 1.67K | | -| new | read_btreemap_10k_elems | | 7.66B | | 3.20K | | 1.67K | | -| new | read_btreemap_1_elem | | 1.64B | | 3.23K | | 1.67K | | -| new | read_btreemap_1m_elems | | 137.12B | | 3.51K | | 3.20K | | -| new | read_stable_100_elems | | 946.86M | | 3.22K | | 1.67K | | -| new | read_stable_10k_elems | | 1.09B | | 3.20K | | 1.67K | | -| new | read_stable_1_elems | | 1.23B | | 3.20K | | 1.67K | | -| new | read_stable_1m_elems | | 1.78B | | 3.51K | | 1.67K | | - -ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change -*/ -use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; - -const SIZE: usize = 100 * 1024 * 1024; -const VALUE: u8 = 37; - -fn page_align(bytes: usize) -> u64 { - bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64 -} - -fn init_memory(id: u8) -> impl ic_stable_structures::Memory { - MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(id)) -} - -fn ensure_memory_size(memory: &impl ic_stable_structures::Memory, size: usize) { - let required = page_align(size); - if memory.size() < required { - memory.grow(required - memory.size()); - } -} - -fn chunk_data(n: usize) -> Vec> { - let chunk_size = SIZE / n; - vec![VALUE; SIZE] - .chunks(chunk_size) - .map(|c| c.to_vec()) - .collect() -} - -#[bench] -fn write_btreemap_1_elems() { - write_btreemap_chunks(10, 1); -} - -#[bench] -fn write_btreemap_1k_elems() { - write_btreemap_chunks(11, 1_000); -} - -#[bench] -fn write_btreemap_1m_elems() { - write_btreemap_chunks(12, 1_000_000); -} - -fn write_btreemap_chunks(mem_id: u8, n: usize) { - let mut map = BTreeMap::init(init_memory(mem_id)); - let chunks = chunk_data(n); - - bench_fn(|| { - for (i, chunk) in chunks.into_iter().enumerate() { - map.insert(i as u32, chunk); - } - }); -} - -#[bench] -fn read_btreemap_1_elem() { - read_btreemap_chunks(20, 1); -} - -#[bench] -fn read_btreemap_1k_elems() { - read_btreemap_chunks(21, 1_000); -} - -#[bench] -fn read_btreemap_1m_elems() { - read_btreemap_chunks(22, 1_000_000); -} - -fn read_btreemap_chunks(mem_id: u8, n: usize) { - write_btreemap_chunks(mem_id, n); - let map: BTreeMap<_, Vec, _> = BTreeMap::init(init_memory(mem_id)); - bench_fn(|| { - for i in 0..n { - let _ = map.get(&(i as u32)); - } - }); -} - -#[bench] -fn write_stable_1_elem() { - write_stable_chunks(30, 1); -} - -#[bench] -fn write_stable_1k_elems() { - write_stable_chunks(31, 1_000); -} - -#[bench] -fn write_stable_1m_elems() { - write_stable_chunks(32, 1_000_000); -} - -fn write_stable_chunks(mem_id: u8, n: usize) { - let memory = init_memory(mem_id); - let chunks = chunk_data(n); - let chunk_size = SIZE / n; - - bench_fn(|| { - ensure_memory_size(&memory, SIZE); - for (i, chunk) in chunks.iter().enumerate() { - memory.write((i * chunk_size) as u64, chunk); - } - }); -} - -#[bench] -fn read_stable_1_elems() { - read_stable_chunks(40, 1); -} - -#[bench] -fn read_stable_1k_elems() { - read_stable_chunks(41, 1_000); -} - -#[bench] -fn read_stable_1m_elems() { - read_stable_chunks(44, 1_000_000); -} - -fn read_stable_chunks(mem_id: u8, n: usize) { - write_stable_chunks(mem_id, n); - - let memory = init_memory(mem_id); - let chunk_size = SIZE / n; - let mut buf = vec![0u8; chunk_size]; - - bench_fn(|| { - for i in 0..n { - memory.read((i * chunk_size) as u64, &mut buf); - } - }); -} - fn main() {} diff --git a/benchmarks/compare/canbench.yml b/benchmarks/compare/canbench.yml new file mode 100644 index 00000000..6cc092ab --- /dev/null +++ b/benchmarks/compare/canbench.yml @@ -0,0 +1,3 @@ +build_cmd: cargo build -p benchmarks --release --target wasm32-unknown-unknown + +wasm_path: ../../target/wasm32-unknown-unknown/release/compare.wasm diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml new file mode 100644 index 00000000..dc72818a --- /dev/null +++ b/benchmarks/compare/canbench_results.yml @@ -0,0 +1,86 @@ +benches: + read_chunks_btreemap_1: + total: + calls: 1 + instructions: 1639628661 + heap_increase: 3233 + stable_memory_increase: 1665 + scopes: {} + read_chunks_btreemap_1k: + total: + calls: 1 + instructions: 5983244986 + heap_increase: 3201 + stable_memory_increase: 1665 + scopes: {} + read_chunks_btreemap_1m: + total: + calls: 1 + instructions: 137082778071 + heap_increase: 3507 + stable_memory_increase: 3201 + scopes: {} + read_chunks_stable_1: + total: + calls: 1 + instructions: 1232198974 + heap_increase: 3202 + stable_memory_increase: 1665 + scopes: {} + read_chunks_stable_1k: + total: + calls: 1 + instructions: 1083042314 + heap_increase: 3201 + stable_memory_increase: 1665 + scopes: {} + read_chunks_stable_1m: + total: + calls: 1 + instructions: 1776011424 + heap_increase: 3507 + stable_memory_increase: 1665 + scopes: {} + write_chunks_btreemap_1: + total: + calls: 1 + instructions: 1490269078 + heap_increase: 3233 + stable_memory_increase: 1665 + scopes: {} + write_chunks_btreemap_1k: + total: + calls: 1 + instructions: 5483248806 + heap_increase: 3201 + stable_memory_increase: 1665 + scopes: {} + write_chunks_btreemap_1m: + total: + calls: 1 + instructions: 93290148614 + heap_increase: 3507 + stable_memory_increase: 3201 + scopes: {} + write_chunks_stable_1: + total: + calls: 1 + instructions: 838346069 + heap_increase: 3202 + stable_memory_increase: 1665 + scopes: {} + write_chunks_stable_1k: + total: + calls: 1 + instructions: 977132812 + heap_increase: 3201 + stable_memory_increase: 1665 + scopes: {} + write_chunks_stable_1m: + total: + calls: 1 + instructions: 1545373069 + heap_increase: 3507 + stable_memory_increase: 1665 + scopes: {} +version: 0.1.15 diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs new file mode 100644 index 00000000..ab7cfe8d --- /dev/null +++ b/benchmarks/compare/src/main.rs @@ -0,0 +1,142 @@ +use canbench_rs::{bench, bench_fn}; +use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; +use ic_stable_structures::{ + memory_manager::{MemoryId, MemoryManager}, + BTreeMap, DefaultMemoryImpl, Memory, +}; + +const SIZE: usize = 100 * 1024 * 1024; +const VALUE: u8 = 37; + +fn page_align(bytes: usize) -> u64 { + bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64 +} + +fn init_memory(id: u8) -> impl ic_stable_structures::Memory { + MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(id)) +} + +fn ensure_memory_size(memory: &impl ic_stable_structures::Memory, size: usize) { + let required = page_align(size); + if memory.size() < required { + memory.grow(required - memory.size()); + } +} + +fn chunk_data(n: usize) -> Vec> { + let chunk_size = SIZE / n; + vec![VALUE; SIZE] + .chunks(chunk_size) + .map(|c| c.to_vec()) + .collect() +} + +#[bench] +fn write_chunks_stable_1() { + write_chunks_stable(30, 1); +} + +#[bench] +fn write_chunks_stable_1k() { + write_chunks_stable(31, 1_000); +} + +#[bench] +fn write_chunks_stable_1m() { + write_chunks_stable(32, 1_000_000); +} + +fn write_chunks_stable(mem_id: u8, n: usize) { + let memory = init_memory(mem_id); + let chunks = chunk_data(n); + let chunk_size = SIZE / n; + + bench_fn(|| { + ensure_memory_size(&memory, SIZE); + for (i, chunk) in chunks.iter().enumerate() { + memory.write((i * chunk_size) as u64, chunk); + } + }); +} + +#[bench] +fn read_chunks_stable_1() { + read_chunks_stable(40, 1); +} + +#[bench] +fn read_chunks_stable_1k() { + read_chunks_stable(41, 1_000); +} + +#[bench] +fn read_chunks_stable_1m() { + read_chunks_stable(44, 1_000_000); +} + +fn read_chunks_stable(mem_id: u8, n: usize) { + write_chunks_stable(mem_id, n); + + let memory = init_memory(mem_id); + let chunk_size = SIZE / n; + let mut buf = vec![0u8; chunk_size]; + + bench_fn(|| { + for i in 0..n { + memory.read((i * chunk_size) as u64, &mut buf); + } + }); +} + +#[bench] +fn write_chunks_btreemap_1() { + write_chunks_btreemap(10, 1); +} + +#[bench] +fn write_chunks_btreemap_1k() { + write_chunks_btreemap(11, 1_000); +} + +#[bench] +fn write_chunks_btreemap_1m() { + write_chunks_btreemap(12, 1_000_000); +} + +fn write_chunks_btreemap(mem_id: u8, n: usize) { + let mut map = BTreeMap::init(init_memory(mem_id)); + let chunks = chunk_data(n); + + bench_fn(|| { + for (i, chunk) in chunks.into_iter().enumerate() { + map.insert(i as u32, chunk); + } + }); +} + +#[bench] +fn read_chunks_btreemap_1() { + read_chunks_btreemap(20, 1); +} + +#[bench] +fn read_chunks_btreemap_1k() { + read_chunks_btreemap(21, 1_000); +} + +#[bench] +fn read_chunks_btreemap_1m() { + read_chunks_btreemap(22, 1_000_000); +} + +fn read_chunks_btreemap(mem_id: u8, n: usize) { + write_chunks_btreemap(mem_id, n); + let map: BTreeMap<_, Vec, _> = BTreeMap::init(init_memory(mem_id)); + bench_fn(|| { + for i in 0..n { + let _ = map.get(&(i as u32)); + } + }); +} + +fn main() {} From 2f7bd00637974b7e0a9aace1186b681e37542514 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 18:14:07 +0200 Subject: [PATCH 17/25] . --- benchmarks/btreemap/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index fb1867b4..6c348ca2 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -784,4 +784,5 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { .count() }) } + fn main() {} From 22f6bf0ab128acdb70247bc033d932f4bd002796 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 18:20:30 +0200 Subject: [PATCH 18/25] cleanup --- benchmarks/compare/canbench_results.yml | 48 ++++----- benchmarks/compare/src/main.rs | 124 ++++++++++++------------ 2 files changed, 84 insertions(+), 88 deletions(-) diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index dc72818a..5cdbc321 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -2,85 +2,85 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 1639628661 - heap_increase: 3233 + instructions: 1639628849 + heap_increase: 4834 stable_memory_increase: 1665 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 5983244986 - heap_increase: 3201 + instructions: 5868571006 + heap_increase: 1638 stable_memory_increase: 1665 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 137082778071 - heap_increase: 3507 + instructions: 135360202221 + heap_increase: 1892 stable_memory_increase: 3201 scopes: {} read_chunks_stable_1: total: calls: 1 - instructions: 1232198974 - heap_increase: 3202 + instructions: 812767514 + heap_increase: 1601 stable_memory_increase: 1665 scopes: {} read_chunks_stable_1k: total: calls: 1 - instructions: 1083042314 - heap_increase: 3201 + instructions: 525926853 + heap_increase: 1600 stable_memory_increase: 1665 scopes: {} read_chunks_stable_1m: total: calls: 1 - instructions: 1776011424 - heap_increase: 3507 + instructions: 1307625987 + heap_increase: 1892 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1: total: calls: 1 - instructions: 1490269078 - heap_increase: 3233 + instructions: 1490269266 + heap_increase: 4834 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 5483248806 - heap_increase: 3201 + instructions: 5368581984 + heap_increase: 1638 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 93290148614 - heap_increase: 3507 + instructions: 91593809891 + heap_increase: 1892 stable_memory_increase: 3201 scopes: {} write_chunks_stable_1: total: calls: 1 - instructions: 838346069 - heap_increase: 3202 + instructions: 418914609 + heap_increase: 1601 stable_memory_increase: 1665 scopes: {} write_chunks_stable_1k: total: calls: 1 - instructions: 977132812 - heap_increase: 3201 + instructions: 420017351 + heap_increase: 1600 stable_memory_increase: 1665 scopes: {} write_chunks_stable_1m: total: calls: 1 - instructions: 1545373069 - heap_increase: 3507 + instructions: 1076987632 + heap_increase: 1892 stable_memory_increase: 1665 scopes: {} version: 0.1.15 diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index ab7cfe8d..97477ab3 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -12,11 +12,11 @@ fn page_align(bytes: usize) -> u64 { bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64 } -fn init_memory(id: u8) -> impl ic_stable_structures::Memory { +fn init_memory(id: u8) -> impl Memory { MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(id)) } -fn ensure_memory_size(memory: &impl ic_stable_structures::Memory, size: usize) { +fn ensure_memory_size(memory: &impl Memory, size: usize) { let required = page_align(size); if memory.size() < required { memory.grow(required - memory.size()); @@ -25,25 +25,7 @@ fn ensure_memory_size(memory: &impl ic_stable_structures::Memory, size: usize) { fn chunk_data(n: usize) -> Vec> { let chunk_size = SIZE / n; - vec![VALUE; SIZE] - .chunks(chunk_size) - .map(|c| c.to_vec()) - .collect() -} - -#[bench] -fn write_chunks_stable_1() { - write_chunks_stable(30, 1); -} - -#[bench] -fn write_chunks_stable_1k() { - write_chunks_stable(31, 1_000); -} - -#[bench] -fn write_chunks_stable_1m() { - write_chunks_stable(32, 1_000_000); + (0..n).map(|_| vec![VALUE; chunk_size]).collect() } fn write_chunks_stable(mem_id: u8, n: usize) { @@ -59,24 +41,8 @@ fn write_chunks_stable(mem_id: u8, n: usize) { }); } -#[bench] -fn read_chunks_stable_1() { - read_chunks_stable(40, 1); -} - -#[bench] -fn read_chunks_stable_1k() { - read_chunks_stable(41, 1_000); -} - -#[bench] -fn read_chunks_stable_1m() { - read_chunks_stable(44, 1_000_000); -} - fn read_chunks_stable(mem_id: u8, n: usize) { write_chunks_stable(mem_id, n); - let memory = init_memory(mem_id); let chunk_size = SIZE / n; let mut buf = vec![0u8; chunk_size]; @@ -88,55 +54,85 @@ fn read_chunks_stable(mem_id: u8, n: usize) { }); } +fn write_chunks_btreemap(mem_id: u8, n: usize) { + let mut map = BTreeMap::init(init_memory(mem_id)); + let chunks = chunk_data(n); + + bench_fn(|| { + for (i, chunk) in chunks.into_iter().enumerate() { + map.insert(i as u32, chunk); + } + }); +} + +fn read_chunks_btreemap(mem_id: u8, n: usize) { + write_chunks_btreemap(mem_id, n); + let map: BTreeMap<_, Vec, _> = BTreeMap::init(init_memory(mem_id)); + bench_fn(|| { + for i in 0..n { + let _ = map.get(&(i as u32)); + } + }); +} + #[bench] -fn write_chunks_btreemap_1() { - write_chunks_btreemap(10, 1); +fn write_chunks_stable_1() { + write_chunks_stable(10, 1); } #[bench] -fn write_chunks_btreemap_1k() { - write_chunks_btreemap(11, 1_000); +fn write_chunks_stable_1k() { + write_chunks_stable(11, 1_000); } #[bench] -fn write_chunks_btreemap_1m() { - write_chunks_btreemap(12, 1_000_000); +fn write_chunks_stable_1m() { + write_chunks_stable(12, 1_000_000); } -fn write_chunks_btreemap(mem_id: u8, n: usize) { - let mut map = BTreeMap::init(init_memory(mem_id)); - let chunks = chunk_data(n); +#[bench] +fn read_chunks_stable_1() { + read_chunks_stable(20, 1); +} - bench_fn(|| { - for (i, chunk) in chunks.into_iter().enumerate() { - map.insert(i as u32, chunk); - } - }); +#[bench] +fn read_chunks_stable_1k() { + read_chunks_stable(21, 1_000); +} + +#[bench] +fn read_chunks_stable_1m() { + read_chunks_stable(22, 1_000_000); +} + +#[bench] +fn write_chunks_btreemap_1() { + write_chunks_btreemap(30, 1); +} + +#[bench] +fn write_chunks_btreemap_1k() { + write_chunks_btreemap(31, 1_000); +} + +#[bench] +fn write_chunks_btreemap_1m() { + write_chunks_btreemap(32, 1_000_000); } #[bench] fn read_chunks_btreemap_1() { - read_chunks_btreemap(20, 1); + read_chunks_btreemap(40, 1); } #[bench] fn read_chunks_btreemap_1k() { - read_chunks_btreemap(21, 1_000); + read_chunks_btreemap(41, 1_000); } #[bench] fn read_chunks_btreemap_1m() { - read_chunks_btreemap(22, 1_000_000); -} - -fn read_chunks_btreemap(mem_id: u8, n: usize) { - write_chunks_btreemap(mem_id, n); - let map: BTreeMap<_, Vec, _> = BTreeMap::init(init_memory(mem_id)); - bench_fn(|| { - for i in 0..n { - let _ = map.get(&(i as u32)); - } - }); + read_chunks_btreemap(42, 1_000_000); } fn main() {} From e7bc5e3073a12834806c497f6bb45bc444347a65 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 18:22:45 +0200 Subject: [PATCH 19/25] fix ci --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 957629de..37eb2ff4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,6 +96,8 @@ jobs: project_dir: ./benchmarks/memory_manager - name: vec project_dir: ./benchmarks/vec + - name: compare + project_dir: ./benchmarks/compare env: PROJECT_DIR: ${{ matrix.project_dir }} From ba717625289b02fd535483c678293e1d849781bf Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 26 May 2025 18:37:13 +0200 Subject: [PATCH 20/25] --persist --- benchmarks/compare/canbench_results.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index 5cdbc321..0fc9dec8 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -2,21 +2,21 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 1639628849 - heap_increase: 4834 + instructions: 1220197642 + heap_increase: 3233 stable_memory_increase: 1665 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 5868571006 - heap_increase: 1638 + instructions: 5418812624 + heap_increase: 1604 stable_memory_increase: 1665 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 135360202221 + instructions: 133684080756 heap_increase: 1892 stable_memory_increase: 3201 scopes: {} @@ -44,21 +44,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 1490269266 - heap_increase: 4834 + instructions: 1070838059 + heap_increase: 3233 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 5368581984 - heap_increase: 1638 + instructions: 4918823602 + heap_increase: 1604 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 91593809891 + instructions: 89917688426 heap_increase: 1892 stable_memory_increase: 3201 scopes: {} From e1eb6f948af01151af748281d6cfa9d35aacc59f Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Tue, 27 May 2025 08:51:54 +0200 Subject: [PATCH 21/25] macro --- benchmarks/compare/src/main.rs | 93 +++++++++++++--------------------- 1 file changed, 34 insertions(+), 59 deletions(-) diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index 97477ab3..307c55bf 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -28,6 +28,8 @@ fn chunk_data(n: usize) -> Vec> { (0..n).map(|_| vec![VALUE; chunk_size]).collect() } +// Stable memory benchmarks + fn write_chunks_stable(mem_id: u8, n: usize) { let memory = init_memory(mem_id); let chunks = chunk_data(n); @@ -54,6 +56,8 @@ fn read_chunks_stable(mem_id: u8, n: usize) { }); } +// BTreeMap benchmarks + fn write_chunks_btreemap(mem_id: u8, n: usize) { let mut map = BTreeMap::init(init_memory(mem_id)); let chunks = chunk_data(n); @@ -75,64 +79,35 @@ fn read_chunks_btreemap(mem_id: u8, n: usize) { }); } -#[bench] -fn write_chunks_stable_1() { - write_chunks_stable(10, 1); -} - -#[bench] -fn write_chunks_stable_1k() { - write_chunks_stable(11, 1_000); -} - -#[bench] -fn write_chunks_stable_1m() { - write_chunks_stable(12, 1_000_000); -} - -#[bench] -fn read_chunks_stable_1() { - read_chunks_stable(20, 1); -} - -#[bench] -fn read_chunks_stable_1k() { - read_chunks_stable(21, 1_000); -} - -#[bench] -fn read_chunks_stable_1m() { - read_chunks_stable(22, 1_000_000); -} - -#[bench] -fn write_chunks_btreemap_1() { - write_chunks_btreemap(30, 1); -} - -#[bench] -fn write_chunks_btreemap_1k() { - write_chunks_btreemap(31, 1_000); -} - -#[bench] -fn write_chunks_btreemap_1m() { - write_chunks_btreemap(32, 1_000_000); -} - -#[bench] -fn read_chunks_btreemap_1() { - read_chunks_btreemap(40, 1); -} - -#[bench] -fn read_chunks_btreemap_1k() { - read_chunks_btreemap(41, 1_000); -} - -#[bench] -fn read_chunks_btreemap_1m() { - read_chunks_btreemap(42, 1_000_000); -} +// Macro to define a single benchmark function +macro_rules! bench_case { + ($name:ident, $func:ident, $mem_id:expr, $n:expr) => { + #[bench] + fn $name() { + $func($mem_id, $n); + } + }; +} + +// Stable Memory benchmarks +bench_case!(write_chunks_stable_1, write_chunks_stable, 10, 1); +bench_case!(write_chunks_stable_1k, write_chunks_stable, 11, 1_000); +bench_case!(write_chunks_stable_1m, write_chunks_stable, 12, 1_000_000); +bench_case!(read_chunks_stable_1, read_chunks_stable, 20, 1); +bench_case!(read_chunks_stable_1k, read_chunks_stable, 21, 1_000); +bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, 1_000_000); + +// BTreeMap benchmarks +bench_case!(write_chunks_btreemap_1, write_chunks_btreemap, 30, 1); +bench_case!(write_chunks_btreemap_1k, write_chunks_btreemap, 31, 1_000); +bench_case!( + write_chunks_btreemap_1m, + write_chunks_btreemap, + 32, + 1_000_000 +); +bench_case!(read_chunks_btreemap_1, read_chunks_btreemap, 40, 1); +bench_case!(read_chunks_btreemap_1k, read_chunks_btreemap, 41, 1_000); +bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, 1_000_000); fn main() {} From e2739fffca9d9e92ce79244aa5502fe7ef3028bf Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Tue, 27 May 2025 08:53:36 +0200 Subject: [PATCH 22/25] . --- benchmarks/compare/src/main.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index 307c55bf..a4ed3ae1 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -8,16 +8,12 @@ use ic_stable_structures::{ const SIZE: usize = 100 * 1024 * 1024; const VALUE: u8 = 37; -fn page_align(bytes: usize) -> u64 { - bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64 -} - fn init_memory(id: u8) -> impl Memory { MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(id)) } fn ensure_memory_size(memory: &impl Memory, size: usize) { - let required = page_align(size); + let required = size.div_ceil(WASM_PAGE_SIZE_IN_BYTES) as u64; if memory.size() < required { memory.grow(required - memory.size()); } From 5fb224f141709dbed2dbe81133d312d6a21f8b58 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Tue, 27 May 2025 08:57:26 +0200 Subject: [PATCH 23/25] . --- benchmarks/compare/src/main.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index a4ed3ae1..d1b590f9 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -7,6 +7,8 @@ use ic_stable_structures::{ const SIZE: usize = 100 * 1024 * 1024; const VALUE: u8 = 37; +const K: usize = 1_000; +const M: usize = 1_000_000; fn init_memory(id: u8) -> impl Memory { MemoryManager::init(DefaultMemoryImpl::default()).get(MemoryId::new(id)) @@ -87,23 +89,18 @@ macro_rules! bench_case { // Stable Memory benchmarks bench_case!(write_chunks_stable_1, write_chunks_stable, 10, 1); -bench_case!(write_chunks_stable_1k, write_chunks_stable, 11, 1_000); -bench_case!(write_chunks_stable_1m, write_chunks_stable, 12, 1_000_000); +bench_case!(write_chunks_stable_1k, write_chunks_stable, 11, K); +bench_case!(write_chunks_stable_1m, write_chunks_stable, 12, M); bench_case!(read_chunks_stable_1, read_chunks_stable, 20, 1); -bench_case!(read_chunks_stable_1k, read_chunks_stable, 21, 1_000); -bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, 1_000_000); +bench_case!(read_chunks_stable_1k, read_chunks_stable, 21, K); +bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, M); // BTreeMap benchmarks bench_case!(write_chunks_btreemap_1, write_chunks_btreemap, 30, 1); -bench_case!(write_chunks_btreemap_1k, write_chunks_btreemap, 31, 1_000); -bench_case!( - write_chunks_btreemap_1m, - write_chunks_btreemap, - 32, - 1_000_000 -); +bench_case!(write_chunks_btreemap_1k, write_chunks_btreemap, 31, K); +bench_case!(write_chunks_btreemap_1m, write_chunks_btreemap, 32, M); bench_case!(read_chunks_btreemap_1, read_chunks_btreemap, 40, 1); -bench_case!(read_chunks_btreemap_1k, read_chunks_btreemap, 41, 1_000); -bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, 1_000_000); +bench_case!(read_chunks_btreemap_1k, read_chunks_btreemap, 41, K); +bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, M); fn main() {} From 5dc8d00a8412140ea6e4f2bb5db6e36acff85c21 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Tue, 27 May 2025 08:58:04 +0200 Subject: [PATCH 24/25] . --- benchmarks/compare/src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index d1b590f9..10cdf550 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -6,7 +6,6 @@ use ic_stable_structures::{ }; const SIZE: usize = 100 * 1024 * 1024; -const VALUE: u8 = 37; const K: usize = 1_000; const M: usize = 1_000_000; @@ -23,7 +22,7 @@ fn ensure_memory_size(memory: &impl Memory, size: usize) { fn chunk_data(n: usize) -> Vec> { let chunk_size = SIZE / n; - (0..n).map(|_| vec![VALUE; chunk_size]).collect() + (0..n).map(|_| vec![37; chunk_size]).collect() } // Stable memory benchmarks From 6627175fb4f9d7925b1199042a73c1e3691d0d81 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Tue, 27 May 2025 09:00:15 +0200 Subject: [PATCH 25/25] . --- benchmarks/compare/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index 10cdf550..4e62b4bd 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -5,7 +5,7 @@ use ic_stable_structures::{ BTreeMap, DefaultMemoryImpl, Memory, }; -const SIZE: usize = 100 * 1024 * 1024; +const TOTAL_SIZE: usize = 100 * 1024 * 1024; // 100 MiB const K: usize = 1_000; const M: usize = 1_000_000; @@ -21,7 +21,7 @@ fn ensure_memory_size(memory: &impl Memory, size: usize) { } fn chunk_data(n: usize) -> Vec> { - let chunk_size = SIZE / n; + let chunk_size = TOTAL_SIZE / n; (0..n).map(|_| vec![37; chunk_size]).collect() } @@ -30,10 +30,10 @@ fn chunk_data(n: usize) -> Vec> { fn write_chunks_stable(mem_id: u8, n: usize) { let memory = init_memory(mem_id); let chunks = chunk_data(n); - let chunk_size = SIZE / n; + let chunk_size = TOTAL_SIZE / n; bench_fn(|| { - ensure_memory_size(&memory, SIZE); + ensure_memory_size(&memory, TOTAL_SIZE); for (i, chunk) in chunks.iter().enumerate() { memory.write((i * chunk_size) as u64, chunk); } @@ -43,7 +43,7 @@ fn write_chunks_stable(mem_id: u8, n: usize) { fn read_chunks_stable(mem_id: u8, n: usize) { write_chunks_stable(mem_id, n); let memory = init_memory(mem_id); - let chunk_size = SIZE / n; + let chunk_size = TOTAL_SIZE / n; let mut buf = vec![0u8; chunk_size]; bench_fn(|| {