From 7b9e0b09109f69ae51ba3bd35fca279e110785da Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 14:47:27 +0200 Subject: [PATCH 01/13] debug with flamegraph --- benchmarks/compare/src/main.rs | 58 +-- benchmarks/compare/test_flamegraph.svg | 491 +++++++++++++++++++++++++ 2 files changed, 525 insertions(+), 24 deletions(-) create mode 100644 benchmarks/compare/test_flamegraph.svg diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index f2048619..aeeba568 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -1,5 +1,5 @@ use benchmarks::vec::BoundedVecN; -use canbench_rs::{bench, bench_fn}; +use canbench_rs::{bench, bench_fn, BenchResult}; use ic_cdk::api::stable::WASM_PAGE_SIZE_IN_BYTES; use ic_stable_structures::{ memory_manager::{MemoryId, MemoryManager}, @@ -128,28 +128,38 @@ macro_rules! bench_case_sized { // Benchmark registrations -// Stable Memory -bench_case!(write_chunks_stable_1, write_chunks_stable, 10, 1); -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, K); -bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, M); - -// BTreeMap -bench_case!(write_chunks_btreemap_1, write_chunks_btreemap, 30, 1); -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, K); -bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, M); - -// StableVec -bench_case_sized!(write_chunks_vec_1, write_chunks_vec, 50, 1); -bench_case_sized!(write_chunks_vec_1k, write_chunks_vec, 51, K); -bench_case_sized!(write_chunks_vec_1m, write_chunks_vec, 52, M); -bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); -bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); -bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); +// // Stable Memory +// bench_case!(write_chunks_stable_1, write_chunks_stable, 10, 1); +// 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, K); +// bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, M); + +// // BTreeMap +// bench_case!(write_chunks_btreemap_1, write_chunks_btreemap, 30, 1); +// 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, K); +// bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, M); + +// // StableVec +// bench_case_sized!(write_chunks_vec_1, write_chunks_vec, 50, 1); +// bench_case_sized!(write_chunks_vec_1k, write_chunks_vec, 51, K); +// bench_case_sized!(write_chunks_vec_1m, write_chunks_vec, 52, M); +// bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); +// bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); +// bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); + +#[bench(raw)] +fn test_flamegraph() -> BenchResult { + let mut map = BTreeMap::init(init_memory(10)); + let value = vec![82; 10 * 1024]; + + bench_fn(|| { + map.insert(1_u32, value); + }) +} fn main() {} diff --git a/benchmarks/compare/test_flamegraph.svg b/benchmarks/compare/test_flamegraph.svg new file mode 100644 index 00000000..8551bd95 --- /dev/null +++ b/benchmarks/compare/test_flamegraph.svg @@ -0,0 +1,491 @@ +test_flamegraph Reset ZoomSearch ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (66 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (548 instructions, 1.48%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..ic_stable_structures::btreemap::BTreeMap<K,V,M>::allocate_node (974 instructions, 2.63%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (107 instructions, 0.29%)ic_stable_structures::write (184 instructions, 0.50%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (84 instructions, 0.23%)__rdl_alloc (102 instructions, 0.27%)__rust_alloc (107 instructions, 0.29%)alloc::raw_vec::finish_grow (152 instructions, 0.41%)alloc::raw_vec::RawVec<T,A>::grow_one (236 instructions, 0.64%)memcpy (12 instructions, 0.03%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (162 instructions, 0.44%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (164 instructions, 0.44%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (417 instructions, 1.12%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (84 instructions, 0.23%)__rdl_alloc (102 instructions, 0.27%)__rust_alloc (107 instructions, 0.29%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.22%)ic_stable_structures::write (160 instructions, 0.43%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (205 instructions, 0.55%)dlmalloc::dlmalloc::Dlmalloc<A>::free (40 instructions, 0.11%)__rdl_dealloc (79 instructions, 0.21%)__rust_dealloc (99 instructions, 0.27%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.22%)ic_stable_structures::write (159 instructions, 0.43%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (49 instructions, 0.13%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,079 instructions, 2.91%)<i..ic_stable_structures::write (1,157 instructions, 3.12%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (327 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (83 instructions, 0.22%)__rdl_alloc (102 instructions, 0.27%)__rust_alloc (107 instructions, 0.29%)alloc::raw_vec::finish_grow (152 instructions, 0.41%)alloc::raw_vec::RawVec<T,A>::grow_one (230 instructions, 0.62%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,169 instructions, 3.15%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,095 instructions, 2.95%)<ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (1,546 instructions, 4.17%)ic_st..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,895 instructions, 5.11%)ic_sta..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,497 instructions, 4.04%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (328 instructions, 0.88%)__rdl_realloc (113 instructions, 0.30%)__rust_realloc (133 instructions, 0.36%)alloc::raw_vec::finish_grow (185 instructions, 0.50%)alloc::raw_vec::RawVec<T,A>::grow_one (274 instructions, 0.74%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,169 instructions, 3.15%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (546 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,095 instructions, 2.95%)<ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (1,547 instructions, 4.17%)ic_st..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,895 instructions, 5.11%)ic_sta..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,497 instructions, 4.04%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (66 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)ic_stable_structures::write (328 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (89 instructions, 0.24%)memcpy (329 instructions, 0.89%)dlmalloc::dlmalloc::Dlmalloc<A>::free (68 instructions, 0.18%)__rdl_realloc (637 instructions, 1.72%)__rust_realloc (658 instructions, 1.77%)_..alloc::raw_vec::finish_grow (710 instructions, 1.91%)a..alloc::raw_vec::RawVec<T,A>::grow_one (798 instructions, 2.15%)a..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,168 instructions, 3.15%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (66 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (201 instructions, 0.54%)ic_stable_structures::write (605 instructions, 1.63%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (5 instructions, 0.01%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (32,289 instructions, 87.05%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::writeic_stable_structures::btreemap::node::io::compute_num_overflow_pages_needed (36 instructions, 0.10%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)ic_stable_structures::write (163 instructions, 0.44%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::deallocate_unused_pages (287 instructions, 0.77%)ic_stable_structures::btreemap::node::Node<K>::save (34,167 instructions, 92.11%)ic_stable_structures::btreemap::node::Node<K>::save<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (107 instructions, 0.29%)ic_stable_structures::write (184 instructions, 0.50%)dlmalloc::dlmalloc::Dlmalloc<A>::insert_large_chunk (65 instructions, 0.18%)dlmalloc::dlmalloc::Dlmalloc<A>::free (119 instructions, 0.32%)__rdl_dealloc (157 instructions, 0.42%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (19 instructions, 0.05%)dlmalloc::dlmalloc::Dlmalloc<A>::insert_large_chunk (65 instructions, 0.18%)dlmalloc::dlmalloc::Dlmalloc<A>::free (172 instructions, 0.46%)__rdl_dealloc (210 instructions, 0.57%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (57 instructions, 0.15%)dlmalloc::dlmalloc::Dlmalloc<A>::free (133 instructions, 0.36%)__rdl_dealloc (172 instructions, 0.46%)__rust_dealloc (599 instructions, 1.61%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfull (35,519 instructions, 95.76%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfullic_stable_structures::btreemap::BTreeMap<K,V,M>::insert (36,838 instructions, 99.32%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insertall (37,092 instructions, 100%)test_flamegraph (37,092 instructions, 100.00%)test_flamegraph \ No newline at end of file From ca7ac0d0b84c9ef72375101e8b3b4a8419568a15 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 16:03:00 +0200 Subject: [PATCH 02/13] len --- benchmarks/btreemap/canbench_results.yml | 210 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 40 ++--- benchmarks/compare/canbench_results.yml | 24 +-- benchmarks/compare/src/main.rs | 66 +++---- benchmarks/compare/test_flamegraph.svg | 2 +- benchmarks/vec/canbench_results.yml | 14 +- src/btreemap/node/io.rs | 5 +- 7 files changed, 181 insertions(+), 180 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 9335445d..2975a813 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -562,14 +562,14 @@ benches: btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4414243466 + instructions: 4407576142 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 444987033 + instructions: 444976597 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -590,7 +590,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 495692313 + instructions: 495692305 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -618,14 +618,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 526875638 + instructions: 526875614 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 580539755 + instructions: 580539739 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -639,14 +639,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 517264825 + instructions: 517264553 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 619389439 + instructions: 619389423 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -667,7 +667,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 416771929 + instructions: 416771925 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -688,21 +688,21 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 468148494 + instructions: 468148486 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 414538939 + instructions: 414536867 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 422120086 + instructions: 422108222 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -723,42 +723,42 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2724541315 + instructions: 2722444295 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1004230958 + instructions: 1003291070 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 712421967 + instructions: 712215287 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1386961585 + instructions: 1385528597 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1172134598 + instructions: 1170933402 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 758019348 + instructions: 757724908 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -772,7 +772,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 866698572 + instructions: 866075708 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -793,14 +793,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 969855594 + instructions: 968988874 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 699344644 + instructions: 699299052 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -814,28 +814,28 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 608538730 + instructions: 608411690 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1840482053 + instructions: 1838704133 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 845897952 + instructions: 845407676 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 669688389 + instructions: 669505501 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -912,7 +912,7 @@ benches: btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3144791193 + instructions: 3144790989 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -926,63 +926,63 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 541900204 + instructions: 541888340 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 843362543 + instructions: 842483543 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1959334611 + instructions: 1957612175 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4345562448 + instructions: 4345562060 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 918002811 + instructions: 918002787 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 774336355 + instructions: 774294491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1235311368 + instructions: 1233773032 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3072998033 + instructions: 3069909301 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 617525736 + instructions: 617493972 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1003,7 +1003,7 @@ benches: btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 759917146 + instructions: 759917122 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,14 +1031,14 @@ benches: btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 816200943 + instructions: 816200919 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 909758915 + instructions: 909758899 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,14 +1052,14 @@ benches: btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 799101117 + instructions: 799100493 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 974145440 + instructions: 974145432 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1073,7 +1073,7 @@ benches: btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 817715606 + instructions: 817715490 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1087,7 +1087,7 @@ benches: btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4633015939 + instructions: 4633015923 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1101,21 +1101,21 @@ benches: btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 621633417 + instructions: 621633385 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 692238497 + instructions: 692232421 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 703685884 + instructions: 703647588 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1136,42 +1136,42 @@ benches: btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4018498913 + instructions: 4015389057 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1502646431 + instructions: 1501359035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1041313741 + instructions: 1041085509 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2002757542 + instructions: 2000679742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1684807804 + instructions: 1683085880 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1103431102 + instructions: 1103081566 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1185,7 +1185,7 @@ benches: btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1222529886 + instructions: 1221692746 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1206,14 +1206,14 @@ benches: btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1372107093 + instructions: 1370880229 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 989955238 + instructions: 989892930 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1227,35 +1227,35 @@ benches: btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 548589797 + instructions: 548495877 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2691148701 + instructions: 2688546497 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1241957624 + instructions: 1241334056 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 862745876 + instructions: 862576004 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 595826027 + instructions: 595792947 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1276,7 +1276,7 @@ benches: btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 733631609 + instructions: 733631601 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1290,7 +1290,7 @@ benches: btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1101403634 + instructions: 1101403626 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1304,14 +1304,14 @@ benches: btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 789994074 + instructions: 789994058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 878909764 + instructions: 878909748 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1325,7 +1325,7 @@ benches: btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 776952126 + instructions: 776951398 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1346,7 +1346,7 @@ benches: btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 790946565 + instructions: 790946485 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1360,7 +1360,7 @@ benches: btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4464466763 + instructions: 4464466747 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1374,21 +1374,21 @@ benches: btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 615779065 + instructions: 615779041 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 670770920 + instructions: 670764116 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 681654379 + instructions: 681614943 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1409,42 +1409,42 @@ benches: btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4236129487 + instructions: 4233014383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1508005318 + instructions: 1506714322 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1022083136 + instructions: 1021853880 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2063446347 + instructions: 2061368899 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1659038728 + instructions: 1657317644 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1078246324 + instructions: 1077894924 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1458,7 +1458,7 @@ benches: btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1198297165 + instructions: 1197460053 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1479,14 +1479,14 @@ benches: btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1356519035 + instructions: 1355293691 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 968507554 + instructions: 968444310 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1500,28 +1500,28 @@ benches: btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 534198256 + instructions: 534106336 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2790585867 + instructions: 2787982511 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1230020877 + instructions: 1229399189 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 862433228 + instructions: 862263332 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1591,14 +1591,14 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4738884700 + instructions: 4731554792 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 596895442 + instructions: 596861458 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1633,14 +1633,14 @@ benches: btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 998591484 + instructions: 998591476 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 762964206 + instructions: 762964198 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1654,7 +1654,7 @@ benches: btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 799332913 + instructions: 799332857 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1668,14 +1668,14 @@ benches: btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 712636077 + instructions: 712635641 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 872035084 + instructions: 872035076 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,14 +1689,14 @@ benches: btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 712282460 + instructions: 712282356 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 464428203 + instructions: 464428171 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1724,14 +1724,14 @@ benches: btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 582340960 + instructions: 582334920 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 603270076 + instructions: 603228212 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1752,42 +1752,42 @@ benches: btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4438860682 + instructions: 4435142510 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1418057388 + instructions: 1416548536 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 926755003 + instructions: 926507075 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2215939794 + instructions: 2213490482 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1691463667 + instructions: 1689404783 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1038694882 + instructions: 1038290162 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1801,7 +1801,7 @@ benches: btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1244067984 + instructions: 1243058852 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1822,14 +1822,14 @@ benches: btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1400789105 + instructions: 1399310197 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 981774893 + instructions: 981708297 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1843,28 +1843,28 @@ benches: btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 668557997 + instructions: 668454445 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3047442828 + instructions: 3044320912 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1190503436 + instructions: 1189781136 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 831016555 + instructions: 830830243 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index 1968303e..d441a239 100644 --- a/benchmarks/btreeset/canbench_results.yml +++ b/benchmarks/btreeset/canbench_results.yml @@ -2,70 +2,70 @@ benches: btreeset_insert_blob_1024: total: calls: 1 - instructions: 7286690242 + instructions: 7286355398 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1655515544 + instructions: 1655180700 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 742764840 + instructions: 742695180 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2467049413 + instructions: 2466714569 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 838550745 + instructions: 838387833 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4071180368 + instructions: 4070845524 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 1000266143 + instructions: 1000031251 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 720924777 + instructions: 720867129 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 569311458 + instructions: 569298378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 588524339 + instructions: 588504719 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,70 +492,70 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7742824218 + instructions: 7742489518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1687315215 + instructions: 1686980515 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 735109295 + instructions: 735039715 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2554595544 + instructions: 2554260844 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 828360358 + instructions: 828197546 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4281538178 + instructions: 4281203478 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 1009246256 + instructions: 1009011500 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 713356340 + instructions: 713298764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 560012231 + instructions: 559999151 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 583587452 + instructions: 583567832 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index 00db9bca..d3c5dc7b 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: 799994339 + instructions: 799580235 heap_increase: 1635 stable_memory_increase: 1665 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 4994472213 + instructions: 4989448149 heap_increase: 1602 stable_memory_increase: 1665 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 133159275732 + instructions: 133173008658 heap_increase: 1892 stable_memory_increase: 3201 scopes: {} @@ -44,42 +44,42 @@ benches: read_chunks_vec_1: total: calls: 1 - instructions: 1363286413 + instructions: 1363286416 heap_increase: 3202 stable_memory_increase: 1665 scopes: {} read_chunks_vec_1k: total: calls: 1 - instructions: 1378477856 + instructions: 1378479857 heap_increase: 3200 stable_memory_increase: 1665 scopes: {} read_chunks_vec_1m: total: calls: 1 - instructions: 4724968939 + instructions: 4726968940 heap_increase: 3784 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1: total: calls: 1 - instructions: 650634827 + instructions: 650220758 heap_increase: 1635 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4494392310 + instructions: 4489368281 heap_increase: 1602 stable_memory_increase: 1665 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 89213197943 + instructions: 89226930904 heap_increase: 1892 stable_memory_increase: 3201 scopes: {} @@ -107,21 +107,21 @@ benches: write_chunks_vec_1: total: calls: 1 - instructions: 1257790959 + instructions: 1257790962 heap_increase: 3202 stable_memory_increase: 1665 scopes: {} write_chunks_vec_1k: total: calls: 1 - instructions: 1272015664 + instructions: 1272017665 heap_increase: 3200 stable_memory_increase: 1665 scopes: {} write_chunks_vec_1m: total: calls: 1 - instructions: 3715427301 + instructions: 3717427302 heap_increase: 3784 stable_memory_increase: 1665 scopes: {} diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index aeeba568..0e0456b5 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -128,38 +128,38 @@ macro_rules! bench_case_sized { // Benchmark registrations -// // Stable Memory -// bench_case!(write_chunks_stable_1, write_chunks_stable, 10, 1); -// 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, K); -// bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, M); - -// // BTreeMap -// bench_case!(write_chunks_btreemap_1, write_chunks_btreemap, 30, 1); -// 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, K); -// bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, M); - -// // StableVec -// bench_case_sized!(write_chunks_vec_1, write_chunks_vec, 50, 1); -// bench_case_sized!(write_chunks_vec_1k, write_chunks_vec, 51, K); -// bench_case_sized!(write_chunks_vec_1m, write_chunks_vec, 52, M); -// bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); -// bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); -// bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); - -#[bench(raw)] -fn test_flamegraph() -> BenchResult { - let mut map = BTreeMap::init(init_memory(10)); - let value = vec![82; 10 * 1024]; - - bench_fn(|| { - map.insert(1_u32, value); - }) -} +// Stable Memory +bench_case!(write_chunks_stable_1, write_chunks_stable, 10, 1); +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, K); +bench_case!(read_chunks_stable_1m, read_chunks_stable, 22, M); + +// BTreeMap +bench_case!(write_chunks_btreemap_1, write_chunks_btreemap, 30, 1); +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, K); +bench_case!(read_chunks_btreemap_1m, read_chunks_btreemap, 42, M); + +// StableVec +bench_case_sized!(write_chunks_vec_1, write_chunks_vec, 50, 1); +bench_case_sized!(write_chunks_vec_1k, write_chunks_vec, 51, K); +bench_case_sized!(write_chunks_vec_1m, write_chunks_vec, 52, M); +bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); +bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); +bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); + +// #[bench(raw)] +// fn test_flamegraph() -> BenchResult { +// let mut map = BTreeMap::init(init_memory(10)); +// let value = vec![82; 5 * 1024]; + +// bench_fn(|| { +// map.insert(1_u32, value); +// }) +// } fn main() {} diff --git a/benchmarks/compare/test_flamegraph.svg b/benchmarks/compare/test_flamegraph.svg index 8551bd95..ff7e8fdc 100644 --- a/benchmarks/compare/test_flamegraph.svg +++ b/benchmarks/compare/test_flamegraph.svg @@ -488,4 +488,4 @@ function search(term) { function format_percent(n) { return n.toFixed(4) + "%"; } -]]>test_flamegraph Reset ZoomSearch ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (66 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (548 instructions, 1.48%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..ic_stable_structures::btreemap::BTreeMap<K,V,M>::allocate_node (974 instructions, 2.63%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (107 instructions, 0.29%)ic_stable_structures::write (184 instructions, 0.50%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (84 instructions, 0.23%)__rdl_alloc (102 instructions, 0.27%)__rust_alloc (107 instructions, 0.29%)alloc::raw_vec::finish_grow (152 instructions, 0.41%)alloc::raw_vec::RawVec<T,A>::grow_one (236 instructions, 0.64%)memcpy (12 instructions, 0.03%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (162 instructions, 0.44%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (164 instructions, 0.44%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (417 instructions, 1.12%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (84 instructions, 0.23%)__rdl_alloc (102 instructions, 0.27%)__rust_alloc (107 instructions, 0.29%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.22%)ic_stable_structures::write (160 instructions, 0.43%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (205 instructions, 0.55%)dlmalloc::dlmalloc::Dlmalloc<A>::free (40 instructions, 0.11%)__rdl_dealloc (79 instructions, 0.21%)__rust_dealloc (99 instructions, 0.27%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.22%)ic_stable_structures::write (159 instructions, 0.43%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (49 instructions, 0.13%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,079 instructions, 2.91%)<i..ic_stable_structures::write (1,157 instructions, 3.12%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (327 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (83 instructions, 0.22%)__rdl_alloc (102 instructions, 0.27%)__rust_alloc (107 instructions, 0.29%)alloc::raw_vec::finish_grow (152 instructions, 0.41%)alloc::raw_vec::RawVec<T,A>::grow_one (230 instructions, 0.62%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,169 instructions, 3.15%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,095 instructions, 2.95%)<ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (1,546 instructions, 4.17%)ic_st..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,895 instructions, 5.11%)ic_sta..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,497 instructions, 4.04%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)ic_stable_structures::write (328 instructions, 0.88%)__rdl_realloc (113 instructions, 0.30%)__rust_realloc (133 instructions, 0.36%)alloc::raw_vec::finish_grow (185 instructions, 0.50%)alloc::raw_vec::RawVec<T,A>::grow_one (274 instructions, 0.74%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,169 instructions, 3.15%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (127 instructions, 0.34%)ic_stable_structures::write (546 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,091 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,095 instructions, 2.95%)<ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (1,547 instructions, 4.17%)ic_st..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,895 instructions, 5.11%)ic_sta..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,497 instructions, 4.04%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (67 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (895 instructions, 2.41%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (81 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,496 instructions, 4.03%)ic_s..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (82 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (66 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)ic_stable_structures::write (328 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (89 instructions, 0.24%)memcpy (329 instructions, 0.89%)dlmalloc::dlmalloc::Dlmalloc<A>::free (68 instructions, 0.18%)__rdl_realloc (637 instructions, 1.72%)__rust_realloc (658 instructions, 1.77%)_..alloc::raw_vec::finish_grow (710 instructions, 1.91%)a..alloc::raw_vec::RawVec<T,A>::grow_one (798 instructions, 2.15%)a..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,092 instructions, 2.94%)<i..ic_stable_structures::write (1,168 instructions, 3.15%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (83 instructions, 0.22%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (66 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (95 instructions, 0.26%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (94 instructions, 0.25%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.34%)ic_stable_structures::write (547 instructions, 1.47%)ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (896 instructions, 2.42%)ic..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (82 instructions, 0.22%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (86 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (201 instructions, 0.54%)ic_stable_structures::write (605 instructions, 1.63%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (5 instructions, 0.01%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (32,289 instructions, 87.05%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::writeic_stable_structures::btreemap::node::io::compute_num_overflow_pages_needed (36 instructions, 0.10%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.23%)ic_stable_structures::write (163 instructions, 0.44%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::deallocate_unused_pages (287 instructions, 0.77%)ic_stable_structures::btreemap::node::Node<K>::save (34,167 instructions, 92.11%)ic_stable_structures::btreemap::node::Node<K>::save<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (107 instructions, 0.29%)ic_stable_structures::write (184 instructions, 0.50%)dlmalloc::dlmalloc::Dlmalloc<A>::insert_large_chunk (65 instructions, 0.18%)dlmalloc::dlmalloc::Dlmalloc<A>::free (119 instructions, 0.32%)__rdl_dealloc (157 instructions, 0.42%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (19 instructions, 0.05%)dlmalloc::dlmalloc::Dlmalloc<A>::insert_large_chunk (65 instructions, 0.18%)dlmalloc::dlmalloc::Dlmalloc<A>::free (172 instructions, 0.46%)__rdl_dealloc (210 instructions, 0.57%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (57 instructions, 0.15%)dlmalloc::dlmalloc::Dlmalloc<A>::free (133 instructions, 0.36%)__rdl_dealloc (172 instructions, 0.46%)__rust_dealloc (599 instructions, 1.61%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfull (35,519 instructions, 95.76%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfullic_stable_structures::btreemap::BTreeMap<K,V,M>::insert (36,838 instructions, 99.32%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insertall (37,092 instructions, 100%)test_flamegraph (37,092 instructions, 100.00%)test_flamegraph \ No newline at end of file +]]>test_flamegraph Reset ZoomSearch ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (568 instructions, 2.63%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (930 instructions, 4.30%)ic_st..ic_stable_structures::btreemap::BTreeMap<K,V,M>::allocate_node (1,014 instructions, 4.69%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (109 instructions, 0.50%)ic_stable_structures::write (191 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (86 instructions, 0.40%)__rdl_alloc (109 instructions, 0.50%)__rust_alloc (119 instructions, 0.55%)alloc::raw_vec::finish_grow (168 instructions, 0.78%)alloc::raw_vec::RawVec<T,A>::grow_one (257 instructions, 1.19%)memcpy (15 instructions, 0.07%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.41%)ic_stable_structures::write (170 instructions, 0.79%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (171 instructions, 0.79%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (441 instructions, 2.04%)i..dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.39%)__rdl_alloc (108 instructions, 0.50%)__rust_alloc (118 instructions, 0.55%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (85 instructions, 0.39%)ic_stable_structures::write (167 instructions, 0.77%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (217 instructions, 1.00%)dlmalloc::dlmalloc::Dlmalloc<A>::free (43 instructions, 0.20%)__rdl_dealloc (86 instructions, 0.40%)__rust_dealloc (111 instructions, 0.51%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)ic_stable_structures::write (166 instructions, 0.77%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (51 instructions, 0.24%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,081 instructions, 5.00%)<ic_st..ic_stable_structures::write (1,163 instructions, 5.38%)ic_stab..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.44%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (567 instructions, 2.62%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (930 instructions, 4.30%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (341 instructions, 1.58%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.39%)__rdl_alloc (108 instructions, 0.50%)__rust_alloc (118 instructions, 0.55%)alloc::raw_vec::finish_grow (168 instructions, 0.78%)alloc::raw_vec::RawVec<T,A>::grow_one (251 instructions, 1.16%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,094 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,176 instructions, 5.44%)ic_stab..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (569 instructions, 2.63%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (931 instructions, 4.31%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,094 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,517 instructions, 7.02%)ic_stable..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,097 instructions, 5.08%)<ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (1,568 instructions, 7.25%)ic_stable_..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,930 instructions, 8.93%)ic_stable_str..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,093 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,516 instructions, 7.01%)ic_stable..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (128 instructions, 0.59%)ic_stable_structures::write (567 instructions, 2.62%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (930 instructions, 4.30%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,094 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,518 instructions, 7.02%)ic_stable..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (84 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (569 instructions, 2.63%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (931 instructions, 4.31%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (341 instructions, 1.58%)__rdl_realloc (115 instructions, 0.53%)__rust_realloc (141 instructions, 0.65%)alloc::raw_vec::finish_grow (197 instructions, 0.91%)alloc::raw_vec::RawVec<T,A>::grow_one (291 instructions, 1.35%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (148 instructions, 0.68%)ic_stable_structures::write (230 instructions, 1.06%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (7 instructions, 0.03%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (16,707 instructions, 77.30%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::writeic_stable_structures::btreemap::node::io::compute_num_overflow_pages_needed (38 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (171 instructions, 0.79%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::deallocate_unused_pages (303 instructions, 1.40%)ic_stable_structures::btreemap::node::Node<K>::save (18,685 instructions, 86.45%)ic_stable_structures::btreemap::node::Node<K>::save<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (109 instructions, 0.50%)ic_stable_structures::write (190 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::free (43 instructions, 0.20%)__rdl_dealloc (86 instructions, 0.40%)dlmalloc::dlmalloc::Dlmalloc<A>::free (70 instructions, 0.32%)__rdl_dealloc (113 instructions, 0.52%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (21 instructions, 0.10%)dlmalloc::dlmalloc::Dlmalloc<A>::insert_large_chunk (68 instructions, 0.31%)dlmalloc::dlmalloc::Dlmalloc<A>::free (185 instructions, 0.86%)__rdl_dealloc (228 instructions, 1.05%)__rust_dealloc (502 instructions, 2.32%)_..ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfull (19,983 instructions, 92.46%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfullic_stable_structures::btreemap::BTreeMap<K,V,M>::insert (21,357 instructions, 98.82%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insertall (21,613 instructions, 100%)test_flamegraph (21,613 instructions, 100.00%)test_flamegraph \ No newline at end of file diff --git a/benchmarks/vec/canbench_results.yml b/benchmarks/vec/canbench_results.yml index bd83ad43..7c952c1b 100644 --- a/benchmarks/vec/canbench_results.yml +++ b/benchmarks/vec/canbench_results.yml @@ -65,49 +65,49 @@ benches: vec_insert_blob_128: total: calls: 1 - instructions: 4151424 + instructions: 4171424 heap_increase: 0 stable_memory_increase: 19 scopes: {} vec_insert_blob_16: total: calls: 1 - instructions: 3316227 + instructions: 3336227 heap_increase: 0 stable_memory_increase: 2 scopes: {} vec_insert_blob_32: total: calls: 1 - instructions: 3435467 + instructions: 3455467 heap_increase: 0 stable_memory_increase: 5 scopes: {} vec_insert_blob_4: total: calls: 1 - instructions: 3227468 + instructions: 3247468 heap_increase: 0 stable_memory_increase: 0 scopes: {} vec_insert_blob_64: total: calls: 1 - instructions: 3675804 + instructions: 3695804 heap_increase: 0 stable_memory_increase: 9 scopes: {} vec_insert_blob_8: total: calls: 1 - instructions: 3256889 + instructions: 3276889 heap_increase: 0 stable_memory_increase: 1 scopes: {} vec_insert_u64: total: calls: 1 - instructions: 5359519 + instructions: 5379519 heap_increase: 0 stable_memory_increase: 1 scopes: {} diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index 9061f9fb..de4bc429 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -265,13 +265,14 @@ impl<'a, M: Memory> NodeWriter<'a, M> { (self.overflows[page_idx - 1] + offset).get() }; + let len = length.get() as usize; write( self.allocator.memory(), offset, - &src[bytes_written as usize..(bytes_written + length.get()) as usize], + &src[bytes_written..bytes_written + len], ); - bytes_written += length.get(); + bytes_written += len; } } From 229800413ad906e6274222fb6f649eb554c1abec Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 16:06:41 +0200 Subject: [PATCH 03/13] fix benchmarks --- benchmarks/compare/canbench_results.yml | 108 ++++++++++++------------ benchmarks/compare/src/main.rs | 46 ++++------ 2 files changed, 72 insertions(+), 82 deletions(-) diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index d3c5dc7b..8830531a 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -2,127 +2,127 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 799580235 - heap_increase: 1635 - stable_memory_increase: 1665 + instructions: 148723119 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 4989448149 - heap_increase: 1602 - stable_memory_increase: 1665 + instructions: 499445396 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 133173008658 - heap_increase: 1892 - stable_memory_increase: 3201 + instructions: 43947440627 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_stable_1: total: calls: 1 - instructions: 812767304 - heap_increase: 1601 - stable_memory_increase: 1665 + instructions: 104859143 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_stable_1k: total: calls: 1 - instructions: 525926643 - heap_increase: 1600 - stable_memory_increase: 1665 + instructions: 104985739 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_stable_1m: total: calls: 1 - instructions: 1307625777 - heap_increase: 1892 - stable_memory_increase: 1665 + instructions: 230002739 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_vec_1: total: calls: 1 - instructions: 1363286416 - heap_increase: 3202 - stable_memory_increase: 1665 + instructions: 104859760 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_vec_1k: total: calls: 1 - instructions: 1378479857 - heap_increase: 3200 - stable_memory_increase: 1665 + instructions: 105826498 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} read_chunks_vec_1m: total: calls: 1 - instructions: 4726968940 - heap_increase: 3784 - stable_memory_increase: 1665 + instructions: 1010905944 + heap_increase: 0 + stable_memory_increase: 0 scopes: {} write_chunks_btreemap_1: total: calls: 1 - instructions: 650220758 - heap_increase: 1635 - stable_memory_increase: 1665 + instructions: 361764747 + heap_increase: 34 + stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4489368281 - heap_increase: 1602 - stable_memory_increase: 1665 + instructions: 4200294851 + heap_increase: 2 + stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 89226930904 - heap_increase: 1892 - stable_memory_increase: 3201 + instructions: 88699035981 + heap_increase: 0 + stable_memory_increase: 3072 scopes: {} write_chunks_stable_1: total: calls: 1 - instructions: 418914504 - heap_increase: 1601 - stable_memory_increase: 1665 + instructions: 130471968 + heap_increase: 0 + stable_memory_increase: 1664 scopes: {} write_chunks_stable_1k: total: calls: 1 - instructions: 420017246 - heap_increase: 1600 - stable_memory_increase: 1665 + instructions: 130598745 + heap_increase: 0 + stable_memory_increase: 1664 scopes: {} write_chunks_stable_1m: total: calls: 1 - instructions: 1076987527 - heap_increase: 1892 - stable_memory_increase: 1665 + instructions: 255406658 + heap_increase: 0 + stable_memory_increase: 1664 scopes: {} write_chunks_vec_1: total: calls: 1 - instructions: 1257790962 - heap_increase: 3202 - stable_memory_increase: 1665 + instructions: 549903573 + heap_increase: 0 + stable_memory_increase: 1536 scopes: {} write_chunks_vec_1k: total: calls: 1 - instructions: 1272017665 - heap_increase: 3200 - stable_memory_increase: 1665 + instructions: 562257515 + heap_increase: 0 + stable_memory_increase: 1536 scopes: {} write_chunks_vec_1m: total: calls: 1 - instructions: 3717427302 - heap_increase: 3784 - stable_memory_increase: 1665 + instructions: 1896593101 + heap_increase: 0 + stable_memory_increase: 1536 scopes: {} version: 0.2.0 diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index 0e0456b5..04148e0f 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -32,7 +32,7 @@ fn chunk_data(n: usize) -> Vec> { // Stable Memory benchmarks -fn write_chunks_stable(mem_id: u8, n: usize) { +fn write_chunks_stable(mem_id: u8, n: usize) -> BenchResult { let memory = init_memory(mem_id); let chunks = chunk_data(n); let chunk_size = TOTAL_SIZE / n; @@ -42,10 +42,10 @@ fn write_chunks_stable(mem_id: u8, n: usize) { for (i, chunk) in chunks.iter().enumerate() { memory.write((i * chunk_size) as u64, chunk); } - }); + }) } -fn read_chunks_stable(mem_id: u8, n: usize) { +fn read_chunks_stable(mem_id: u8, n: usize) -> BenchResult { write_chunks_stable(mem_id, n); let memory = init_memory(mem_id); let chunk_size = TOTAL_SIZE / n; @@ -55,12 +55,12 @@ fn read_chunks_stable(mem_id: u8, n: usize) { for i in 0..n { memory.read((i * chunk_size) as u64, &mut buf); } - }); + }) } // BTreeMap benchmarks -fn write_chunks_btreemap(mem_id: u8, n: usize) { +fn write_chunks_btreemap(mem_id: u8, n: usize) -> BenchResult { let mut map = BTreeMap::init(init_memory(mem_id)); let chunks = chunk_data(n); @@ -68,22 +68,22 @@ fn write_chunks_btreemap(mem_id: u8, n: usize) { for (i, chunk) in chunks.into_iter().enumerate() { map.insert(i as u32, chunk); } - }); + }) } -fn read_chunks_btreemap(mem_id: u8, n: usize) { +fn read_chunks_btreemap(mem_id: u8, n: usize) -> BenchResult { 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)); } - }); + }) } // StableVec benchmarks -fn write_chunks_vec(mem_id: u8, n: usize) { +fn write_chunks_vec(mem_id: u8, n: usize) -> BenchResult { let vec: StableVec, _> = StableVec::new(init_memory(mem_id)); let chunks: Vec<_> = chunk_data(n).iter().map(|v| BoundedVecN::from(v)).collect(); @@ -91,10 +91,10 @@ fn write_chunks_vec(mem_id: u8, n: usize) { for chunk in &chunks { vec.push(chunk); } - }); + }) } -fn read_chunks_vec(mem_id: u8, n: usize) { +fn read_chunks_vec(mem_id: u8, n: usize) -> BenchResult { write_chunks_vec::(mem_id, n); let vec: StableVec, _> = StableVec::init(init_memory(mem_id)); @@ -102,26 +102,26 @@ fn read_chunks_vec(mem_id: u8, n: usize) { for i in 0..n as u64 { let _ = vec.get(i); } - }); + }) } // Benchmark macros macro_rules! bench_case { ($name:ident, $func:ident, $mem_id:expr, $n:expr) => { - #[bench] - fn $name() { - $func($mem_id, $n); + #[bench(raw)] + fn $name() -> BenchResult { + $func($mem_id, $n) } }; } macro_rules! bench_case_sized { ($name:ident, $func:ident, $mem_id:expr, $n:expr) => { - #[bench] - fn $name() { + #[bench(raw)] + fn $name() -> BenchResult { const SIZE: usize = chunk_size::<$n>(); - $func::($mem_id, $n); + $func::($mem_id, $n) } }; } @@ -152,14 +152,4 @@ bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); -// #[bench(raw)] -// fn test_flamegraph() -> BenchResult { -// let mut map = BTreeMap::init(init_memory(10)); -// let value = vec![82; 5 * 1024]; - -// bench_fn(|| { -// map.insert(1_u32, value); -// }) -// } - fn main() {} From 910188caaef0b0ee4f4c794a9ef1d0d2c8cee2aa Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 16:56:06 +0200 Subject: [PATCH 04/13] --persist --- benchmarks/compare/canbench_results.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index 25bbf0e7..8830531a 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 362178795 + instructions: 361764747 heap_increase: 34 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4205340423 + instructions: 4200294851 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 88707302109 + instructions: 88699035981 heap_increase: 0 stable_memory_increase: 3072 scopes: {} From 2615838814d1872d90974212081afd698df5d092 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 17:20:51 +0200 Subject: [PATCH 05/13] update test --- benchmarks/compare/src/main.rs | 10 ++++++++++ benchmarks/compare/test_flamegraph.svg | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index 04148e0f..9b256ebd 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -152,4 +152,14 @@ bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); +#[bench(raw)] +fn test_flamegraph() -> BenchResult { + let mut map = BTreeMap::init(init_memory(10)); + let value = vec![82; 3 * 1024]; + + bench_fn(|| { + map.insert(1_u32, value); + }) +} + fn main() {} diff --git a/benchmarks/compare/test_flamegraph.svg b/benchmarks/compare/test_flamegraph.svg index ff7e8fdc..64f41abd 100644 --- a/benchmarks/compare/test_flamegraph.svg +++ b/benchmarks/compare/test_flamegraph.svg @@ -488,4 +488,4 @@ function search(term) { function format_percent(n) { return n.toFixed(4) + "%"; } -]]>test_flamegraph Reset ZoomSearch ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (568 instructions, 2.63%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (930 instructions, 4.30%)ic_st..ic_stable_structures::btreemap::BTreeMap<K,V,M>::allocate_node (1,014 instructions, 4.69%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (109 instructions, 0.50%)ic_stable_structures::write (191 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (86 instructions, 0.40%)__rdl_alloc (109 instructions, 0.50%)__rust_alloc (119 instructions, 0.55%)alloc::raw_vec::finish_grow (168 instructions, 0.78%)alloc::raw_vec::RawVec<T,A>::grow_one (257 instructions, 1.19%)memcpy (15 instructions, 0.07%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.41%)ic_stable_structures::write (170 instructions, 0.79%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (171 instructions, 0.79%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (441 instructions, 2.04%)i..dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.39%)__rdl_alloc (108 instructions, 0.50%)__rust_alloc (118 instructions, 0.55%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (85 instructions, 0.39%)ic_stable_structures::write (167 instructions, 0.77%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (217 instructions, 1.00%)dlmalloc::dlmalloc::Dlmalloc<A>::free (43 instructions, 0.20%)__rdl_dealloc (86 instructions, 0.40%)__rust_dealloc (111 instructions, 0.51%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)ic_stable_structures::write (166 instructions, 0.77%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (51 instructions, 0.24%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,081 instructions, 5.00%)<ic_st..ic_stable_structures::write (1,163 instructions, 5.38%)ic_stab..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.44%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (567 instructions, 2.62%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (930 instructions, 4.30%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (341 instructions, 1.58%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.39%)__rdl_alloc (108 instructions, 0.50%)__rust_alloc (118 instructions, 0.55%)alloc::raw_vec::finish_grow (168 instructions, 0.78%)alloc::raw_vec::RawVec<T,A>::grow_one (251 instructions, 1.16%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,094 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,176 instructions, 5.44%)ic_stab..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (569 instructions, 2.63%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (931 instructions, 4.31%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,094 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,517 instructions, 7.02%)ic_stable..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,097 instructions, 5.08%)<ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (1,568 instructions, 7.25%)ic_stable_..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,930 instructions, 8.93%)ic_stable_str..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,093 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,516 instructions, 7.01%)ic_stable..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (128 instructions, 0.59%)ic_stable_structures::write (567 instructions, 2.62%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (930 instructions, 4.30%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,094 instructions, 5.06%)<ic_st..ic_stable_structures::write (1,518 instructions, 7.02%)ic_stable..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (84 instructions, 0.39%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (69 instructions, 0.32%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (97 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (129 instructions, 0.60%)ic_stable_structures::write (569 instructions, 2.63%)ic..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (931 instructions, 4.31%)ic_st..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.39%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (341 instructions, 1.58%)__rdl_realloc (115 instructions, 0.53%)__rust_realloc (141 instructions, 0.65%)alloc::raw_vec::finish_grow (197 instructions, 0.91%)alloc::raw_vec::RawVec<T,A>::grow_one (291 instructions, 1.35%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (148 instructions, 0.68%)ic_stable_structures::write (230 instructions, 1.06%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (7 instructions, 0.03%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (16,707 instructions, 77.30%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::writeic_stable_structures::btreemap::node::io::compute_num_overflow_pages_needed (38 instructions, 0.18%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (89 instructions, 0.41%)ic_stable_structures::write (171 instructions, 0.79%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::deallocate_unused_pages (303 instructions, 1.40%)ic_stable_structures::btreemap::node::Node<K>::save (18,685 instructions, 86.45%)ic_stable_structures::btreemap::node::Node<K>::save<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (109 instructions, 0.50%)ic_stable_structures::write (190 instructions, 0.88%)dlmalloc::dlmalloc::Dlmalloc<A>::free (43 instructions, 0.20%)__rdl_dealloc (86 instructions, 0.40%)dlmalloc::dlmalloc::Dlmalloc<A>::free (70 instructions, 0.32%)__rdl_dealloc (113 instructions, 0.52%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (21 instructions, 0.10%)dlmalloc::dlmalloc::Dlmalloc<A>::insert_large_chunk (68 instructions, 0.31%)dlmalloc::dlmalloc::Dlmalloc<A>::free (185 instructions, 0.86%)__rdl_dealloc (228 instructions, 1.05%)__rust_dealloc (502 instructions, 2.32%)_..ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfull (19,983 instructions, 92.46%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfullic_stable_structures::btreemap::BTreeMap<K,V,M>::insert (21,357 instructions, 98.82%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insertall (21,613 instructions, 100%)test_flamegraph (21,613 instructions, 100.00%)test_flamegraph \ No newline at end of file +]]>test_flamegraph Reset ZoomSearch ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (68 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (128 instructions, 0.84%)ic_stable_structures::safe_write (548 instructions, 3.59%)ic_s..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (923 instructions, 6.05%)ic_stabl..ic_stable_structures::btreemap::BTreeMap<K,V,M>::allocate_node (1,005 instructions, 6.58%)ic_stable..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (108 instructions, 0.71%)ic_stable_structures::safe_write (184 instructions, 1.21%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::write_header (202 instructions, 1.32%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.56%)__rdl_alloc (106 instructions, 0.69%)__rust_alloc (114 instructions, 0.75%)alloc::raw_vec::finish_grow (162 instructions, 1.06%)alloc::raw_vec::RawVec<T,A>::grow_one (249 instructions, 1.63%)memcpy (14 instructions, 0.09%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (87 instructions, 0.57%)ic_stable_structures::safe_write (164 instructions, 1.07%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)ic_stable_structures::safe_write (164 instructions, 1.07%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (424 instructions, 2.78%)ic..dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.56%)__rdl_alloc (106 instructions, 0.69%)__rust_alloc (114 instructions, 0.75%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.55%)ic_stable_structures::safe_write (160 instructions, 1.05%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (209 instructions, 1.37%)dlmalloc::dlmalloc::Dlmalloc<A>::free (42 instructions, 0.28%)__rdl_dealloc (83 instructions, 0.54%)__rust_dealloc (106 instructions, 0.69%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (84 instructions, 0.55%)ic_stable_structures::safe_write (160 instructions, 1.05%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (50 instructions, 0.33%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,081 instructions, 7.08%)<ic_stable..ic_stable_structures::safe_write (1,157 instructions, 7.58%)ic_stable_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (84 instructions, 0.55%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (68 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (128 instructions, 0.84%)ic_stable_structures::safe_write (548 instructions, 3.59%)ic_s..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (923 instructions, 6.05%)ic_stabl..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.54%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)ic_stable_structures::safe_write (329 instructions, 2.15%)i..dlmalloc::dlmalloc::Dlmalloc<A>::malloc (85 instructions, 0.56%)__rdl_alloc (106 instructions, 0.69%)__rust_alloc (114 instructions, 0.75%)alloc::raw_vec::finish_grow (162 instructions, 1.06%)alloc::raw_vec::RawVec<T,A>::grow_one (243 instructions, 1.59%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,093 instructions, 7.16%)<ic_stable..ic_stable_structures::safe_write (1,169 instructions, 7.66%)ic_stable_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (84 instructions, 0.55%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (68 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (128 instructions, 0.84%)ic_stable_structures::safe_write (548 instructions, 3.59%)ic_s..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (923 instructions, 6.05%)ic_stabl..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.54%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,093 instructions, 7.16%)<ic_stable..ic_stable_structures::safe_write (1,498 instructions, 9.81%)ic_stable_stru..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (84 instructions, 0.55%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (68 instructions, 0.45%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (96 instructions, 0.63%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (1,096 instructions, 7.18%)<ic_stable..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (128 instructions, 0.84%)ic_stable_structures::safe_write (1,548 instructions, 10.14%)ic_stable_struc..ic_stable_structures::btreemap::allocator::Allocator<M>::allocate (1,924 instructions, 12.60%)ic_stable_structure..<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (83 instructions, 0.54%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (126 instructions, 0.83%)ic_stable_structures::safe_write (530 instructions, 3.47%)ic_..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (6 instructions, 0.04%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::write (10,472 instructions, 68.59%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::writeic_stable_structures::btreemap::node::io::compute_num_overflow_pages_needed (37 instructions, 0.24%)<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (88 instructions, 0.58%)ic_stable_structures::safe_write (164 instructions, 1.07%)ic_stable_structures::btreemap::node::io::NodeWriter<M>::deallocate_unused_pages (293 instructions, 1.92%)i..ic_stable_structures::btreemap::node::Node<K>::save (12,400 instructions, 81.22%)ic_stable_structures::btreemap::node::Node<K>::save<ic_stable_structures::memory_manager::VirtualMemory<M> as ic_stable_structures::Memory>::write (108 instructions, 0.71%)ic_stable_structures::safe_write (184 instructions, 1.21%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::write_header (201 instructions, 1.32%)dlmalloc::dlmalloc::Dlmalloc<A>::free (42 instructions, 0.28%)__rdl_dealloc (83 instructions, 0.54%)dlmalloc::dlmalloc::Dlmalloc<A>::free (69 instructions, 0.45%)__rdl_dealloc (110 instructions, 0.72%)dlmalloc::dlmalloc::Dlmalloc<A>::unlink_chunk (20 instructions, 0.13%)dlmalloc::dlmalloc::Dlmalloc<A>::free (100 instructions, 0.65%)__rdl_dealloc (141 instructions, 0.92%)__rust_dealloc (404 instructions, 2.65%)__..ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfull (13,618 instructions, 89.19%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insert_nonfullic_stable_structures::btreemap::BTreeMap<K,V,M>::insert (15,012 instructions, 98.32%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::insertall (15,268 instructions, 100%)test_flamegraph (15,268 instructions, 100.00%)test_flamegraph \ No newline at end of file From 97766393f8a4e73188f7dbad472b4006f4b328dc Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 18:45:18 +0200 Subject: [PATCH 06/13] batch overflow page allocation --- benchmarks/btreemap/canbench_results.yml | 210 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 40 ++--- benchmarks/compare/canbench_results.yml | 29 ++-- src/btreemap/node/io.rs | 36 ++-- 4 files changed, 160 insertions(+), 155 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 2975a813..e414b0e0 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -562,14 +562,14 @@ benches: btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4407576142 + instructions: 4401582060 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 444976597 + instructions: 445161273 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -590,7 +590,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 495692305 + instructions: 495692436 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -618,14 +618,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 526875614 + instructions: 526876122 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 580539739 + instructions: 580540001 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -639,14 +639,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 517264553 + instructions: 517270357 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 619389423 + instructions: 619389685 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -667,7 +667,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 416771925 + instructions: 416771977 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -688,21 +688,21 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 468148486 + instructions: 468148617 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 414536867 + instructions: 414576050 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 422108222 + instructions: 422325402 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -723,42 +723,42 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2722444295 + instructions: 2754706083 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1003291070 + instructions: 1020174794 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 712215287 + instructions: 715699322 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1385528597 + instructions: 1411258343 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1170933402 + instructions: 1186497872 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 757724908 + instructions: 762898063 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -772,7 +772,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 866075708 + instructions: 876552880 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -793,14 +793,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 968988874 + instructions: 982340561 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 699299052 + instructions: 700026996 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -814,28 +814,28 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 608411690 + instructions: 610488520 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1838704133 + instructions: 1868789672 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 845407676 + instructions: 854143426 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 669505501 + instructions: 672640867 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -912,7 +912,7 @@ benches: btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3144790989 + instructions: 3144794936 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -926,63 +926,63 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 541888340 + instructions: 542105152 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 842483543 + instructions: 856017898 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1957612175 + instructions: 1987608020 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4345562060 + instructions: 4345569465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 918002787 + instructions: 918003126 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 774294491 + instructions: 775040614 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1233773032 + instructions: 1257053201 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3069909301 + instructions: 3123352816 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 617493972 + instructions: 618043803 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1003,7 +1003,7 @@ benches: btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 759917122 + instructions: 759917465 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,14 +1031,14 @@ benches: btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 816200919 + instructions: 816201311 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 909758899 + instructions: 909759161 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,14 +1052,14 @@ benches: btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 799100493 + instructions: 799112835 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 974145432 + instructions: 974145563 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1073,7 +1073,7 @@ benches: btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 817715490 + instructions: 817717540 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1087,7 +1087,7 @@ benches: btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4633015923 + instructions: 4633016210 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1101,21 +1101,21 @@ benches: btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 621633385 + instructions: 621633909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 692232421 + instructions: 692336498 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 703647588 + instructions: 704328798 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1136,42 +1136,42 @@ benches: btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4015389057 + instructions: 4062739297 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1501359035 + instructions: 1524238547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1041085509 + instructions: 1044925333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2000679742 + instructions: 2037699893 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1683085880 + instructions: 1704755770 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1103081566 + instructions: 1109121943 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1185,7 +1185,7 @@ benches: btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1221692746 + instructions: 1235498463 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1206,14 +1206,14 @@ benches: btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1370880229 + instructions: 1389475388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 989892930 + instructions: 990873786 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1227,35 +1227,35 @@ benches: btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 548495877 + instructions: 550040667 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2688546497 + instructions: 2732209325 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1241334056 + instructions: 1252254548 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 862576004 + instructions: 865460058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 595792947 + instructions: 596365400 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1276,7 +1276,7 @@ benches: btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 733631601 + instructions: 733631732 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1290,7 +1290,7 @@ benches: btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1101403626 + instructions: 1101403757 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1304,14 +1304,14 @@ benches: btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 789994058 + instructions: 789994320 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 878909748 + instructions: 878910010 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1325,7 +1325,7 @@ benches: btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 776951398 + instructions: 776966326 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1346,7 +1346,7 @@ benches: btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 790946485 + instructions: 790948058 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1360,7 +1360,7 @@ benches: btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4464466747 + instructions: 4464467009 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1374,21 +1374,21 @@ benches: btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 615779041 + instructions: 615779384 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 670764116 + instructions: 670880584 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 681614943 + instructions: 682317723 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1409,42 +1409,42 @@ benches: btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4233014383 + instructions: 4280440866 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1506714322 + instructions: 1529659306 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1021853880 + instructions: 1025713072 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2061368899 + instructions: 2098382562 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1657317644 + instructions: 1678976826 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1077894924 + instructions: 1083972349 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1458,7 +1458,7 @@ benches: btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1197460053 + instructions: 1211266412 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1479,14 +1479,14 @@ benches: btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1355293691 + instructions: 1373865804 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 968444310 + instructions: 969445668 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1500,28 +1500,28 @@ benches: btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 534106336 + instructions: 535612201 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2787982511 + instructions: 2831661515 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1229399189 + instructions: 1240285105 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 862263332 + instructions: 865146354 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1591,14 +1591,14 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4731554792 + instructions: 4724562471 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 596861458 + instructions: 597444541 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1633,14 +1633,14 @@ benches: btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 998591476 + instructions: 998591607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 762964198 + instructions: 762964329 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1654,7 +1654,7 @@ benches: btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 799332857 + instructions: 799333574 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1668,14 +1668,14 @@ benches: btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 712635641 + instructions: 712644263 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 872035076 + instructions: 872035207 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,14 +1689,14 @@ benches: btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 712282356 + instructions: 712284249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 464428171 + instructions: 464428695 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1724,14 +1724,14 @@ benches: btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 582334920 + instructions: 582438021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 603228212 + instructions: 603974661 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1752,42 +1752,42 @@ benches: btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4435142510 + instructions: 4491814643 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1416548536 + instructions: 1443314163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 926507075 + instructions: 930680421 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2213490482 + instructions: 2257102776 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1689404783 + instructions: 1715289382 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1038290162 + instructions: 1045181302 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1801,7 +1801,7 @@ benches: btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1243058852 + instructions: 1259767253 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1822,14 +1822,14 @@ benches: btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1399310197 + instructions: 1421685495 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 981708297 + instructions: 982751169 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1843,28 +1843,28 @@ benches: btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 668454445 + instructions: 670145884 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3044320912 + instructions: 3096728457 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1189781136 + instructions: 1202215750 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 830830243 + instructions: 833981402 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index d441a239..73b8e180 100644 --- a/benchmarks/btreeset/canbench_results.yml +++ b/benchmarks/btreeset/canbench_results.yml @@ -2,70 +2,70 @@ benches: btreeset_insert_blob_1024: total: calls: 1 - instructions: 7286355398 + instructions: 7297699002 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1655180700 + instructions: 1666523852 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 742695180 + instructions: 745174978 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2466714569 + instructions: 2478057721 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 838387833 + instructions: 844244339 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4070845524 + instructions: 4082188902 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 1000031251 + instructions: 1008252471 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 720867129 + instructions: 722769076 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 569298378 + instructions: 569724763 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 588504719 + instructions: 589202514 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,70 +492,70 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7742489518 + instructions: 7753833824 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1686980515 + instructions: 1698324477 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 735039715 + instructions: 737522300 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2554260844 + instructions: 2565604806 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 828197546 + instructions: 834056304 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4281203478 + instructions: 4292547666 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 1009011500 + instructions: 1017233682 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 713298764 + instructions: 715203944 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 559999151 + instructions: 560431527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 583567832 + instructions: 584271618 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index 8830531a..f31568c8 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: 148723119 - heap_increase: 0 + instructions: 148723613 + heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 499445396 + instructions: 499348246 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 43947440627 + instructions: 43680240885 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -62,24 +62,31 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + test_flamegraph: + total: + calls: 1 + instructions: 15164 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} write_chunks_btreemap_1: total: calls: 1 - instructions: 361764747 - heap_increase: 34 + instructions: 357929697 + heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4200294851 + instructions: 4197380810 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 88699035981 + instructions: 88596909659 heap_increase: 0 stable_memory_increase: 3072 scopes: {} @@ -107,21 +114,21 @@ benches: write_chunks_vec_1: total: calls: 1 - instructions: 549903573 + instructions: 549903532 heap_increase: 0 stable_memory_increase: 1536 scopes: {} write_chunks_vec_1k: total: calls: 1 - instructions: 562257515 + instructions: 562216515 heap_increase: 0 stable_memory_increase: 1536 scopes: {} write_chunks_vec_1m: total: calls: 1 - instructions: 1896593101 + instructions: 1855593101 heap_increase: 0 stable_memory_increase: 1536 scopes: {} diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index de4bc429..7ae7fbdd 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -238,6 +238,15 @@ impl<'a, M: Memory> NodeWriter<'a, M> { return; } + // Batch overflow page allocation. + let needed_pages = + compute_num_overflow_pages_needed(end_offset, self.page_size.get() as u64) as usize; + self.overflows + .reserve(needed_pages.saturating_sub(self.overflows.len())); + while self.overflows.len() < needed_pages { + self.allocate_new_page(); + } + let iter = NodeIterator::new( VirtualSegment { address: Address::from(offset), @@ -246,33 +255,22 @@ impl<'a, M: Memory> NodeWriter<'a, M> { Bytes::from(self.page_size.get()), ); - let mut bytes_written = 0; + let mut position = 0; for RealSegment { page_idx, offset, length, } in iter { - let offset = if page_idx == 0 { - // Write to the initial page. - (self.address + offset).get() - } else { - // Write to an overflow page, allocating it if it doesn't already exist. - if self.overflows.len() < page_idx { - self.allocate_new_page(); - } - - (self.overflows[page_idx - 1] + offset).get() + let address = match page_idx { + 0 => self.address, // Write to the initial page. + _ => self.overflows[page_idx - 1], // Write to an overflow page. }; - + let offset = (address + offset).get(); let len = length.get() as usize; - write( - self.allocator.memory(), - offset, - &src[bytes_written..bytes_written + len], - ); - - bytes_written += len; + let slice = &src[position..position + len]; + write(self.allocator.memory(), offset, slice); + position += len; } } From 4af938f656d1eac8c8a1e751a698dc647eb2c7da Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 19:01:59 +0200 Subject: [PATCH 07/13] . --- benchmarks/compare/canbench_results.yml | 7 ------- benchmarks/compare/src/main.rs | 19 ++++++++++--------- benchmarks/compare/test_flamegraph.svg | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index f31568c8..6cae7147 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -62,13 +62,6 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} - test_flamegraph: - total: - calls: 1 - instructions: 15164 - heap_increase: 0 - stable_memory_increase: 0 - scopes: {} write_chunks_btreemap_1: total: calls: 1 diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index 9b256ebd..bd2fa271 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -152,14 +152,15 @@ bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); -#[bench(raw)] -fn test_flamegraph() -> BenchResult { - let mut map = BTreeMap::init(init_memory(10)); - let value = vec![82; 3 * 1024]; - - bench_fn(|| { - map.insert(1_u32, value); - }) -} +// #[bench(raw)] +// fn test_flamegraph() -> BenchResult { +// let mut map = BTreeMap::init(init_memory(10)); +// let value = vec![82; 3 * 1024]; + +// map.insert(1_u32, value); +// bench_fn(|| { +// map.get(&1_u32); +// }) +// } fn main() {} diff --git a/benchmarks/compare/test_flamegraph.svg b/benchmarks/compare/test_flamegraph.svg index 64f41abd..a4a74ac2 100644 --- a/benchmarks/compare/test_flamegraph.svg +++ b/benchmarks/compare/test_flamegraph.svg @@ -1,4 +1,4 @@ - \ No newline at end of file From 98a8ef7fe71e6df5defa51cc9fd7130d175b6d36 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 19:28:14 +0200 Subject: [PATCH 08/13] . --- benchmarks/btreemap/canbench_results.yml | 312 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 168 ++++++------ benchmarks/compare/canbench_results.yml | 16 +- src/btreemap/node/io.rs | 48 ++-- 4 files changed, 271 insertions(+), 273 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index e414b0e0..4ac0bad2 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,14 +2,14 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142211173 + instructions: 142211289 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 284729276 + instructions: 284742003 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -142,7 +142,7 @@ benches: btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 233050993 + instructions: 233059949 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -163,42 +163,42 @@ benches: btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1824658598 + instructions: 1825382365 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 574277483 + instructions: 574579481 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 448376101 + instructions: 448426688 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 902317934 + instructions: 902855816 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 514204302 + instructions: 514457952 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 428712852 + instructions: 428799492 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -212,7 +212,7 @@ benches: btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 441718228 + instructions: 441894745 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -233,14 +233,14 @@ benches: btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 460605845 + instructions: 460823441 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 407446580 + instructions: 407452371 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -254,42 +254,42 @@ benches: btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 412997571 + instructions: 413038419 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1252406681 + instructions: 1253051503 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 506200295 + instructions: 506363621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 402314964 + instructions: 402342263 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388591796 + instructions: 388591936 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 305721002 + instructions: 305733799 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -422,7 +422,7 @@ benches: btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 243863619 + instructions: 243872698 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -443,42 +443,42 @@ benches: btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1841512514 + instructions: 1842246281 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 583901094 + instructions: 584213023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 456729377 + instructions: 456782927 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 912188247 + instructions: 912736128 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 552829330 + instructions: 553094600 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 437331840 + instructions: 437422631 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 457027782 + instructions: 457212173 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -513,14 +513,14 @@ benches: btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 480046387 + instructions: 480273662 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 414392801 + instructions: 414399116 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -534,42 +534,42 @@ benches: btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 421113110 + instructions: 421155617 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1262553242 + instructions: 1263208063 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 514950921 + instructions: 515120682 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 410396741 + instructions: 410426150 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4401582060 + instructions: 4401582364 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 445161273 + instructions: 445171359 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -590,7 +590,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 495692436 + instructions: 495692438 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -618,14 +618,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 526876122 + instructions: 526876128 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 580540001 + instructions: 580540005 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -639,14 +639,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 517270357 + instructions: 517270478 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 619389685 + instructions: 619389689 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -667,7 +667,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 416771977 + instructions: 416771979 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -688,21 +688,21 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 468148617 + instructions: 468148619 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 414576050 + instructions: 414576801 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 422325402 + instructions: 422333845 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -723,42 +723,42 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2754706083 + instructions: 2755572448 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1020174794 + instructions: 1020575350 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 715699322 + instructions: 715779719 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1411258343 + instructions: 1411918352 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1186497872 + instructions: 1186857567 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 762898063 + instructions: 763014217 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -772,7 +772,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 876552880 + instructions: 876802161 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -793,14 +793,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 982340561 + instructions: 982647506 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 700026996 + instructions: 700044036 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -814,28 +814,28 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 610488520 + instructions: 610536234 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1868789672 + instructions: 1869585172 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 854143426 + instructions: 854343805 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 672640867 + instructions: 672704819 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -856,21 +856,21 @@ benches: btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 309491909 + instructions: 309518211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 393000497 + instructions: 393660530 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1228107785 + instructions: 1230138278 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -891,28 +891,28 @@ benches: btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 320421253 + instructions: 320447888 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 416742620 + instructions: 417439200 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1268826315 + instructions: 1270886805 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3144794936 + instructions: 3144795142 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -926,28 +926,28 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 542105152 + instructions: 542129461 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 856017898 + instructions: 857007102 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1987608020 + instructions: 1990100735 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4345569465 + instructions: 4345569585 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -961,28 +961,28 @@ benches: btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 775040614 + instructions: 775100025 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1257053201 + instructions: 1258349746 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3123352816 + instructions: 3126395644 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 618043803 + instructions: 618081363 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1003,7 +1003,7 @@ benches: btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 759917465 + instructions: 759917471 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,14 +1031,14 @@ benches: btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 816201311 + instructions: 816201320 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 909759161 + instructions: 909759163 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,7 +1052,7 @@ benches: btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 799112835 + instructions: 799113677 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1073,7 +1073,7 @@ benches: btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 817717540 + instructions: 817717607 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1087,7 +1087,7 @@ benches: btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4633016210 + instructions: 4633016215 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1101,21 +1101,21 @@ benches: btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 621633909 + instructions: 621633917 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 692336498 + instructions: 692344234 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 704328798 + instructions: 704374857 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1136,42 +1136,42 @@ benches: btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4062739297 + instructions: 4064179367 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1524238547 + instructions: 1524896850 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1044925333 + instructions: 1045040157 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2037699893 + instructions: 2038769176 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1704755770 + instructions: 1705365884 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1109121943 + instructions: 1109305681 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1185,7 +1185,7 @@ benches: btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1235498463 + instructions: 1235894977 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1206,14 +1206,14 @@ benches: btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1389475388 + instructions: 1389979460 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 990873786 + instructions: 990901186 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1227,35 +1227,35 @@ benches: btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 550040667 + instructions: 550082111 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2732209325 + instructions: 2733491074 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1252254548 + instructions: 1252566669 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 865460058 + instructions: 865542171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 596365400 + instructions: 596401950 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1276,7 +1276,7 @@ benches: btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 733631732 + instructions: 733631734 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1304,14 +1304,14 @@ benches: btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 789994320 + instructions: 789994324 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 878910010 + instructions: 878910014 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1325,7 +1325,7 @@ benches: btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 776966326 + instructions: 776967103 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1346,7 +1346,7 @@ benches: btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 790948058 + instructions: 790948128 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1360,7 +1360,7 @@ benches: btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4464467009 + instructions: 4464467011 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1374,21 +1374,21 @@ benches: btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 615779384 + instructions: 615779390 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 670880584 + instructions: 670889520 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 682317723 + instructions: 682362323 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1409,42 +1409,42 @@ benches: btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4280440866 + instructions: 4281841546 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1529659306 + instructions: 1530345769 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1025713072 + instructions: 1025830900 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2098382562 + instructions: 2099507949 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1678976826 + instructions: 1679575951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1083972349 + instructions: 1084159715 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1458,7 +1458,7 @@ benches: btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1211266412 + instructions: 1211670396 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1479,14 +1479,14 @@ benches: btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1373865804 + instructions: 1374382252 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 969445668 + instructions: 969476412 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1500,28 +1500,28 @@ benches: btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 535612201 + instructions: 535654478 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2831661515 + instructions: 2832952332 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1240285105 + instructions: 1240615082 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 865146354 + instructions: 865233566 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1535,14 +1535,14 @@ benches: btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2576893 + instructions: 2577695 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 20576208 + instructions: 20576224 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1556,14 +1556,14 @@ benches: btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 56941685 + instructions: 56943685 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 1105820811 + instructions: 1105820851 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1577,28 +1577,28 @@ benches: btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 56953681 + instructions: 56955681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 1105821047 + instructions: 1105821087 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4724562471 + instructions: 4724562785 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 597444541 + instructions: 597462205 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1640,7 +1640,7 @@ benches: btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 762964329 + instructions: 762964331 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1654,7 +1654,7 @@ benches: btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 799333574 + instructions: 799333588 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1668,7 +1668,7 @@ benches: btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 712644263 + instructions: 712644462 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,14 +1689,14 @@ benches: btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 712284249 + instructions: 712284278 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 464428695 + instructions: 464428703 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1724,14 +1724,14 @@ benches: btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 582438021 + instructions: 582440907 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 603974661 + instructions: 603996164 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1752,42 +1752,42 @@ benches: btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4491814643 + instructions: 4492865126 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1443314163 + instructions: 1443777732 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 930680421 + instructions: 930751769 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2257102776 + instructions: 2257900700 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1715289382 + instructions: 1715748535 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1045181302 + instructions: 1045300823 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1801,7 +1801,7 @@ benches: btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1259767253 + instructions: 1260067771 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1822,14 +1822,14 @@ benches: btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1421685495 + instructions: 1422074690 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 982751169 + instructions: 982764549 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1843,28 +1843,28 @@ benches: btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 670145884 + instructions: 670182849 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3096728457 + instructions: 3097684610 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1202215750 + instructions: 1202431423 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 833981402 + instructions: 834038451 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1878,14 +1878,14 @@ benches: btreemap_v2_scan_iter_1k_10kib: total: calls: 1 - instructions: 56743813 + instructions: 56745813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_20_10mib: total: calls: 1 - instructions: 1103713183 + instructions: 1103713223 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1899,14 +1899,14 @@ benches: btreemap_v2_scan_iter_rev_1k_10kib: total: calls: 1 - instructions: 56722199 + instructions: 56724199 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_20_10mib: total: calls: 1 - instructions: 1103712762 + instructions: 1103712802 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1920,14 +1920,14 @@ benches: btreemap_v2_scan_keys_1k_10kib: total: calls: 1 - instructions: 2514294 + instructions: 2515096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_20_10mib: total: calls: 1 - instructions: 18468498 + instructions: 18468514 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1941,14 +1941,14 @@ benches: btreemap_v2_scan_keys_rev_1k_10kib: total: calls: 1 - instructions: 2494346 + instructions: 2495148 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_20_10mib: total: calls: 1 - instructions: 18468514 + instructions: 18468530 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1962,14 +1962,14 @@ benches: btreemap_v2_scan_values_1k_10kib: total: calls: 1 - instructions: 56721151 + instructions: 56723151 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_20_10mib: total: calls: 1 - instructions: 1103712733 + instructions: 1103712773 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1983,14 +1983,14 @@ benches: btreemap_v2_scan_values_rev_1k_10kib: total: calls: 1 - instructions: 56700201 + instructions: 56702201 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_20_10mib: total: calls: 1 - instructions: 1103712324 + instructions: 1103712364 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index 73b8e180..4c68d115 100644 --- a/benchmarks/btreeset/canbench_results.yml +++ b/benchmarks/btreeset/canbench_results.yml @@ -2,196 +2,196 @@ benches: btreeset_insert_blob_1024: total: calls: 1 - instructions: 7297699002 + instructions: 7298665563 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1666523852 + instructions: 1667490413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 745174978 + instructions: 745902718 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2478057721 + instructions: 2479024282 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 844244339 + instructions: 845105027 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4082188902 + instructions: 4083155463 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 1008252471 + instructions: 1009147426 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 722769076 + instructions: 723471937 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 569724763 + instructions: 569809687 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 589202514 + instructions: 589345899 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_1024: total: calls: 1 - instructions: 108717480 + instructions: 108717621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_128: total: calls: 1 - instructions: 18182327 + instructions: 18182468 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_16: total: calls: 1 - instructions: 3647475 + instructions: 3647564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_256: total: calls: 1 - instructions: 31425854 + instructions: 31425995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_32: total: calls: 1 - instructions: 4922239 + instructions: 4922338 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_512: total: calls: 1 - instructions: 57189237 + instructions: 57189378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_64: total: calls: 1 - instructions: 10298042 + instructions: 10298171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_8: total: calls: 1 - instructions: 3391579 + instructions: 3391669 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_u32: total: calls: 1 - instructions: 2493481 + instructions: 2493491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_u64: total: calls: 1 - instructions: 2511564 + instructions: 2511580 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_1024: total: calls: 1 - instructions: 52538700 + instructions: 52538789 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_128: total: calls: 1 - instructions: 9488952 + instructions: 9489041 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_16: total: calls: 1 - instructions: 2342914 + instructions: 2342951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_256: total: calls: 1 - instructions: 15786657 + instructions: 15786746 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_32: total: calls: 1 - instructions: 3010054 + instructions: 3010101 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_512: total: calls: 1 - instructions: 28037630 + instructions: 28037719 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_64: total: calls: 1 - instructions: 5459388 + instructions: 5459465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_8: total: calls: 1 - instructions: 2251588 + instructions: 2251626 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -282,126 +282,126 @@ benches: btreeset_is_superset_blob_1024: total: calls: 1 - instructions: 91980425 + instructions: 91980566 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_128: total: calls: 1 - instructions: 15754445 + instructions: 15754586 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_16: total: calls: 1 - instructions: 3567098 + instructions: 3567187 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_256: total: calls: 1 - instructions: 26966925 + instructions: 26967066 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_32: total: calls: 1 - instructions: 4791883 + instructions: 4791982 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_512: total: calls: 1 - instructions: 48630735 + instructions: 48630876 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_64: total: calls: 1 - instructions: 8895044 + instructions: 8895173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_8: total: calls: 1 - instructions: 3336666 + instructions: 3336756 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_u32: total: calls: 1 - instructions: 2492193 + instructions: 2492203 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_u64: total: calls: 1 - instructions: 2510639 + instructions: 2510655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_1024: total: calls: 1 - instructions: 435128581 + instructions: 435128533 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_128: total: calls: 1 - instructions: 77513297 + instructions: 77513249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_16: total: calls: 1 - instructions: 17507874 + instructions: 17507842 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_256: total: calls: 1 - instructions: 129686734 + instructions: 129686686 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_32: total: calls: 1 - instructions: 23964306 + instructions: 23964269 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_512: total: calls: 1 - instructions: 231606208 + instructions: 231606160 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_64: total: calls: 1 - instructions: 42407274 + instructions: 42407224 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_8: total: calls: 1 - instructions: 16849520 + instructions: 16849490 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -422,56 +422,56 @@ benches: btreeset_range_blob_1024: total: calls: 1 - instructions: 263016896 + instructions: 263016902 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_128: total: calls: 1 - instructions: 47362850 + instructions: 47362856 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_16: total: calls: 1 - instructions: 11550015 + instructions: 11550023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_256: total: calls: 1 - instructions: 80331544 + instructions: 80331550 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_32: total: calls: 1 - instructions: 15400052 + instructions: 15400058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_512: total: calls: 1 - instructions: 140685790 + instructions: 140685796 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_64: total: calls: 1 - instructions: 26559863 + instructions: 26559869 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_8: total: calls: 1 - instructions: 11166386 + instructions: 11166395 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,210 +492,210 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7753833824 + instructions: 7754658011 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1698324477 + instructions: 1699148664 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 737522300 + instructions: 738550535 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2565604806 + instructions: 2566428993 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 834056304 + instructions: 834853372 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4292547666 + instructions: 4293371853 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 1017233682 + instructions: 1018026207 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 715203944 + instructions: 716249970 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 560431527 + instructions: 560649225 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 584271618 + instructions: 584607312 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_1024: total: calls: 1 - instructions: 108731606 + instructions: 108731747 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_128: total: calls: 1 - instructions: 18185701 + instructions: 18185842 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_16: total: calls: 1 - instructions: 3649099 + instructions: 3649188 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_256: total: calls: 1 - instructions: 31430764 + instructions: 31430905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_32: total: calls: 1 - instructions: 4923907 + instructions: 4924006 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_512: total: calls: 1 - instructions: 57197219 + instructions: 57197360 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_64: total: calls: 1 - instructions: 10300648 + instructions: 10300777 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_8: total: calls: 1 - instructions: 3393182 + instructions: 3393272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_u32: total: calls: 1 - instructions: 2509589 + instructions: 2509599 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_u64: total: calls: 1 - instructions: 2517649 + instructions: 2517665 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_1024: total: calls: 1 - instructions: 108732114 + instructions: 108732255 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_128: total: calls: 1 - instructions: 18186209 + instructions: 18186350 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_16: total: calls: 1 - instructions: 3649607 + instructions: 3649696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_256: total: calls: 1 - instructions: 31431272 + instructions: 31431413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_32: total: calls: 1 - instructions: 4924415 + instructions: 4924514 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_512: total: calls: 1 - instructions: 57197727 + instructions: 57197868 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_64: total: calls: 1 - instructions: 10301156 + instructions: 10301285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_8: total: calls: 1 - instructions: 3393690 + instructions: 3393780 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_u32: total: calls: 1 - instructions: 2507096 + instructions: 2507106 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_u64: total: calls: 1 - instructions: 2513159 + instructions: 2513175 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index 6cae7147..e99f98a1 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: 148723613 + instructions: 149241200 heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 499348246 + instructions: 500055724 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 43680240885 + instructions: 43947440713 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -72,14 +72,14 @@ benches: write_chunks_btreemap_1k: total: calls: 1 - instructions: 4197380810 + instructions: 4203353743 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 88596909659 + instructions: 88857341974 heap_increase: 0 stable_memory_increase: 3072 scopes: {} @@ -107,21 +107,21 @@ benches: write_chunks_vec_1: total: calls: 1 - instructions: 549903532 + instructions: 549903573 heap_increase: 0 stable_memory_increase: 1536 scopes: {} write_chunks_vec_1k: total: calls: 1 - instructions: 562216515 + instructions: 562257515 heap_increase: 0 stable_memory_increase: 1536 scopes: {} write_chunks_vec_1m: total: calls: 1 - instructions: 1855593101 + instructions: 1896593101 heap_increase: 0 stable_memory_increase: 1536 scopes: {} diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index 7ae7fbdd..4b63c96f 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -37,31 +37,27 @@ impl Memory for NodeReader<'_, M> { Bytes::from(self.page_size.get()), ); - let mut bytes_read = 0; + let mut position = 0; for RealSegment { page_idx, offset, length, } in iter { - // SAFETY: read_unsafe() is safe to call iff bytes_read + length <= count since the + // SAFETY: read_unsafe() is safe to call iff position + length <= count since the // caller guarantees that we can write `count` number of bytes to `dst`. - assert!(bytes_read + length.get() as usize <= count); - if page_idx == 0 { - self.memory.read_unsafe( - (self.address + offset).get(), - dst.add(bytes_read), - length.get() as usize, - ); - } else { - self.memory.read_unsafe( - (self.overflows[page_idx - 1] + offset).get(), - dst.add(bytes_read), - length.get() as usize, - ); - } - - bytes_read += length.get() as usize; + let len = length.get() as usize; + assert!(position + len <= count); + self.memory.read_unsafe( + (match page_idx { + 0 => self.address, // Initial page. + _ => self.overflows[page_idx - 1], // Overflow page. + } + offset) + .get(), + dst.add(position), + len, + ); + position += len; } } @@ -262,14 +258,16 @@ impl<'a, M: Memory> NodeWriter<'a, M> { length, } in iter { - let address = match page_idx { - 0 => self.address, // Write to the initial page. - _ => self.overflows[page_idx - 1], // Write to an overflow page. - }; - let offset = (address + offset).get(); let len = length.get() as usize; - let slice = &src[position..position + len]; - write(self.allocator.memory(), offset, slice); + write( + self.allocator.memory(), + (match page_idx { + 0 => self.address, // Initial page. + _ => self.overflows[page_idx - 1], // Overflow page. + } + offset) + .get(), + &src[position..position + len], + ); position += len; } } From 790c1d9b304073fb7b26528bc0d806da05a1ba96 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 19:44:58 +0200 Subject: [PATCH 09/13] . --- benchmarks/btreemap/canbench_results.yml | 210 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 40 ++--- benchmarks/compare/canbench_results.yml | 6 +- src/btreemap/node/io.rs | 29 ++-- 4 files changed, 139 insertions(+), 146 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 4ac0bad2..534608ad 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -562,14 +562,14 @@ benches: btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4401582364 + instructions: 4393250281 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 445171359 + instructions: 445174309 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -590,7 +590,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 495692438 + instructions: 495692435 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -618,14 +618,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 526876128 + instructions: 526876129 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 580540005 + instructions: 580539999 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -639,14 +639,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 517270478 + instructions: 517270579 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 619389689 + instructions: 619389683 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -667,7 +667,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 416771979 + instructions: 416771981 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -688,21 +688,21 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 468148619 + instructions: 468148616 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 414576801 + instructions: 414577133 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 422333845 + instructions: 422338489 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -723,42 +723,42 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2755572448 + instructions: 2755817960 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1020575350 + instructions: 1020900744 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 715779719 + instructions: 715822950 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1411918352 + instructions: 1412409929 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1186857567 + instructions: 1186725209 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 763014217 + instructions: 763098584 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -772,7 +772,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 876802161 + instructions: 876944445 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -793,14 +793,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 982647506 + instructions: 982741023 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 700044036 + instructions: 700044684 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -814,28 +814,28 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 610536234 + instructions: 610557656 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1869585172 + instructions: 1870040041 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 854343805 + instructions: 854496424 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 672704819 + instructions: 672749097 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -912,7 +912,7 @@ benches: btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3144795142 + instructions: 3144795237 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -926,63 +926,63 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 542129461 + instructions: 542134105 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 857007102 + instructions: 857102440 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1990100735 + instructions: 1990619289 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4345569585 + instructions: 4345569744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 918003126 + instructions: 918003117 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 775100025 + instructions: 775116764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1258349746 + instructions: 1258502326 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3126395644 + instructions: 3127317024 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 618081363 + instructions: 618090434 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1003,7 +1003,7 @@ benches: btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 759917471 + instructions: 759917462 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,14 +1031,14 @@ benches: btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 816201320 + instructions: 816201318 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 909759163 + instructions: 909759157 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,14 +1052,14 @@ benches: btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 799113677 + instructions: 799113858 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 974145563 + instructions: 974145560 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1073,7 +1073,7 @@ benches: btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 817717607 + instructions: 817717612 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1087,7 +1087,7 @@ benches: btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4633016215 + instructions: 4633016216 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1101,21 +1101,21 @@ benches: btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 621633917 + instructions: 621633905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 692344234 + instructions: 692345223 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 704374857 + instructions: 704389945 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1136,42 +1136,42 @@ benches: btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4064179367 + instructions: 4064558554 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1524896850 + instructions: 1525332389 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1045040157 + instructions: 1045091679 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2038769176 + instructions: 2039476885 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1705365884 + instructions: 1705172191 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1109305681 + instructions: 1109400656 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1185,7 +1185,7 @@ benches: btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1235894977 + instructions: 1236079880 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1206,14 +1206,14 @@ benches: btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1389979460 + instructions: 1390102731 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 990901186 + instructions: 990904536 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1227,35 +1227,35 @@ benches: btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 550082111 + instructions: 550099083 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2733491074 + instructions: 2734162267 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1252566669 + instructions: 1252743885 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 865542171 + instructions: 865582293 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 596401950 + instructions: 596411483 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1276,7 +1276,7 @@ benches: btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 733631734 + instructions: 733631731 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1290,7 +1290,7 @@ benches: btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1101403757 + instructions: 1101403754 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1304,14 +1304,14 @@ benches: btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 789994324 + instructions: 789994318 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 878910014 + instructions: 878910008 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1325,7 +1325,7 @@ benches: btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 776967103 + instructions: 776967354 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1346,7 +1346,7 @@ benches: btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 790948128 + instructions: 790948150 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1360,7 +1360,7 @@ benches: btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4464467011 + instructions: 4464467005 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1374,21 +1374,21 @@ benches: btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 615779390 + instructions: 615779381 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 670889520 + instructions: 670890736 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 682362323 + instructions: 682378065 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1409,42 +1409,42 @@ benches: btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4281841546 + instructions: 4282221124 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1530345769 + instructions: 1530782702 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1025830900 + instructions: 1025882878 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2099507949 + instructions: 2100215524 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1679575951 + instructions: 1679382300 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1084159715 + instructions: 1084255692 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1458,7 +1458,7 @@ benches: btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1211670396 + instructions: 1211855390 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1479,14 +1479,14 @@ benches: btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1374382252 + instructions: 1374505316 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 969476412 + instructions: 969480440 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1500,28 +1500,28 @@ benches: btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 535654478 + instructions: 535670457 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2832952332 + instructions: 2833623569 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1240615082 + instructions: 1240791526 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 865233566 + instructions: 865273560 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1591,14 +1591,14 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4724562785 + instructions: 4715402661 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 597462205 + instructions: 597471560 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1633,14 +1633,14 @@ benches: btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 998591607 + instructions: 998591604 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 762964331 + instructions: 762964328 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1654,7 +1654,7 @@ benches: btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 799333588 + instructions: 799333567 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1668,14 +1668,14 @@ benches: btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 712644462 + instructions: 712644627 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 872035207 + instructions: 872035204 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,14 +1689,14 @@ benches: btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 712284278 + instructions: 712284284 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 464428703 + instructions: 464428691 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1724,14 +1724,14 @@ benches: btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 582440907 + instructions: 582441841 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 603996164 + instructions: 604012903 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1752,42 +1752,42 @@ benches: btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4492865126 + instructions: 4493323799 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1443777732 + instructions: 1444284036 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 930751769 + instructions: 930808421 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2257900700 + instructions: 2258731746 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1715748535 + instructions: 1715515261 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1045300823 + instructions: 1045394123 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1801,7 +1801,7 @@ benches: btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1260067771 + instructions: 1260297055 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1822,14 +1822,14 @@ benches: btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1422074690 + instructions: 1422219179 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 982764549 + instructions: 982768027 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1843,28 +1843,28 @@ benches: btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 670182849 + instructions: 670200794 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3097684610 + instructions: 3098493866 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1202431423 + instructions: 1202621976 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 834038451 + instructions: 834081802 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index 4c68d115..d763e5b2 100644 --- a/benchmarks/btreeset/canbench_results.yml +++ b/benchmarks/btreeset/canbench_results.yml @@ -2,70 +2,70 @@ benches: btreeset_insert_blob_1024: total: calls: 1 - instructions: 7298665563 + instructions: 7299000416 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1667490413 + instructions: 1667825266 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 745902718 + instructions: 745978342 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2479024282 + instructions: 2479359135 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 845105027 + instructions: 845281597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4083155463 + instructions: 4083490316 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 1009147426 + instructions: 1009390653 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 723471937 + instructions: 723528608 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 569809687 + instructions: 569822767 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 589345899 + instructions: 589367154 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,70 +492,70 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7754658011 + instructions: 7754992714 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1699148664 + instructions: 1699483367 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 738550535 + instructions: 738626065 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2566428993 + instructions: 2566763696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 834853372 + instructions: 835029833 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4293371853 + instructions: 4293706556 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 1018026207 + instructions: 1018269288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 716249970 + instructions: 716306561 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 560649225 + instructions: 560662305 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 584607312 + instructions: 584628567 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index e99f98a1..6648234f 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 357929697 + instructions: 357412144 heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4203353743 + instructions: 4197203368 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 88857341974 + instructions: 88858441931 heap_increase: 0 stable_memory_increase: 3072 scopes: {} diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index 4b63c96f..87d0031b 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -48,15 +48,11 @@ impl Memory for NodeReader<'_, M> { // caller guarantees that we can write `count` number of bytes to `dst`. let len = length.get() as usize; assert!(position + len <= count); - self.memory.read_unsafe( - (match page_idx { - 0 => self.address, // Initial page. - _ => self.overflows[page_idx - 1], // Overflow page. - } + offset) - .get(), - dst.add(position), - len, - ); + let addr = match page_idx { + 0 => self.address, // Initial page. + _ => self.overflows[page_idx - 1], // Overflow page. + } + offset; + self.memory.read_unsafe(addr.get(), dst.add(position), len); position += len; } } @@ -252,6 +248,7 @@ impl<'a, M: Memory> NodeWriter<'a, M> { ); let mut position = 0; + let memory = self.allocator.memory(); for RealSegment { page_idx, offset, @@ -259,15 +256,11 @@ impl<'a, M: Memory> NodeWriter<'a, M> { } in iter { let len = length.get() as usize; - write( - self.allocator.memory(), - (match page_idx { - 0 => self.address, // Initial page. - _ => self.overflows[page_idx - 1], // Overflow page. - } + offset) - .get(), - &src[position..position + len], - ); + let addr = match page_idx { + 0 => self.address, // Initial page. + _ => self.overflows[page_idx - 1], // Overflow page. + } + offset; + write(memory, addr.get(), &src[position..position + len]); position += len; } } From 0f44a8da4d05bcd5c0ee1c52bc4a08629a67b349 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 19:47:27 +0200 Subject: [PATCH 10/13] cleanup --- benchmarks/compare/src/main.rs | 11 - benchmarks/compare/test_flamegraph.svg | 491 ------------------------- 2 files changed, 502 deletions(-) delete mode 100644 benchmarks/compare/test_flamegraph.svg diff --git a/benchmarks/compare/src/main.rs b/benchmarks/compare/src/main.rs index bd2fa271..04148e0f 100644 --- a/benchmarks/compare/src/main.rs +++ b/benchmarks/compare/src/main.rs @@ -152,15 +152,4 @@ bench_case_sized!(read_chunks_vec_1, read_chunks_vec, 60, 1); bench_case_sized!(read_chunks_vec_1k, read_chunks_vec, 61, K); bench_case_sized!(read_chunks_vec_1m, read_chunks_vec, 62, M); -// #[bench(raw)] -// fn test_flamegraph() -> BenchResult { -// let mut map = BTreeMap::init(init_memory(10)); -// let value = vec![82; 3 * 1024]; - -// map.insert(1_u32, value); -// bench_fn(|| { -// map.get(&1_u32); -// }) -// } - fn main() {} diff --git a/benchmarks/compare/test_flamegraph.svg b/benchmarks/compare/test_flamegraph.svg deleted file mode 100644 index a4a74ac2..00000000 --- a/benchmarks/compare/test_flamegraph.svg +++ /dev/null @@ -1,491 +0,0 @@ -test_flamegraph Reset ZoomSearch ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (61 instructions, 0.79%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (62 instructions, 0.80%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (87 instructions, 1.12%)__rdl_alloc (112 instructions, 1.44%)__rust_alloc (122 instructions, 1.57%)alloc::raw_vec::finish_grow (174 instructions, 2.24%)a..alloc::raw_vec::RawVec<T,A>::grow_one (259 instructions, 3.34%)all..ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (65 instructions, 0.84%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (65 instructions, 0.84%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (65 instructions, 0.84%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (87 instructions, 1.12%)__rdl_alloc (112 instructions, 1.44%)__rust_alloc (123 instructions, 1.59%)ic_stable_structures::storable::Bound::max_size (14 instructions, 0.18%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (87 instructions, 1.12%)__rdl_alloc (112 instructions, 1.44%)__rust_alloc (123 instructions, 1.59%)alloc::raw_vec::finish_grow (174 instructions, 2.24%)a..ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (57 instructions, 0.74%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (58 instructions, 0.75%)<ic_stable_structures::btreemap::node::io::NodeReader<M> as ic_stable_structures::Memory>::read_unsafe (274 instructions, 3.53%)<ic..dlmalloc::dlmalloc::Dlmalloc<A>::free (43 instructions, 0.55%)__rdl_dealloc (88 instructions, 1.14%)__rust_dealloc (115 instructions, 1.48%)ic_stable_structures::btreemap::node::Node<K>::load (2,315 instructions, 29.86%)ic_stable_structures::btreemap::node::Node<K>::l..dlmalloc::dlmalloc::Dlmalloc<A>::free (44 instructions, 0.57%)__rdl_dealloc (89 instructions, 1.15%)__rust_dealloc (115 instructions, 1.48%)dlmalloc::dlmalloc::Dlmalloc<A>::malloc (70 instructions, 0.90%)__rdl_alloc (95 instructions, 1.23%)__rust_alloc (107 instructions, 1.38%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (51 instructions, 0.66%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (1,055 instructions, 13.61%)ic_stable_structures:..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (85 instructions, 1.10%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (1,067 instructions, 13.76%)ic_stable_structures:..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (86 instructions, 1.11%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (1,067 instructions, 13.76%)ic_stable_structures:..<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (86 instructions, 1.11%)ic_stable_structures::memory_manager::MemoryManagerInner<M>::read_unsafe (99 instructions, 1.28%)<ic_stable_structures::btreemap::node::io::NodeIterator as core::iter::traits::iterator::Iterator>::next (8 instructions, 0.10%)<ic_stable_structures::btreemap::node::io::NodeReader<M> as ic_stable_structures::Memory>::read_unsafe (4,144 instructions, 53.45%)<ic_stable_structures::btreemap::node::io::NodeReader<M> as ic_stable_structures::Memory..dlmalloc::dlmalloc::Dlmalloc<A>::free (44 instructions, 0.57%)__rdl_dealloc (88 instructions, 1.14%)__rust_dealloc (115 instructions, 1.48%)ic_stable_structures::btreemap::node::Node<K>::into_entry (4,768 instructions, 61.50%)ic_stable_structures::btreemap::node::Node<K>::into_entryic_stable_structures::btreemap::BTreeMap<K,V,M>::traverse (7,332 instructions, 94.57%)ic_stable_structures::btreemap::BTreeMap<K,V,M>::traversedlmalloc::dlmalloc::Dlmalloc<A>::free (44 instructions, 0.57%)__rdl_dealloc (89 instructions, 1.15%)__rust_dealloc (114 instructions, 1.47%)all (7,753 instructions, 100%)test_flamegraph (7,753 instructions, 100.00%)test_flamegraph \ No newline at end of file From 34ce05bf37d3577154d7740c26f196c4abd1b41c Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 21:08:46 +0200 Subject: [PATCH 11/13] revert read --- benchmarks/btreemap/canbench_results.yml | 312 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 168 ++++++------ benchmarks/compare/canbench_results.yml | 10 +- src/btreemap/node/io.rs | 24 +- 4 files changed, 261 insertions(+), 253 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 534608ad..bcde2e7c 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,14 +2,14 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142211289 + instructions: 142211173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 284742003 + instructions: 284729276 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -142,7 +142,7 @@ benches: btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 233059949 + instructions: 233050993 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -163,42 +163,42 @@ benches: btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1825382365 + instructions: 1824658598 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 574579481 + instructions: 574277483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 448426688 + instructions: 448376101 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 902855816 + instructions: 902317934 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 514457952 + instructions: 514204302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 428799492 + instructions: 428712852 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -212,7 +212,7 @@ benches: btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 441894745 + instructions: 441718228 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -233,14 +233,14 @@ benches: btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 460823441 + instructions: 460605845 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 407452371 + instructions: 407446580 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -254,42 +254,42 @@ benches: btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 413038419 + instructions: 412997571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1253051503 + instructions: 1252406681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 506363621 + instructions: 506200295 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 402342263 + instructions: 402314964 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388591936 + instructions: 388591796 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 305733799 + instructions: 305721002 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -422,7 +422,7 @@ benches: btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 243872698 + instructions: 243863619 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -443,42 +443,42 @@ benches: btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1842246281 + instructions: 1841512514 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 584213023 + instructions: 583901094 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 456782927 + instructions: 456729377 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 912736128 + instructions: 912188247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 553094600 + instructions: 552829330 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 437422631 + instructions: 437331840 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 457212173 + instructions: 457027782 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -513,14 +513,14 @@ benches: btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 480273662 + instructions: 480046387 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 414399116 + instructions: 414392801 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -534,42 +534,42 @@ benches: btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 421155617 + instructions: 421113110 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1263208063 + instructions: 1262553242 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 515120682 + instructions: 514950921 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 410426150 + instructions: 410396741 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4393250281 + instructions: 4393249977 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 445174309 + instructions: 445164223 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -590,7 +590,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 495692435 + instructions: 495692433 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -618,14 +618,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 526876129 + instructions: 526876123 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 580539999 + instructions: 580539995 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -639,14 +639,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 517270579 + instructions: 517270458 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 619389683 + instructions: 619389679 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -667,7 +667,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 416771981 + instructions: 416771979 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -688,21 +688,21 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 468148616 + instructions: 468148614 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 414577133 + instructions: 414576382 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 422338489 + instructions: 422330046 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -723,42 +723,42 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2755817960 + instructions: 2754951595 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1020900744 + instructions: 1020500188 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 715822950 + instructions: 715742553 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1412409929 + instructions: 1411749920 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1186725209 + instructions: 1186365514 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 763098584 + instructions: 762982430 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -772,7 +772,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 876944445 + instructions: 876695164 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -793,14 +793,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 982741023 + instructions: 982434078 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 700044684 + instructions: 700027644 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -814,28 +814,28 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 610557656 + instructions: 610509942 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1870040041 + instructions: 1869244541 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 854496424 + instructions: 854296045 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 672749097 + instructions: 672685145 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -856,21 +856,21 @@ benches: btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 309518211 + instructions: 309491909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 393660530 + instructions: 393000497 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1230138278 + instructions: 1228107785 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -891,28 +891,28 @@ benches: btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 320447888 + instructions: 320421253 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 417439200 + instructions: 416742620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1270886805 + instructions: 1268826315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3144795237 + instructions: 3144795031 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -926,28 +926,28 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 542134105 + instructions: 542109796 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 857102440 + instructions: 856113236 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1990619289 + instructions: 1988126574 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4345569744 + instructions: 4345569624 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -961,28 +961,28 @@ benches: btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 775116764 + instructions: 775057353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1258502326 + instructions: 1257205781 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3127317024 + instructions: 3124274196 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 618090434 + instructions: 618052874 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1003,7 +1003,7 @@ benches: btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 759917462 + instructions: 759917456 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,14 +1031,14 @@ benches: btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 816201318 + instructions: 816201309 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 909759157 + instructions: 909759155 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,7 +1052,7 @@ benches: btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 799113858 + instructions: 799113016 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1073,7 +1073,7 @@ benches: btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 817717612 + instructions: 817717545 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1087,7 +1087,7 @@ benches: btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4633016216 + instructions: 4633016211 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1101,21 +1101,21 @@ benches: btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 621633905 + instructions: 621633897 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 692345223 + instructions: 692337487 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 704389945 + instructions: 704343886 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1136,42 +1136,42 @@ benches: btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4064558554 + instructions: 4063118484 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1525332389 + instructions: 1524674086 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1045091679 + instructions: 1044976855 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2039476885 + instructions: 2038407602 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1705172191 + instructions: 1704562077 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1109400656 + instructions: 1109216918 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1185,7 +1185,7 @@ benches: btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1236079880 + instructions: 1235683366 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1206,14 +1206,14 @@ benches: btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1390102731 + instructions: 1389598659 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 990904536 + instructions: 990877136 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1227,35 +1227,35 @@ benches: btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 550099083 + instructions: 550057639 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2734162267 + instructions: 2732880518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1252743885 + instructions: 1252431764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 865582293 + instructions: 865500180 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 596411483 + instructions: 596374933 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1276,7 +1276,7 @@ benches: btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 733631731 + instructions: 733631729 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1304,14 +1304,14 @@ benches: btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 789994318 + instructions: 789994314 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 878910008 + instructions: 878910004 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1325,7 +1325,7 @@ benches: btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 776967354 + instructions: 776966577 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1346,7 +1346,7 @@ benches: btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 790948150 + instructions: 790948080 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1360,7 +1360,7 @@ benches: btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4464467005 + instructions: 4464467003 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1374,21 +1374,21 @@ benches: btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 615779381 + instructions: 615779375 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 670890736 + instructions: 670881800 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 682378065 + instructions: 682333465 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1409,42 +1409,42 @@ benches: btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4282221124 + instructions: 4280820444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1530782702 + instructions: 1530096239 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1025882878 + instructions: 1025765050 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2100215524 + instructions: 2099090137 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1679382300 + instructions: 1678783175 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1084255692 + instructions: 1084068326 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1458,7 +1458,7 @@ benches: btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1211855390 + instructions: 1211451406 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1479,14 +1479,14 @@ benches: btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1374505316 + instructions: 1373988868 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 969480440 + instructions: 969449696 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1500,28 +1500,28 @@ benches: btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 535670457 + instructions: 535628180 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2833623569 + instructions: 2832332752 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1240791526 + instructions: 1240461549 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 865273560 + instructions: 865186348 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1535,14 +1535,14 @@ benches: btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2577695 + instructions: 2576893 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 20576224 + instructions: 20576208 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1556,14 +1556,14 @@ benches: btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 56943685 + instructions: 56941685 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 1105820851 + instructions: 1105820811 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1577,28 +1577,28 @@ benches: btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 56955681 + instructions: 56953681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 1105821087 + instructions: 1105821047 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4715402661 + instructions: 4715402347 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 597471560 + instructions: 597453896 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1640,7 +1640,7 @@ benches: btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 762964328 + instructions: 762964326 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1654,7 +1654,7 @@ benches: btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 799333567 + instructions: 799333553 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1668,7 +1668,7 @@ benches: btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 712644627 + instructions: 712644428 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,14 +1689,14 @@ benches: btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 712284284 + instructions: 712284255 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 464428691 + instructions: 464428683 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1724,14 +1724,14 @@ benches: btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 582441841 + instructions: 582438955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 604012903 + instructions: 603991400 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1752,42 +1752,42 @@ benches: btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4493323799 + instructions: 4492273316 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1444284036 + instructions: 1443820467 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 930808421 + instructions: 930737073 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2258731746 + instructions: 2257933822 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1715515261 + instructions: 1715056108 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1045394123 + instructions: 1045274602 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1801,7 +1801,7 @@ benches: btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1260297055 + instructions: 1259996537 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1822,14 +1822,14 @@ benches: btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1422219179 + instructions: 1421829984 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 982768027 + instructions: 982754647 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1843,28 +1843,28 @@ benches: btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 670200794 + instructions: 670163829 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3098493866 + instructions: 3097537713 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1202621976 + instructions: 1202406303 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 834081802 + instructions: 834024753 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1878,14 +1878,14 @@ benches: btreemap_v2_scan_iter_1k_10kib: total: calls: 1 - instructions: 56745813 + instructions: 56743813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_20_10mib: total: calls: 1 - instructions: 1103713223 + instructions: 1103713183 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1899,14 +1899,14 @@ benches: btreemap_v2_scan_iter_rev_1k_10kib: total: calls: 1 - instructions: 56724199 + instructions: 56722199 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_20_10mib: total: calls: 1 - instructions: 1103712802 + instructions: 1103712762 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1920,14 +1920,14 @@ benches: btreemap_v2_scan_keys_1k_10kib: total: calls: 1 - instructions: 2515096 + instructions: 2514294 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_20_10mib: total: calls: 1 - instructions: 18468514 + instructions: 18468498 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1941,14 +1941,14 @@ benches: btreemap_v2_scan_keys_rev_1k_10kib: total: calls: 1 - instructions: 2495148 + instructions: 2494346 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_20_10mib: total: calls: 1 - instructions: 18468530 + instructions: 18468514 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1962,14 +1962,14 @@ benches: btreemap_v2_scan_values_1k_10kib: total: calls: 1 - instructions: 56723151 + instructions: 56721151 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_20_10mib: total: calls: 1 - instructions: 1103712773 + instructions: 1103712733 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1983,14 +1983,14 @@ benches: btreemap_v2_scan_values_rev_1k_10kib: total: calls: 1 - instructions: 56702201 + instructions: 56700201 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_20_10mib: total: calls: 1 - instructions: 1103712364 + instructions: 1103712324 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index d763e5b2..8ceee3fd 100644 --- a/benchmarks/btreeset/canbench_results.yml +++ b/benchmarks/btreeset/canbench_results.yml @@ -2,196 +2,196 @@ benches: btreeset_insert_blob_1024: total: calls: 1 - instructions: 7299000416 + instructions: 7297866433 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1667825266 + instructions: 1666691283 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 745978342 + instructions: 745215772 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2479359135 + instructions: 2478225152 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 845281597 + instructions: 844339453 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4083490316 + instructions: 4082356333 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 1009390653 + instructions: 1008378252 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 723528608 + instructions: 722796923 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 569822767 + instructions: 569731303 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 589367154 + instructions: 589213959 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_1024: total: calls: 1 - instructions: 108717621 + instructions: 108717480 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_128: total: calls: 1 - instructions: 18182468 + instructions: 18182327 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_16: total: calls: 1 - instructions: 3647564 + instructions: 3647475 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_256: total: calls: 1 - instructions: 31425995 + instructions: 31425854 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_32: total: calls: 1 - instructions: 4922338 + instructions: 4922239 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_512: total: calls: 1 - instructions: 57189378 + instructions: 57189237 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_64: total: calls: 1 - instructions: 10298171 + instructions: 10298042 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_blob_8: total: calls: 1 - instructions: 3391669 + instructions: 3391579 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_u32: total: calls: 1 - instructions: 2493491 + instructions: 2493481 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_intersection_u64: total: calls: 1 - instructions: 2511580 + instructions: 2511564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_1024: total: calls: 1 - instructions: 52538789 + instructions: 52538700 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_128: total: calls: 1 - instructions: 9489041 + instructions: 9488952 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_16: total: calls: 1 - instructions: 2342951 + instructions: 2342914 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_256: total: calls: 1 - instructions: 15786746 + instructions: 15786657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_32: total: calls: 1 - instructions: 3010101 + instructions: 3010054 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_512: total: calls: 1 - instructions: 28037719 + instructions: 28037630 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_64: total: calls: 1 - instructions: 5459465 + instructions: 5459388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_disjoint_blob_8: total: calls: 1 - instructions: 2251626 + instructions: 2251588 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -282,126 +282,126 @@ benches: btreeset_is_superset_blob_1024: total: calls: 1 - instructions: 91980566 + instructions: 91980425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_128: total: calls: 1 - instructions: 15754586 + instructions: 15754445 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_16: total: calls: 1 - instructions: 3567187 + instructions: 3567098 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_256: total: calls: 1 - instructions: 26967066 + instructions: 26966925 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_32: total: calls: 1 - instructions: 4791982 + instructions: 4791883 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_512: total: calls: 1 - instructions: 48630876 + instructions: 48630735 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_64: total: calls: 1 - instructions: 8895173 + instructions: 8895044 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_blob_8: total: calls: 1 - instructions: 3336756 + instructions: 3336666 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_u32: total: calls: 1 - instructions: 2492203 + instructions: 2492193 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_is_superset_u64: total: calls: 1 - instructions: 2510655 + instructions: 2510639 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_1024: total: calls: 1 - instructions: 435128533 + instructions: 435128581 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_128: total: calls: 1 - instructions: 77513249 + instructions: 77513297 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_16: total: calls: 1 - instructions: 17507842 + instructions: 17507874 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_256: total: calls: 1 - instructions: 129686686 + instructions: 129686734 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_32: total: calls: 1 - instructions: 23964269 + instructions: 23964306 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_512: total: calls: 1 - instructions: 231606160 + instructions: 231606208 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_64: total: calls: 1 - instructions: 42407224 + instructions: 42407274 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_iter_blob_8: total: calls: 1 - instructions: 16849490 + instructions: 16849520 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -422,56 +422,56 @@ benches: btreeset_range_blob_1024: total: calls: 1 - instructions: 263016902 + instructions: 263016896 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_128: total: calls: 1 - instructions: 47362856 + instructions: 47362850 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_16: total: calls: 1 - instructions: 11550023 + instructions: 11550015 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_256: total: calls: 1 - instructions: 80331550 + instructions: 80331544 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_32: total: calls: 1 - instructions: 15400058 + instructions: 15400052 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_512: total: calls: 1 - instructions: 140685796 + instructions: 140685790 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_64: total: calls: 1 - instructions: 26559869 + instructions: 26559863 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_8: total: calls: 1 - instructions: 11166395 + instructions: 11166386 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,210 +492,210 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7754992714 + instructions: 7754001177 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1699483367 + instructions: 1698491830 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 738626065 + instructions: 737563040 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2566763696 + instructions: 2565772159 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 835029833 + instructions: 834151359 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4293706556 + instructions: 4292715019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 1018269288 + instructions: 1017359385 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 716306561 + instructions: 715231747 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 560662305 + instructions: 560438067 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 584628567 + instructions: 584283063 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_1024: total: calls: 1 - instructions: 108731747 + instructions: 108731606 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_128: total: calls: 1 - instructions: 18185842 + instructions: 18185701 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_16: total: calls: 1 - instructions: 3649188 + instructions: 3649099 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_256: total: calls: 1 - instructions: 31430905 + instructions: 31430764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_32: total: calls: 1 - instructions: 4924006 + instructions: 4923907 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_512: total: calls: 1 - instructions: 57197360 + instructions: 57197219 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_64: total: calls: 1 - instructions: 10300777 + instructions: 10300648 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_blob_8: total: calls: 1 - instructions: 3393272 + instructions: 3393182 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_u32: total: calls: 1 - instructions: 2509599 + instructions: 2509589 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_symmetric_difference_u64: total: calls: 1 - instructions: 2517665 + instructions: 2517649 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_1024: total: calls: 1 - instructions: 108732255 + instructions: 108732114 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_128: total: calls: 1 - instructions: 18186350 + instructions: 18186209 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_16: total: calls: 1 - instructions: 3649696 + instructions: 3649607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_256: total: calls: 1 - instructions: 31431413 + instructions: 31431272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_32: total: calls: 1 - instructions: 4924514 + instructions: 4924415 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_512: total: calls: 1 - instructions: 57197868 + instructions: 57197727 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_64: total: calls: 1 - instructions: 10301285 + instructions: 10301156 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_blob_8: total: calls: 1 - instructions: 3393780 + instructions: 3393690 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_u32: total: calls: 1 - instructions: 2507106 + instructions: 2507096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_union_u64: total: calls: 1 - instructions: 2513175 + instructions: 2513159 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index 6648234f..c6db68c8 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: 149241200 + instructions: 148723640 heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 500055724 + instructions: 499445396 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 43947440713 + instructions: 43947440627 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -72,14 +72,14 @@ benches: write_chunks_btreemap_1k: total: calls: 1 - instructions: 4197203368 + instructions: 4191327135 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 88858441931 + instructions: 88839231407 heap_increase: 0 stable_memory_increase: 3072 scopes: {} diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index 87d0031b..7424c9dc 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -46,14 +46,22 @@ impl Memory for NodeReader<'_, M> { { // SAFETY: read_unsafe() is safe to call iff position + length <= count since the // caller guarantees that we can write `count` number of bytes to `dst`. - let len = length.get() as usize; - assert!(position + len <= count); - let addr = match page_idx { - 0 => self.address, // Initial page. - _ => self.overflows[page_idx - 1], // Overflow page. - } + offset; - self.memory.read_unsafe(addr.get(), dst.add(position), len); - position += len; + assert!(position + length.get() as usize <= count); + if page_idx == 0 { + self.memory.read_unsafe( + (self.address + offset).get(), + dst.add(position), + length.get() as usize, + ); + } else { + self.memory.read_unsafe( + (self.overflows[page_idx - 1] + offset).get(), + dst.add(position), + length.get() as usize, + ); + } + + position += length.get() as usize; } } From 74b35036cd76faa72a0eaadde8c0319f5d48fb7c Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 21:13:40 +0200 Subject: [PATCH 12/13] . --- src/btreemap/node/io.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index 7424c9dc..c4e1ab71 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -44,24 +44,22 @@ impl Memory for NodeReader<'_, M> { length, } in iter { - // SAFETY: read_unsafe() is safe to call iff position + length <= count since the + // SAFETY: read_unsafe() is safe to call iff `position + length <= count` since the // caller guarantees that we can write `count` number of bytes to `dst`. - assert!(position + length.get() as usize <= count); + let len = length.get() as usize; + assert!(position + len <= count); if page_idx == 0 { - self.memory.read_unsafe( - (self.address + offset).get(), - dst.add(position), - length.get() as usize, - ); + self.memory + .read_unsafe((self.address + offset).get(), dst.add(position), len); } else { self.memory.read_unsafe( (self.overflows[page_idx - 1] + offset).get(), dst.add(position), - length.get() as usize, + len, ); } - position += length.get() as usize; + position += len; } } From df5e0b6ba7fefa452bc350b431742a8d3434e897 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Jun 2025 21:20:59 +0200 Subject: [PATCH 13/13] improve perf --- benchmarks/btreemap/canbench_results.yml | 210 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 40 ++--- benchmarks/compare/canbench_results.yml | 6 +- src/btreemap/node/io.rs | 34 ++-- 4 files changed, 150 insertions(+), 140 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index bcde2e7c..726a4c72 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -562,14 +562,14 @@ benches: btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4393249977 + instructions: 4389914887 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 445164223 + instructions: 445148380 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -590,7 +590,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 495692433 + instructions: 495692426 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -618,14 +618,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 526876123 + instructions: 526876092 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 580539995 + instructions: 580539981 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -639,14 +639,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 517270458 + instructions: 517270027 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 619389679 + instructions: 619389665 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -667,7 +667,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 416771979 + instructions: 416771974 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -688,21 +688,21 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 468148614 + instructions: 468148607 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 414576382 + instructions: 414573520 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 422330046 + instructions: 422311308 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -723,42 +723,42 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2754951595 + instructions: 2751883354 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1020500188 + instructions: 1018986630 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 715742553 + instructions: 715440972 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1411749920 + instructions: 1409430838 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1186365514 + instructions: 1184814611 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 762982430 + instructions: 762530013 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -772,7 +772,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 876695164 + instructions: 875753632 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -793,14 +793,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 982434078 + instructions: 981187745 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 700027644 + instructions: 699970006 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -814,28 +814,28 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 610509942 + instructions: 610329720 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1869244541 + instructions: 1866471276 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 854296045 + instructions: 853527323 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 672685145 + instructions: 672412257 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -912,7 +912,7 @@ benches: btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3144795031 + instructions: 3144794685 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -926,63 +926,63 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 542109796 + instructions: 542091058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 856113236 + instructions: 854848972 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1988126574 + instructions: 1985385065 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4345569624 + instructions: 4345568982 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 918003117 + instructions: 918003096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 775057353 + instructions: 774990832 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1257205781 + instructions: 1255009601 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3124274196 + instructions: 3119370019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 618052874 + instructions: 618004432 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1003,7 +1003,7 @@ benches: btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 759917456 + instructions: 759917435 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,14 +1031,14 @@ benches: btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 816201309 + instructions: 816201283 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 909759155 + instructions: 909759141 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,14 +1052,14 @@ benches: btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 799113016 + instructions: 799112085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 974145560 + instructions: 974145553 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1073,7 +1073,7 @@ benches: btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 817717545 + instructions: 817717399 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1087,7 +1087,7 @@ benches: btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4633016211 + instructions: 4633016190 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1101,21 +1101,21 @@ benches: btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 621633897 + instructions: 621633869 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 692337487 + instructions: 692329103 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 704343886 + instructions: 704283252 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1136,42 +1136,42 @@ benches: btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4063118484 + instructions: 4058561257 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1524674086 + instructions: 1522614084 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1044976855 + instructions: 1044640043 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2038407602 + instructions: 2035052771 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1704562077 + instructions: 1702345063 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1109216918 + instructions: 1108685023 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1185,7 +1185,7 @@ benches: btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1235683366 + instructions: 1234428372 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1206,14 +1206,14 @@ benches: btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1389598659 + instructions: 1387844690 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 990877136 + instructions: 990795901 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1227,35 +1227,35 @@ benches: btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 550057639 + instructions: 549923267 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2732880518 + instructions: 2728821380 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1252431764 + instructions: 1251470670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 865500180 + instructions: 865247718 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 596374933 + instructions: 596324464 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1276,7 +1276,7 @@ benches: btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 733631729 + instructions: 733631722 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1290,7 +1290,7 @@ benches: btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1101403754 + instructions: 1101403747 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1304,14 +1304,14 @@ benches: btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 789994314 + instructions: 789994300 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 878910004 + instructions: 878909990 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1325,7 +1325,7 @@ benches: btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 776966577 + instructions: 776965442 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1346,7 +1346,7 @@ benches: btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 790948080 + instructions: 790947962 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1360,7 +1360,7 @@ benches: btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4464467003 + instructions: 4464466989 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1374,21 +1374,21 @@ benches: btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 615779375 + instructions: 615779354 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 670881800 + instructions: 670872335 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 682333465 + instructions: 682270872 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1409,42 +1409,42 @@ benches: btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4280820444 + instructions: 4276255634 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1530096239 + instructions: 1528030235 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1025765050 + instructions: 1025426502 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2099090137 + instructions: 2095735884 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1678783175 + instructions: 1676567325 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1084068326 + instructions: 1083533099 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1458,7 +1458,7 @@ benches: btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1211451406 + instructions: 1210196374 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1479,14 +1479,14 @@ benches: btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1373988868 + instructions: 1372237172 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 969449696 + instructions: 969366613 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1500,28 +1500,28 @@ benches: btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 535628180 + instructions: 535497301 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2832332752 + instructions: 2828271962 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1240461549 + instructions: 1239503601 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 865186348 + instructions: 864933984 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1591,14 +1591,14 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4715402347 + instructions: 4711735840 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 597453896 + instructions: 597402521 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1633,14 +1633,14 @@ benches: btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 998591604 + instructions: 998591597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 762964326 + instructions: 762964319 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1654,7 +1654,7 @@ benches: btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 799333553 + instructions: 799333504 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1668,14 +1668,14 @@ benches: btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 712644428 + instructions: 712643752 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 872035204 + instructions: 872035197 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,14 +1689,14 @@ benches: btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 712284255 + instructions: 712284119 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 464428683 + instructions: 464428655 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1724,14 +1724,14 @@ benches: btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 582438955 + instructions: 582430661 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 603991400 + instructions: 603924879 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1752,42 +1752,42 @@ benches: btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4492273316 + instructions: 4486822914 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1443820467 + instructions: 1441411708 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 930737073 + instructions: 930370511 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2257933822 + instructions: 2253983036 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1715056108 + instructions: 1712407887 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1045274602 + instructions: 1044675402 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1801,7 +1801,7 @@ benches: btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1259996537 + instructions: 1258480662 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1822,14 +1822,14 @@ benches: btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1421829984 + instructions: 1419720324 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 982754647 + instructions: 982667924 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1843,28 +1843,28 @@ benches: btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 670163829 + instructions: 670016444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3097537713 + instructions: 3092666660 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1202406303 + instructions: 1201307935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 834024753 + instructions: 833748512 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index 8ceee3fd..67545f8d 100644 --- a/benchmarks/btreeset/canbench_results.yml +++ b/benchmarks/btreeset/canbench_results.yml @@ -2,70 +2,70 @@ benches: btreeset_insert_blob_1024: total: calls: 1 - instructions: 7297866433 + instructions: 7297615291 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1666691283 + instructions: 1666440141 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 745215772 + instructions: 745165513 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2478225152 + instructions: 2477974010 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 844339453 + instructions: 844209596 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4082356333 + instructions: 4082105191 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 1008378252 + instructions: 1008193748 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 722796923 + instructions: 722754664 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 569731303 + instructions: 569721493 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 589213959 + instructions: 589197609 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,70 +492,70 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7754001177 + instructions: 7753750149 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1698491830 + instructions: 1698240802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 737563040 + instructions: 737512849 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2565772159 + instructions: 2565521131 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 834151359 + instructions: 834021583 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4292715019 + instructions: 4292463991 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 1017359385 + instructions: 1017174993 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 715231747 + instructions: 715189550 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 560438067 + instructions: 560428257 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 584283063 + instructions: 584266713 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/compare/canbench_results.yml b/benchmarks/compare/canbench_results.yml index c6db68c8..4c9ef89e 100644 --- a/benchmarks/compare/canbench_results.yml +++ b/benchmarks/compare/canbench_results.yml @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 357412144 + instructions: 357205117 heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4191327135 + instructions: 4188695663 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 88839231407 + instructions: 88827798790 heap_increase: 0 stable_memory_increase: 3072 scopes: {} diff --git a/src/btreemap/node/io.rs b/src/btreemap/node/io.rs index c4e1ab71..4a2c97e8 100644 --- a/src/btreemap/node/io.rs +++ b/src/btreemap/node/io.rs @@ -48,15 +48,17 @@ impl Memory for NodeReader<'_, M> { // caller guarantees that we can write `count` number of bytes to `dst`. let len = length.get() as usize; assert!(position + len <= count); - if page_idx == 0 { - self.memory - .read_unsafe((self.address + offset).get(), dst.add(position), len); - } else { - self.memory.read_unsafe( + match page_idx { + // Initial page. + 0 => self + .memory + .read_unsafe((self.address + offset).get(), dst.add(position), len), + // Overflow page. + _ => self.memory.read_unsafe( (self.overflows[page_idx - 1] + offset).get(), dst.add(position), len, - ); + ), } position += len; @@ -254,7 +256,6 @@ impl<'a, M: Memory> NodeWriter<'a, M> { ); let mut position = 0; - let memory = self.allocator.memory(); for RealSegment { page_idx, offset, @@ -262,11 +263,20 @@ impl<'a, M: Memory> NodeWriter<'a, M> { } in iter { let len = length.get() as usize; - let addr = match page_idx { - 0 => self.address, // Initial page. - _ => self.overflows[page_idx - 1], // Overflow page. - } + offset; - write(memory, addr.get(), &src[position..position + len]); + match page_idx { + // Initial page. + 0 => write( + self.allocator.memory(), + (self.address + offset).get(), + &src[position..position + len], + ), + // Overflow page. + _ => write( + self.allocator.memory(), + (self.overflows[page_idx - 1] + offset).get(), + &src[position..position + len], + ), + }; position += len; } }