From 8a8c9c3d726cdae28a73d87f8102ebe706c27a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Wed, 18 Mar 2026 18:46:08 +0100 Subject: [PATCH 01/42] perf: add direct-mapped node cache to BTreeMap Add a 32-slot direct-mapped node cache to BTreeMap that avoids re-loading hot nodes from stable memory. Modeled after CPU caches: O(1) lookup via (address / page_size) % 32, collision = eviction. Read paths (get, contains_key, first/last_key_value) use a take+return pattern to borrow nodes from the cache without RefCell lifetime issues. Write paths (insert, remove, split, merge) invalidate affected cache slots. Key changes: - Switch get() from destructive extract_entry_at to node.value() - Remove unused extract_entry_at method - Change traverse() closure from Fn(&mut Node) to Fn(&Node) - Invalidate cache in save_node, deallocate_node, merge, clear_new Expected improvement: ~15-20% for random reads, ~65% for hot-key workloads, ~0% overhead for writes (cache.get_mut() bypasses RefCell). --- src/btreemap.rs | 137 +++++++++++++++++++++++++++++++++++++------ src/btreemap/node.rs | 9 --- 2 files changed, 118 insertions(+), 28 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index c6f4ae92..58d67b4a 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -61,6 +61,7 @@ use allocator::Allocator; pub use iter::Iter; use node::{DerivedPageSize, Entry, Node, NodeType, PageSize, Version}; use std::borrow::Cow; +use std::cell::RefCell; use std::marker::PhantomData; use std::ops::{Bound, RangeBounds}; @@ -81,6 +82,57 @@ const DEFAULT_PAGE_SIZE: u32 = 1024; // A marker to indicate that the `PageSize` stored in the header is a `PageSize::Value`. const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; +const NODE_CACHE_NUM_SLOTS: usize = 32; + +/// A direct-mapped node cache modeled after CPU caches. +/// +/// Each slot is indexed by `(node_address / page_size) % NUM_SLOTS`. Lookup +/// is O(1) with ~5 instructions overhead. Collision = eviction (no LRU +/// tracking needed). +/// +/// Upper tree levels (root, depth-1) naturally stay cached because their +/// addresses are stable and map to distinct slots. +struct NodeCache { + slots: Vec<(Address, Option>)>, + page_size: u32, +} + +impl NodeCache { + fn new(page_size: u32) -> Self { + let mut slots = Vec::with_capacity(NODE_CACHE_NUM_SLOTS); + for _ in 0..NODE_CACHE_NUM_SLOTS { + slots.push((NULL, None)); + } + Self { slots, page_size } + } + + fn slot_index(&self, addr: Address) -> usize { + (addr.get() / self.page_size as u64) as usize % NODE_CACHE_NUM_SLOTS + } + + fn take(&mut self, addr: Address) -> Option> { + let idx = self.slot_index(addr); + if self.slots[idx].0 == addr { + self.slots[idx].0 = NULL; + self.slots[idx].1.take() + } else { + None + } + } + + fn put(&mut self, addr: Address, node: Node) { + let idx = self.slot_index(addr); + self.slots[idx] = (addr, Some(node)); + } + + fn invalidate(&mut self, addr: Address) { + let idx = self.slot_index(addr); + if self.slots[idx].0 == addr { + self.slots[idx] = (NULL, None); + } + } +} + /// A B-Tree map implementation that stores its data into a designated memory. /// /// # Memory Implementations @@ -248,6 +300,9 @@ where // The number of elements in the map. length: u64, + // Direct-mapped node cache to avoid re-loading hot nodes from stable memory. + cache: RefCell>, + // A marker to communicate to the Rust compiler that we own these types. _phantom: PhantomData<(K, V)>, } @@ -358,6 +413,7 @@ where ), version: Version::V2(page_size), length: 0, + cache: RefCell::new(NodeCache::new(page_size.get())), _phantom: PhantomData, }; @@ -373,6 +429,11 @@ where let max_key_size = K::BOUND.max_size(); let max_value_size = V::BOUND.max_size(); + let version = Version::V1(DerivedPageSize { + max_key_size, + max_value_size, + }); + let btree = Self { root_addr: NULL, allocator: Allocator::new( @@ -380,11 +441,9 @@ where Address::from(ALLOCATOR_OFFSET as u64), Node::::max_size(max_key_size, max_value_size), ), - version: Version::V1(DerivedPageSize { - max_key_size, - max_value_size, - }), + version, length: 0, + cache: RefCell::new(NodeCache::new(version.page_size().get())), _phantom: PhantomData, }; @@ -434,6 +493,7 @@ where allocator: Allocator::load(memory, allocator_addr), version, length: header.length, + cache: RefCell::new(NodeCache::new(version.page_size().get())), _phantom: PhantomData, } } @@ -654,7 +714,7 @@ where return None; } self.traverse(self.root_addr, key, |node, idx| { - node.extract_entry_at(idx, self.memory()).1 // Extract value. + node.value(idx, self.memory()).to_vec() }) .map(Cow::Owned) .map(V::from_bytes) @@ -662,23 +722,34 @@ where /// Returns true if the key exists. pub fn contains_key(&self, key: &K) -> bool { - // An empty closure returns Some(()) if the key is found. self.root_addr != NULL && self.traverse(self.root_addr, key, |_, _| ()).is_some() } /// Recursively traverses from `node_addr`, invoking `f` if `key` is found. Stops at a leaf if not. + /// + /// Uses the node cache: nodes are taken out before use and returned after. fn traverse(&self, node_addr: Address, key: &K, f: F) -> Option where - F: Fn(&mut Node, usize) -> R, + F: Fn(&Node, usize) -> R, { - let mut node = self.load_node(node_addr); - // Look for the key in the current node. + let node = self.take_or_load_node(node_addr); match node.search(key, self.memory()) { - Ok(idx) => Some(f(&mut node, idx)), // Key found: apply `f`. - Err(idx) => match node.node_type() { - NodeType::Leaf => None, // At a leaf: key not present. - NodeType::Internal => self.traverse(node.child(idx), key, f), // Continue search in child. - }, + Ok(idx) => { + let result = f(&node, idx); + self.return_node(node); + Some(result) + } + Err(idx) => { + let child_addr = match node.node_type() { + NodeType::Leaf => { + self.return_node(node); + return None; + } + NodeType::Internal => node.child(idx), + }; + self.return_node(node); + self.traverse(child_addr, key, f) + } } } @@ -713,6 +784,7 @@ where self.root_addr = NULL; self.length = 0; self.allocator.clear(); + *self.cache.get_mut() = NodeCache::new(self.version.page_size().get()); self.save_header(); } @@ -722,8 +794,9 @@ where if self.root_addr == NULL { return None; } - let root = self.load_node(self.root_addr); + let root = self.take_or_load_node(self.root_addr); let (k, encoded_v) = root.get_min(self.memory()); + self.return_node(root); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -733,8 +806,9 @@ where if self.root_addr == NULL { return None; } - let root = self.load_node(self.root_addr); + let root = self.take_or_load_node(self.root_addr); let (k, encoded_v) = root.get_max(self.memory()); + self.return_node(root); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1273,7 +1347,13 @@ where /// [1, 2, 3, 4, 5, 6, 7] (stored in the `into` node) /// `source` is deallocated. fn merge(&mut self, source: Node, mut into: Node, median: Entry) -> Node { + let source_addr = source.address(); into.merge(source, median, &mut self.allocator); + // Node::merge saves `into` and deallocates `source` directly through + // the allocator, so we must invalidate both cache slots here. + let cache = self.cache.get_mut(); + cache.invalidate(into.address()); + cache.invalidate(source_addr); into } @@ -1285,22 +1365,41 @@ where } } - /// Deallocates a node. + /// Deallocates a node and invalidates its cache slot. #[inline] fn deallocate_node(&mut self, node: Node) { + let addr = node.address(); node.deallocate(self.allocator_mut()); + self.cache.get_mut().invalidate(addr); + } + + /// Takes a node from the cache, or loads it from memory if not cached. + /// + /// Used by read paths (`&self`). The caller must call `return_node` when + /// done to put the node back into the cache. + fn take_or_load_node(&self, address: Address) -> Node { + if let Some(node) = self.cache.borrow_mut().take(address) { + return node; + } + Node::load(address, self.version.page_size(), self.memory()) + } + + /// Returns a node to the cache after use on a read path. + fn return_node(&self, node: Node) { + self.cache.borrow_mut().put(node.address(), node); } - /// Loads a node from memory. + /// Loads a node from memory, bypassing the cache. #[inline] fn load_node(&self, address: Address) -> Node { Node::load(address, self.version.page_size(), self.memory()) } - /// Saves the node to memory. + /// Saves the node to memory and invalidates the cache slot. #[inline] fn save_node(&mut self, node: &mut Node) { node.save(self.allocator_mut()); + self.cache.get_mut().invalidate(node.address()); } /// Replaces the value at `idx` in the node, saves the node, and returns the old value. diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index 5daa0c40..b8d104fc 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -318,15 +318,6 @@ impl Node { .insert(idx, (LazyKey::by_value(key), LazyValue::by_value(value))); } - /// Returns the entry at the specified index while consuming this node. - pub fn extract_entry_at(&mut self, idx: usize, memory: &M) -> Entry { - let (key, value) = self.entries.swap_remove(idx); - ( - self.extract_key(key, memory), - self.extract_value(value, memory), - ) - } - /// Removes the entry at the specified index. pub fn remove_entry(&mut self, idx: usize, memory: &M) -> Entry { let (key, value) = self.entries.remove(idx); From c3a10724cdb1310a8030b1318bc25a1e2d2a4144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 20 Mar 2026 12:01:01 +0100 Subject: [PATCH 02/42] Update canbench results and add uncached reads --- benchmarks/btreemap/canbench_results.yml | 576 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 62 +-- src/btreemap.rs | 2 +- src/btreemap/node.rs | 27 ++ 4 files changed, 347 insertions(+), 320 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 2dabed3e..3b7bad04 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,1995 +2,1995 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142210325 + instructions: 18482246 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 277134712 + instructions: 187134264 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 4278312217 + instructions: 2944793213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 819285681 + instructions: 593610036 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 293742975 + instructions: 208606564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1310685287 + instructions: 954020425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 329571719 + instructions: 245081366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 326072097 + instructions: 250000243 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 326242314 + instructions: 245033845 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 318823973 + instructions: 248238620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 324026367 + instructions: 244881343 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 330971981 + instructions: 239674364 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 323046095 + instructions: 240914992 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 321643229 + instructions: 251689217 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 324885334 + instructions: 240249301 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 324308878 + instructions: 232365837 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 243884967 + instructions: 140689668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 2281494289 + instructions: 1654903502 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 403270584 + instructions: 335668696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 268086207 + instructions: 181444347 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 349062610 + instructions: 246048227 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 219629119 + instructions: 164479574 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 223284326 + instructions: 162143395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 219629119 + instructions: 156091162 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 374095890 + instructions: 235566587 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1817385622 + instructions: 1411128152 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 568150650 + instructions: 422459377 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 442851826 + instructions: 270172403 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 896432175 + instructions: 651860288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 355321635 + instructions: 279005799 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 520527229 + instructions: 367350171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 428325937 + instructions: 289854465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 367802150 + instructions: 299011462 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 433045196 + instructions: 305570848 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 355276471 + instructions: 274242434 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 352561298 + instructions: 259363022 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 454924839 + instructions: 335551833 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 398356880 + instructions: 274925035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 352626675 + instructions: 263351649 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 404252150 + instructions: 188215138 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1246829046 + instructions: 1030147142 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 493185629 + instructions: 338667333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 396603085 + instructions: 265935955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388592804 + instructions: 264852503 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 299599641 + instructions: 191789628 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 4457685507 + instructions: 2949582090 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 855273807 + instructions: 598652637 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 308463753 + instructions: 213183160 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 1367052477 + instructions: 959136408 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 337429950 + instructions: 246791396 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 350508333 + instructions: 262155839 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 341653262 + instructions: 249713118 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 330651190 + instructions: 252469161 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 342643724 + instructions: 249642209 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 342697250 + instructions: 244211211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 334169026 + instructions: 244667235 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 342695399 + instructions: 260114935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 336813935 + instructions: 245062558 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 335925065 + instructions: 236673028 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 254906111 + instructions: 145902230 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 2378828514 + instructions: 1659900963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 428744853 + instructions: 340703803 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 279716343 + instructions: 186605640 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 356428202 + instructions: 247908954 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 226446414 + instructions: 168727516 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 230534752 + instructions: 166767421 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 226935610 + instructions: 160616939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 379651663 + instructions: 242543353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1870806515 + instructions: 1416718089 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 577227038 + instructions: 430310829 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 449737724 + instructions: 276488750 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 905669607 + instructions: 659832382 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 358216658 + instructions: 280844485 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 544469486 + instructions: 390484640 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 436037967 + instructions: 296353403 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 373713570 + instructions: 303369246 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 447151619 + instructions: 318446833 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 361330699 + instructions: 278805184 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 358348309 + instructions: 263912722 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 472992093 + instructions: 348597169 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 404811886 + instructions: 279830023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 358456622 + instructions: 267935659 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 411151875 + instructions: 194386813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1256149861 + instructions: 1038168776 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501687251 + instructions: 345747166 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 403496154 + instructions: 272139935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4388592719 + instructions: 4387227618 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 436633391 + instructions: 437168425 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496222167 + instructions: 5496782790 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1180838234 + instructions: 1181402069 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486249812 + instructions: 486798371 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1789038066 + instructions: 1789598954 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 490459106 + instructions: 491017189 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 703500065 + instructions: 704055034 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 542568143 + instructions: 543121105 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519117156 + instructions: 519674235 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 570690137 + instructions: 571247103 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 528951192 + instructions: 529508588 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509380036 + instructions: 509936102 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610063051 + instructions: 610619295 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 534921249 + instructions: 535476147 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 517593840 + instructions: 518147099 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407268940 + instructions: 407778139 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041223382 + instructions: 3041785919 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661179485 + instructions: 661736171 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 458615568 + instructions: 459150697 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 503308324 + instructions: 503866730 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 406744693 + instructions: 407284638 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 414580548 + instructions: 415118683 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410372254 + instructions: 410912955 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 594103663 + instructions: 593348835 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2744606200 + instructions: 2745078501 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1012643373 + instructions: 1013193412 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 708997439 + instructions: 709536461 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1402219761 + instructions: 1402747303 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 621849784 - heap_increase: 0 + instructions: 621090062 + heap_increase: 1 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1182132701 + instructions: 1181290163 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 756106158 + instructions: 755323238 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 666191903 + instructions: 665421183 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 869225881 + instructions: 868439443 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 661645394 + instructions: 660880230 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 660354036 + instructions: 659583890 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 973664463 + instructions: 972858640 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 691643081 + instructions: 690861909 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 659845953 + instructions: 659078546 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604355928 - heap_increase: 0 + instructions: 604860371 + heap_increase: 1 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1859161681 + instructions: 1858344666 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846320282 + instructions: 846858422 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 666289233 - heap_increase: 0 + instructions: 665525462 + heap_increase: 1 stable_memory_increase: 23 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 2349312653 + instructions: 1662857542 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 278855238 + instructions: 197299563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 283522171 + instructions: 198205456 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 367041614 + instructions: 254851402 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1201243952 + instructions: 922477374 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 2458034243 + instructions: 1668157665 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 295406794 + instructions: 206942000 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 291718588 + instructions: 203626104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 388831325 + instructions: 271395508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1242312078 + instructions: 930146772 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3127680452 + instructions: 3128432076 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: calls: 1 - instructions: 607288370 + instructions: 608020860 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 520545864 + instructions: 521278454 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 834100595 + instructions: 834948896 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1964405448 + instructions: 1963938415 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4310221225 + instructions: 4311796818 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 882970074 + instructions: 884618642 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 736785650 + instructions: 738411478 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1223804753 + instructions: 1225631059 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3084565257 + instructions: 3085313551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 599256189 + instructions: 600095870 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8387602842 + instructions: 8388704292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1824725965 + instructions: 1825803787 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 743084112 + instructions: 744048656 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2763911828 + instructions: 2764998607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 751497584 + instructions: 752526510 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1121481321 + instructions: 1122511399 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 860285162 + instructions: 861323742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 795095715 + instructions: 796116025 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 891739804 + instructions: 892773686 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 808560505 + instructions: 809579026 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 778864648 + instructions: 779893121 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 957571175 + instructions: 958601126 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 817406508 + instructions: 818428248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 796779002 + instructions: 797819723 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 371435725 + instructions: 371984968 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4613700344 + instructions: 4614791291 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1031695256 + instructions: 1032768755 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 604976184 + instructions: 605806118 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 800191973 + instructions: 801253147 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 669276877 + instructions: 670348573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 681264462 + instructions: 682338475 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 671829217 + instructions: 672901741 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 782876135 + instructions: 782990741 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4049265076 + instructions: 4050249046 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1503218744 + instructions: 1504273439 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1024772148 + instructions: 1025736559 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2019891066 + instructions: 2020915633 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 862946599 + instructions: 863081986 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1689829372 + instructions: 1689866318 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1088869698 + instructions: 1088992450 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 928270806 + instructions: 928389791 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1215466767 + instructions: 1215585108 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 931028208 + instructions: 931147986 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 914745699 + instructions: 914883634 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1373268399 + instructions: 1373352212 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 972735601 + instructions: 972857069 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 924967663 + instructions: 925109531 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 540984708 + instructions: 541543657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2716330411 + instructions: 2716413527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1234556907 + instructions: 1235585572 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 850734232 + instructions: 850851341 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 575661530 + instructions: 576559885 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8055247791 + instructions: 8056356881 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1755509118 + instructions: 1756597278 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 716556083 + instructions: 717530897 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2669730307 + instructions: 2670829657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 723335313 + instructions: 724372248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1085450731 + instructions: 1086491529 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 825902306 + instructions: 826951393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 766901397 + instructions: 767933115 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 860879651 + instructions: 861924147 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 775936416 + instructions: 776964692 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 755124599 + instructions: 756161526 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 932320719 + instructions: 933359777 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 791545690 + instructions: 792576883 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 768161716 + instructions: 769213912 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 357885021 + instructions: 358500576 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4444567386 + instructions: 4445668424 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 999738711 + instructions: 1000823636 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 598942864 + instructions: 599823615 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 780291969 + instructions: 781329628 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 645812582 + instructions: 647012138 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 657455588 + instructions: 658657268 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 648268033 + instructions: 649468860 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 759547094 + instructions: 759681953 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4254818123 + instructions: 4255809727 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1509650210 + instructions: 1510715380 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1006125814 + instructions: 1007100483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2073363853 + instructions: 2074400177 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 846109662 + instructions: 846241612 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1664437667 + instructions: 1664491218 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1064611264 + instructions: 1064748196 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 902974455 + instructions: 903112288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1193452039 + instructions: 1193583640 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 910490347 + instructions: 910624308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 898985596 + instructions: 899125898 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1356914135 + instructions: 1357006105 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 949782755 + instructions: 949913494 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 902473492 + instructions: 902629600 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 527064939 + instructions: 527629807 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2808165041 + instructions: 2808260663 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1220824533 + instructions: 1221864433 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 850619579 + instructions: 850726825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_0b: total: calls: 1 - instructions: 16962 + instructions: 16964 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2507196 + instructions: 2507198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 18468765 + instructions: 18468767 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_0b: total: calls: 1 - instructions: 16933 + instructions: 16935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 2572994 + instructions: 2572996 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 18469999 + instructions: 18470001 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_0b: total: calls: 1 - instructions: 17300 + instructions: 17302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 20668618 + instructions: 20668620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 398305226 + instructions: 398305228 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4711118385 + instructions: 4709567410 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 584636969 + instructions: 585830278 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7363800309 + instructions: 7365191131 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1588756329 + instructions: 1590127722 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665337905 + instructions: 666633118 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2421697300 + instructions: 2423069262 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 654250005 + instructions: 655578571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 985325869 + instructions: 986632504 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 746608890 + instructions: 747912442 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 700059994 + instructions: 701357690 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784125701 + instructions: 785430027 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 711919498 + instructions: 713229366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696214241 + instructions: 697546995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 857936684 + instructions: 859266737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 737074307 + instructions: 738432503 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 696057915 + instructions: 697351398 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 452857933 + instructions: 453656380 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4071507249 + instructions: 4072899827 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 910052271 + instructions: 911363849 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599299651 + instructions: 600505934 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 684159422 + instructions: 685512541 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566079913 + instructions: 567518806 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 586718731 + instructions: 588171920 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 571366355 + instructions: 572786465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 755823918 + instructions: 756048064 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4475943466 + instructions: 4477187214 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1418213214 + instructions: 1419538762 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 921111290 + instructions: 922396009 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2244668594 + instructions: 2245931148 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 834330028 + instructions: 834665077 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1701563272 + instructions: 1701754536 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1036968514 + instructions: 1037240444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 871328883 + instructions: 871626827 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1240176546 + instructions: 1240476802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 867569469 + instructions: 867877637 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 862147420 + instructions: 862483197 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1405971132 + instructions: 1406217953 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 968312981 + instructions: 968659703 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 856477157 + instructions: 856782328 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 662121914 + instructions: 662867447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3082706271 + instructions: 3083022222 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1183958569 + instructions: 1185217898 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 821774415 + instructions: 821944350 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index 8c79367a..b58fd1b1 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: 7265892372 + instructions: 7266733124 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1636767402 + instructions: 1637608154 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 715664326 + instructions: 716505078 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2445225121 + instructions: 2446065873 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 814718710 + instructions: 815559462 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4049839436 + instructions: 4050680188 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 980469261 + instructions: 981310013 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 694043361 + instructions: 694884113 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 540164863 + instructions: 541005615 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 561497942 + instructions: 562338694 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -422,140 +422,140 @@ benches: btreeset_range_blob_1024: total: calls: 1 - instructions: 259870196 + instructions: 259870198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_128: total: calls: 1 - instructions: 45508439 + instructions: 45508441 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_16: total: calls: 1 - instructions: 9508605 + instructions: 9508607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_256: total: calls: 1 - instructions: 76456411 + instructions: 76456413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_32: total: calls: 1 - instructions: 13294157 + instructions: 13294159 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_512: total: calls: 1 - instructions: 137589173 + instructions: 137589175 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_64: total: calls: 1 - instructions: 24443488 + instructions: 24443490 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_8: total: calls: 1 - instructions: 9144616 + instructions: 9144618 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_u32: total: calls: 1 - instructions: 6480292 + instructions: 6480294 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_u64: total: calls: 1 - instructions: 6624379 + instructions: 6624381 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_1024: total: calls: 1 - instructions: 7722749146 + instructions: 7723612026 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1666415454 + instructions: 1667278334 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 705483928 + instructions: 706326808 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2534126706 + instructions: 2534989586 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 802114863 + instructions: 802957743 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4261462921 - heap_increase: 0 + instructions: 4262349463 + heap_increase: 1 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 987128732 + instructions: 987991612 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 683601373 + instructions: 684444253 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 528154844 + instructions: 528997724 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 553060549 + instructions: 553903429 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 58d67b4a..aa1cfa80 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -714,7 +714,7 @@ where return None; } self.traverse(self.root_addr, key, |node, idx| { - node.value(idx, self.memory()).to_vec() + node.read_value_uncached(idx, self.memory()) }) .map(Cow::Owned) .map(V::from_bytes) diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index b8d104fc..ea912c70 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -205,6 +205,15 @@ impl Node { self.get_value(&self.entries[idx], memory) } + /// Reads the value at `idx` without storing it in the node's lazy cache. + /// Avoids inflating cached nodes with large value buffers. + #[inline(always)] + pub fn read_value_uncached(&self, idx: usize, memory: &M) -> Vec { + self.entries[idx] + .1 + .read_uncached(|offset, size| self.load_value_from_memory(offset, size, memory)) + } + /// Extracts the contents of key (by loading it first if it's not loaded yet). fn extract_key(&self, key: LazyKey, memory: &M) -> K { key.take_or_load(|offset, size| self.load_key_from_memory(offset, size, memory)) @@ -593,6 +602,24 @@ impl LazyValue { pub fn take_or_load(self, load: impl FnOnce(Bytes, u32) -> Blob) -> Blob { self.0.take_or_load(load) } + + /// Reads the value without populating the OnceCell. + /// Returns the already-loaded value if present, otherwise reads from memory + /// into a fresh buffer without storing it in the node. + #[inline(always)] + fn read_uncached(&self, load: impl FnOnce(Bytes, u32) -> Blob) -> Blob { + match &self.0 { + LazyObject::ByVal(v) => v.clone(), + LazyObject::ByRef { + offset, + size, + loaded, + } => loaded + .get() + .cloned() + .unwrap_or_else(|| load(*offset, *size)), + } + } } #[derive(Debug)] From 1ab43e96b659533fd6e69d0070fe71617471726d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 20 Mar 2026 12:13:03 +0100 Subject: [PATCH 03/42] Update io-chunks perf --- benchmarks/io_chunks/canbench_results.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/benchmarks/io_chunks/canbench_results.yml b/benchmarks/io_chunks/canbench_results.yml index b9b59d80..6df6b8c3 100644 --- a/benchmarks/io_chunks/canbench_results.yml +++ b/benchmarks/io_chunks/canbench_results.yml @@ -2,21 +2,21 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 148723585 + instructions: 148723284 heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 498228206 + instructions: 203406339 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 40940569325 + instructions: 12127804634 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 360207245 + instructions: 357205451 heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4194582593 + instructions: 4187201659 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 83673829307 + instructions: 83738699843 heap_increase: 0 stable_memory_increase: 3072 scopes: {} @@ -107,21 +107,21 @@ benches: write_chunks_vec_1: total: calls: 1 - instructions: 549903446 + instructions: 549903461 heap_increase: 0 stable_memory_increase: 1536 scopes: {} write_chunks_vec_1k: total: calls: 1 - instructions: 562132513 + instructions: 562145515 heap_increase: 0 stable_memory_increase: 1536 scopes: {} write_chunks_vec_1m: total: calls: 1 - instructions: 1771593099 + instructions: 1784593101 heap_increase: 0 stable_memory_increase: 1536 scopes: {} From cc8189421753a9bd8c829bb5984f1db6fbb434a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Wed, 25 Mar 2026 14:38:04 +0100 Subject: [PATCH 04/42] Make NodeCache size configurable at construction size, and track and expose hit/miss stats --- src/btreemap.rs | 177 +++++++++++++++++++++++++++++++++++++++++++++--- src/lib.rs | 2 +- 2 files changed, 167 insertions(+), 12 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index aa1cfa80..d0b2335c 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -82,11 +82,34 @@ const DEFAULT_PAGE_SIZE: u32 = 1024; // A marker to indicate that the `PageSize` stored in the header is a `PageSize::Value`. const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; -const NODE_CACHE_NUM_SLOTS: usize = 32; +/// Default number of slots in the direct-mapped node cache. +/// +/// The B-tree has a branching factor of ~11 (max entries per node), so each +/// tree level contains roughly 11× more nodes than the one above: +/// +/// | Level | Nodes | Cumulative | +/// |-------|-------|------------| +/// | 0 (root) | 1 | 1 | +/// | 1 | ~11 | ~12 | +/// | 2 | ~121 | ~133 | +/// | 3 | ~1 331 | ~1 464 | +/// +/// With 32 slots the top 2 levels (≤12 nodes) stay cached with zero +/// collisions because nodes are allocated at sequential addresses that map +/// to distinct slots. Every lookup traverses root → one level-1 child, so +/// those 2 cache hits save 2 stable-memory reads per operation regardless +/// of total tree size. +/// +/// * 64 slots would add partial level-2 coverage but doubles heap cost for +/// diminishing returns. +/// * 16 slots risks collisions among the 12 top-level nodes. +/// +/// 32 is the smallest power of two that fits levels 0 + 1 comfortably. +const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 32; /// A direct-mapped node cache modeled after CPU caches. /// -/// Each slot is indexed by `(node_address / page_size) % NUM_SLOTS`. Lookup +/// Each slot is indexed by `(node_address / page_size) % num_slots`. Lookup /// is O(1) with ~5 instructions overhead. Collision = eviction (no LRU /// tracking needed). /// @@ -95,42 +118,93 @@ const NODE_CACHE_NUM_SLOTS: usize = 32; struct NodeCache { slots: Vec<(Address, Option>)>, page_size: u32, + hits: u64, + misses: u64, +} + +/// Cache performance counters. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct CacheStats { + pub hits: u64, + pub misses: u64, +} + +impl CacheStats { + /// Returns the hit ratio as a value between 0.0 and 1.0. + /// Returns 0.0 if no lookups have been performed. + pub fn hit_ratio(&self) -> f64 { + let total = self.hits + self.misses; + if total == 0 { + 0.0 + } else { + self.hits as f64 / total as f64 + } + } } impl NodeCache { - fn new(page_size: u32) -> Self { - let mut slots = Vec::with_capacity(NODE_CACHE_NUM_SLOTS); - for _ in 0..NODE_CACHE_NUM_SLOTS { + fn new(page_size: u32, num_slots: usize) -> Self { + let mut slots = Vec::with_capacity(num_slots); + for _ in 0..num_slots { slots.push((NULL, None)); } - Self { slots, page_size } + Self { + slots, + page_size, + hits: 0, + misses: 0, + } + } + + fn is_enabled(&self) -> bool { + !self.slots.is_empty() } fn slot_index(&self, addr: Address) -> usize { - (addr.get() / self.page_size as u64) as usize % NODE_CACHE_NUM_SLOTS + debug_assert!(self.is_enabled()); + (addr.get() / self.page_size as u64) as usize % self.slots.len() } fn take(&mut self, addr: Address) -> Option> { + if !self.is_enabled() { + self.misses += 1; + return None; + } let idx = self.slot_index(addr); if self.slots[idx].0 == addr { self.slots[idx].0 = NULL; + self.hits += 1; self.slots[idx].1.take() } else { + self.misses += 1; None } } fn put(&mut self, addr: Address, node: Node) { + if !self.is_enabled() { + return; + } let idx = self.slot_index(addr); self.slots[idx] = (addr, Some(node)); } fn invalidate(&mut self, addr: Address) { + if !self.is_enabled() { + return; + } let idx = self.slot_index(addr); if self.slots[idx].0 == addr { self.slots[idx] = (NULL, None); } } + + fn stats(&self) -> CacheStats { + CacheStats { + hits: self.hits, + misses: self.misses, + } + } } /// A B-Tree map implementation that stores its data into a designated memory. @@ -300,6 +374,10 @@ where // The number of elements in the map. length: u64, + // Number of slots in the direct-mapped node cache. + // Stored so we can recreate the cache with the same configuration on clear(). + cache_num_slots: usize, + // Direct-mapped node cache to avoid re-loading hot nodes from stable memory. cache: RefCell>, @@ -344,6 +422,71 @@ where } } + /// Configures the size of the node cache in bytes. + /// + /// The cache is a direct-mapped cache that keeps frequently accessed + /// B-tree nodes in heap memory to avoid repeated stable-memory reads. + /// The byte budget is converted to a number of cache slots by dividing + /// by the node page size and rounding to the nearest power of two. + /// + /// Pass `0` to disable the cache entirely. + /// + /// # Default + /// + /// The default cache holds 32 slots. + /// This is the smallest power of two that fits the top 2 levels of the + /// B-tree (root + its ~11 children) with no collisions, giving 2 cache + /// hits per lookup regardless of tree size. + /// + /// # Examples + /// + /// ```rust + /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; + /// + /// // 10 MB cache + /// let map: BTreeMap = + /// BTreeMap::init(DefaultMemoryImpl::default()) + /// .with_cache_size(10 * 1024 * 1024); + /// + /// // Disable the cache + /// let map: BTreeMap = + /// BTreeMap::init(DefaultMemoryImpl::default()) + /// .with_cache_size(0); + /// ``` + pub fn with_cache_size(mut self, bytes: u64) -> Self { + let page_size = self.version.page_size().get() as u64; + let num_slots = if bytes == 0 { + 0 + } else { + (bytes / page_size).max(1).next_power_of_two() as usize + }; + self.cache_num_slots = num_slots; + *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); + self + } + + /// Returns cache performance counters. + /// + /// Use these to monitor cache effectiveness and tune the cache size + /// via [`with_cache_size`](Self::with_cache_size). + /// + /// # Examples + /// + /// ```rust + /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; + /// + /// let mut map: BTreeMap = + /// BTreeMap::init(DefaultMemoryImpl::default()); + /// map.insert(1, 100); + /// let _ = map.get(&1); + /// + /// let stats = map.cache_stats(); + /// println!("hit ratio: {:.1}%", stats.hit_ratio() * 100.0); + /// ``` + pub fn cache_stats(&self) -> CacheStats { + self.cache.borrow().stats() + } + /// Initializes a v1 `BTreeMap`. /// /// This is exposed only in testing. @@ -413,7 +556,11 @@ where ), version: Version::V2(page_size), length: 0, - cache: RefCell::new(NodeCache::new(page_size.get())), + cache_num_slots: DEFAULT_NODE_CACHE_NUM_SLOTS, + cache: RefCell::new(NodeCache::new( + page_size.get(), + DEFAULT_NODE_CACHE_NUM_SLOTS, + )), _phantom: PhantomData, }; @@ -443,7 +590,11 @@ where ), version, length: 0, - cache: RefCell::new(NodeCache::new(version.page_size().get())), + cache_num_slots: DEFAULT_NODE_CACHE_NUM_SLOTS, + cache: RefCell::new(NodeCache::new( + version.page_size().get(), + DEFAULT_NODE_CACHE_NUM_SLOTS, + )), _phantom: PhantomData, }; @@ -493,7 +644,11 @@ where allocator: Allocator::load(memory, allocator_addr), version, length: header.length, - cache: RefCell::new(NodeCache::new(version.page_size().get())), + cache_num_slots: DEFAULT_NODE_CACHE_NUM_SLOTS, + cache: RefCell::new(NodeCache::new( + version.page_size().get(), + DEFAULT_NODE_CACHE_NUM_SLOTS, + )), _phantom: PhantomData, } } @@ -784,7 +939,7 @@ where self.root_addr = NULL; self.length = 0; self.allocator.clear(); - *self.cache.get_mut() = NodeCache::new(self.version.page_size().get()); + *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), self.cache_num_slots); self.save_header(); } diff --git a/src/lib.rs b/src/lib.rs index 5b5a98fc..25074e0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ pub mod vec; pub mod vec_mem; pub mod writer; -pub use btreemap::{BTreeMap, BTreeMap as StableBTreeMap}; +pub use btreemap::{BTreeMap, BTreeMap as StableBTreeMap, CacheStats}; pub use btreeset::{BTreeSet, BTreeSet as StableBTreeSet}; pub use file_mem::FileMemory; #[cfg(target_arch = "wasm32")] From ec14e6dce837a7d01f246266af22029fcca987fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Wed, 25 Mar 2026 14:40:59 +0100 Subject: [PATCH 05/42] fmt --- src/btreemap.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index d0b2335c..07ae4f4a 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -939,7 +939,8 @@ where self.root_addr = NULL; self.length = 0; self.allocator.clear(); - *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), self.cache_num_slots); + *self.cache.get_mut() = + NodeCache::new(self.version.page_size().get(), self.cache_num_slots); self.save_header(); } From 53c2c37c3d7afcc6935037c7b4dc1becd2f2c0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Thu, 26 Mar 2026 17:55:35 +0100 Subject: [PATCH 06/42] update results and reviews --- benchmarks/btreemap/canbench_results.yml | 642 ++++++++++++---------- benchmarks/btreemap/src/main.rs | 44 ++ benchmarks/btreeset/canbench_results.yml | 42 +- benchmarks/io_chunks/canbench_results.yml | 12 +- src/btreemap.rs | 213 +++++-- 5 files changed, 611 insertions(+), 342 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 3b7bad04..9ac141c0 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,1631 +2,1694 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 18482246 + instructions: 142229570 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 187134264 + instructions: 300167392 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 2944793213 + instructions: 4286397285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 593610036 + instructions: 828790249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 208606564 + instructions: 301080947 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 954020425 + instructions: 1318518633 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 245081366 + instructions: 335083916 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 250000243 + instructions: 332585344 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 245033845 + instructions: 332576427 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_blob_32_128_cached_32entry: + total: + calls: 1 + instructions: 245878499 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 248238620 + instructions: 325435860 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 244881343 + instructions: 330793474 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 239674364 + instructions: 335022835 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 240914992 + instructions: 328835359 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 251689217 + instructions: 328788296 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 240249301 + instructions: 331384312 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 232365837 + instructions: 330764242 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 140689668 + instructions: 250950007 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 1654903502 + instructions: 2290387899 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 335668696 + instructions: 408981840 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 181444347 + instructions: 273650788 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 246048227 + instructions: 355737299 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 164479574 + instructions: 226482899 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 162143395 + instructions: 229607502 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_u64_u64_cached_32entry: + total: + calls: 1 + instructions: 162978425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 156091162 + instructions: 226482899 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 235566587 + instructions: 381755139 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1411128152 + instructions: 1860576961 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 422459377 + instructions: 568870538 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 270172403 + instructions: 441474534 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 651860288 + instructions: 900622956 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 279005799 + instructions: 365610144 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 367350171 + instructions: 493941216 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 289854465 + instructions: 421455526 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_contains_vec_32_128_cached_32entry: + total: + calls: 1 + instructions: 290697001 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 299011462 + instructions: 373320046 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 305570848 + instructions: 439607589 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 274242434 + instructions: 362903003 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 259363022 + instructions: 375619686 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 335551833 + instructions: 458608779 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 274925035 + instructions: 409735939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 263351649 + instructions: 376062932 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 188215138 + instructions: 404701150 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1030147142 + instructions: 1235984162 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 338667333 + instructions: 503153094 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 265935955 + instructions: 399063664 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 264852503 + instructions: 388604627 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 191789628 + instructions: 304726975 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 2949582090 + instructions: 4291440795 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 598652637 + instructions: 833840112 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 213183160 + instructions: 306048666 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 959136408 + instructions: 1323549944 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 246791396 + instructions: 336793946 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 262155839 + instructions: 343218346 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 249713118 + instructions: 337516150 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_blob_32_128_cached_32entry: + total: + calls: 1 + instructions: 250557772 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 252469161 + instructions: 329686154 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 249642209 + instructions: 336390450 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 244211211 + instructions: 339421666 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 244667235 + instructions: 332566900 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 260114935 + instructions: 336384847 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 245062558 + instructions: 335954966 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 236673028 + instructions: 334806316 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 145902230 + instructions: 256050245 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 1659900963 + instructions: 2295436807 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 340703803 + instructions: 414041110 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 186605640 + instructions: 278781207 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 247908954 + instructions: 357598026 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 168727516 + instructions: 230605141 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 166767421 + instructions: 234129779 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_u64_u64_cached_32entry: + total: + calls: 1 + instructions: 167602451 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 160616939 + instructions: 230909165 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 242543353 + instructions: 386523249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1416718089 + instructions: 1871057563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 430310829 + instructions: 576645044 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 276488750 + instructions: 447782546 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 659832382 + instructions: 908544922 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 280844485 + instructions: 367448830 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 390484640 + instructions: 517190987 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 296353403 + instructions: 427990005 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_get_vec_32_128_cached_32entry: + total: + calls: 1 + instructions: 297195939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 303369246 + instructions: 377969171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 318446833 + instructions: 452603736 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 278805184 + instructions: 367711808 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 263912722 + instructions: 380149092 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 348597169 + instructions: 475468755 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 279830023 + instructions: 414911394 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 267935659 + instructions: 380632402 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 194386813 + instructions: 410752111 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1038168776 + instructions: 1243811689 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 345747166 + instructions: 510129615 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 272139935 + instructions: 405215725 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4387227618 + instructions: 4387226708 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 437168425 + instructions: 436709225 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496782790 + instructions: 5496293245 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1181402069 + instructions: 1180911684 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486798371 + instructions: 486322476 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1789598954 + instructions: 1789108884 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 491017189 + instructions: 490533629 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 704055034 + instructions: 703571159 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 543121105 + instructions: 542638910 + heap_increase: 0 + stable_memory_increase: 28 + scopes: {} + btreemap_v2_insert_blob_32_128_cached_32entry: + total: + calls: 1 + instructions: 543217544 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519674235 + instructions: 519188260 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 571247103 + instructions: 570762598 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 529508588 + instructions: 529023348 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509936102 + instructions: 509451702 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610619295 + instructions: 610134685 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 535476147 + instructions: 534992272 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 518147099 + instructions: 517665219 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407778139 + instructions: 407355164 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041785919 + instructions: 3041295219 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661736171 + instructions: 661249041 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 459150697 + instructions: 458692022 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 503866730 + instructions: 503377605 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 407284638 + instructions: 406794043 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 415118683 + instructions: 414627878 + heap_increase: 0 + stable_memory_increase: 6 + scopes: {} + btreemap_v2_insert_u64_u64_cached_32entry: + total: + calls: 1 + instructions: 415216844 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410912955 + instructions: 410422360 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 593348835 + instructions: 592889950 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2745078501 + instructions: 2744588956 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1013193412 + instructions: 1012703027 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 709536461 + instructions: 709060566 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1402747303 + instructions: 1402257128 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 621090062 - heap_increase: 1 + instructions: 620606035 + heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1181290163 + instructions: 1180806288 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 755323238 + instructions: 754841043 + heap_increase: 0 + stable_memory_increase: 33 + scopes: {} + btreemap_v2_insert_vec_32_128_cached_32entry: + total: + calls: 1 + instructions: 755419677 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 665421183 + instructions: 664935313 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 868439443 + instructions: 867954938 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 660880230 + instructions: 660394990 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 659583890 + instructions: 659099490 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 972858640 + instructions: 972374030 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 690861909 + instructions: 690378034 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 659078546 + instructions: 658596666 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604860371 - heap_increase: 1 + instructions: 604437139 + heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1858344666 + instructions: 1857853966 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846858422 + instructions: 846371292 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 665525462 - heap_increase: 1 + instructions: 665066425 + heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 1662857542 + instructions: 2358760299 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 197299563 + instructions: 285805346 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 198205456 + instructions: 289714366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 254851402 + instructions: 368616168 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 922477374 + instructions: 1267371016 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 1668157665 + instructions: 2365920667 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 206942000 + instructions: 294270839 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 203626104 + instructions: 295027558 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 271395508 + instructions: 383090319 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 930146772 + instructions: 1275457142 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3128432076 + instructions: 3127942006 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: calls: 1 - instructions: 608020860 + instructions: 607527955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 521278454 + instructions: 520787649 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 834948896 + instructions: 834455991 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1963938415 + instructions: 1963448345 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4311796818 + instructions: 4310758963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 884618642 + instructions: 883593492 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 738411478 + instructions: 737401273 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1225631059 + instructions: 1224605909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3085313551 + instructions: 3084275696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 600095870 + instructions: 599444870 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8388704292 + instructions: 8387866497 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1825803787 + instructions: 1824981182 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 744048656 + instructions: 743301756 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2764998607 + instructions: 2764167882 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 752526510 + instructions: 751729105 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1122511399 + instructions: 1121712594 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 861323742 + instructions: 860518357 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 796116025 + instructions: 795323065 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 892773686 + instructions: 891973131 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 809579026 + instructions: 808788096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 779893121 + instructions: 779096766 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 958601126 + instructions: 957804106 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 818428248 + instructions: 817635848 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 797819723 + instructions: 797013498 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 371984968 + instructions: 371556043 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4614791291 + instructions: 4613959936 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1032768755 + instructions: 1031950490 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 605806118 + instructions: 605165233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 801253147 + instructions: 800436737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 670348573 + instructions: 669514103 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 682338475 + instructions: 681505055 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 672901741 + instructions: 672067271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 782990741 + instructions: 782339951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4050249046 + instructions: 4049411251 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1504273439 + instructions: 1503451079 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1025736559 + instructions: 1024989939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2020915633 + instructions: 2020084943 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 863081986 + instructions: 862284896 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1689866318 + instructions: 1689068528 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1088992450 + instructions: 1088187240 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 928389791 + instructions: 927596586 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1215585108 + instructions: 1214784693 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 931147986 + instructions: 930357336 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 914883634 + instructions: 914087279 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1373352212 + instructions: 1372555472 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 972857069 + instructions: 972064704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 925109531 + instructions: 924303586 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 541543657 + instructions: 541115642 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2716413527 + instructions: 2715582172 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1235585572 + instructions: 1234767342 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 850851341 + instructions: 850211681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 576559885 + instructions: 575908780 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8056356881 + instructions: 8055518981 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1756597278 + instructions: 1755774253 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 717530897 + instructions: 716784102 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2670829657 + instructions: 2669998617 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 724372248 + instructions: 723573793 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1086491529 + instructions: 1085692619 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 826951393 + instructions: 826145903 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 767933115 + instructions: 767140365 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 861924147 + instructions: 861123382 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 776964692 + instructions: 776173867 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 756161526 + instructions: 755364541 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 933359777 + instructions: 932562547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 792576883 + instructions: 791784273 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 769213912 + instructions: 768406742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 358500576 + instructions: 358071231 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4445668424 + instructions: 4444837489 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 1000823636 + instructions: 1000005266 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 599823615 + instructions: 599183465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 781329628 + instructions: 780512483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 647012138 + instructions: 646177878 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 658657268 + instructions: 657824058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 649468860 + instructions: 648634600 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 759681953 + instructions: 759030848 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4255809727 + instructions: 4254971827 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1510715380 + instructions: 1509892495 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1007100483 + instructions: 1006353968 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2074400177 + instructions: 2073569697 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 846241612 + instructions: 845443577 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1664491218 + instructions: 1663693008 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1064748196 + instructions: 1063942986 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 903112288 + instructions: 902319398 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1193583640 + instructions: 1192783015 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 910624308 + instructions: 909833763 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 899125898 + instructions: 898328913 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1357006105 + instructions: 1356209155 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 949913494 + instructions: 949121024 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 902629600 + instructions: 901822710 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 527629807 + instructions: 527201582 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2808260663 + instructions: 2807429728 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1221864433 + instructions: 1221046203 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 850726825 + instructions: 850087795 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1696,301 +1759,322 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4709567410 + instructions: 4709566185 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 585830278 + instructions: 584961228 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7365191131 + instructions: 7364162621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1590127722 + instructions: 1589112722 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 666633118 + instructions: 665656233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2423069262 + instructions: 2422055032 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 655578571 + instructions: 654579216 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 986632504 + instructions: 985648444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 747912442 + instructions: 746930902 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_128_cached_32entry: + total: + calls: 1 + instructions: 748108750 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 701357690 + instructions: 700379720 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 785430027 + instructions: 784447437 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 713229366 + instructions: 712242366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 697546995 + instructions: 696545085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 859266737 + instructions: 858265527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 738432503 + instructions: 737412253 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 697351398 + instructions: 696375353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 453656380 + instructions: 453069395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4072899827 + instructions: 4071869567 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 911363849 + instructions: 910390114 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 600505934 + instructions: 599629254 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 685512541 + instructions: 684480216 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 567518806 + instructions: 566517736 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 588171920 + instructions: 587161715 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_u64_u64_cached_32entry: + total: + calls: 1 + instructions: 588373961 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 572786465 + instructions: 571785395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 756048064 + instructions: 755155844 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4477187214 + instructions: 4476158704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1419538762 + instructions: 1418524112 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 922396009 + instructions: 921411284 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2245931148 + instructions: 2244929518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 834665077 + instructions: 833674437 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1701754536 + instructions: 1700784231 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1037240444 + instructions: 1036266814 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_128_cached_32entry: + total: + calls: 1 + instructions: 1037435170 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 871626827 + instructions: 870649277 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1240476802 + instructions: 1239481192 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 867877637 + instructions: 866890672 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 862483197 + instructions: 861481287 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1406217953 + instructions: 1405227943 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 968659703 + instructions: 967639488 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 856782328 + instructions: 855796413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 662867447 + instructions: 662260967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3083022222 + instructions: 3081991962 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1185217898 + instructions: 1184235903 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 821944350 + instructions: 821067705 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 167b973c..9b0e3d28 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -815,4 +815,48 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { }) } +// --- Cached (32-slot) variants --- +// +// These duplicate a representative subset of benchmarks with a 32-slot +// direct-mapped node cache enabled, so the effect of caching can be +// compared against the default (cache disabled) results above. + +fn insert_helper_v2_cached_32entry() -> BenchResult { + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + insert_helper::(btree) +} + +fn get_helper_v2_cached_32entry() -> BenchResult { + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + get_helper::(btree) +} + +fn remove_helper_v2_cached_32entry() -> BenchResult { + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + remove_helper::(btree) +} + +fn contains_helper_v2_cached_32entry() -> BenchResult { + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + contains_helper::(btree) +} + +bench_tests! { + btreemap_v2_insert_u64_u64_cached_32entry, insert_helper_v2_cached_32entry, u64, u64; + btreemap_v2_insert_blob_32_128_cached_32entry, insert_helper_v2_cached_32entry, Blob32, Blob128; + btreemap_v2_insert_vec_32_128_cached_32entry, insert_helper_v2_cached_32entry, UnboundedVecN32, UnboundedVecN128; + + btreemap_v2_get_u64_u64_cached_32entry, get_helper_v2_cached_32entry, u64, u64; + btreemap_v2_get_blob_32_128_cached_32entry, get_helper_v2_cached_32entry, Blob32, Blob128; + btreemap_v2_get_vec_32_128_cached_32entry, get_helper_v2_cached_32entry, UnboundedVecN32, UnboundedVecN128; + + btreemap_v2_remove_u64_u64_cached_32entry, remove_helper_v2_cached_32entry, u64, u64; + btreemap_v2_remove_blob_32_128_cached_32entry, remove_helper_v2_cached_32entry, Blob32, Blob128; + btreemap_v2_remove_vec_32_128_cached_32entry, remove_helper_v2_cached_32entry, UnboundedVecN32, UnboundedVecN128; + + btreemap_v2_contains_u64_u64_cached_32entry, contains_helper_v2_cached_32entry, u64, u64; + btreemap_v2_contains_blob_32_128_cached_32entry, contains_helper_v2_cached_32entry, Blob32, Blob128; + btreemap_v2_contains_vec_32_128_cached_32entry, contains_helper_v2_cached_32entry, UnboundedVecN32, UnboundedVecN128; +} + fn main() {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index b58fd1b1..e7967ac3 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: 7266733124 + instructions: 7266173964 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1637608154 + instructions: 1637048994 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 716505078 + instructions: 715945918 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2446065873 + instructions: 2445506713 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 815559462 + instructions: 815000302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4050680188 + instructions: 4050121028 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 981310013 + instructions: 980750853 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 694884113 + instructions: 694324953 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 541005615 + instructions: 540446455 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 562338694 + instructions: 561779534 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,70 +492,70 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7723612026 + instructions: 7723051396 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1667278334 + instructions: 1666717704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 706326808 + instructions: 705766178 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2534989586 + instructions: 2534428956 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 802957743 + instructions: 802397113 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4262349463 - heap_increase: 1 + instructions: 4261765171 + heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 987991612 + instructions: 987430982 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 684444253 + instructions: 683883623 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 528997724 + instructions: 528437094 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 553903429 + instructions: 553342799 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/io_chunks/canbench_results.yml b/benchmarks/io_chunks/canbench_results.yml index 6df6b8c3..bb4a39cb 100644 --- a/benchmarks/io_chunks/canbench_results.yml +++ b/benchmarks/io_chunks/canbench_results.yml @@ -2,21 +2,21 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 148723284 + instructions: 148723619 heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 203406339 + instructions: 509357411 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 12127804634 + instructions: 40809911847 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 357205451 + instructions: 357205416 heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4187201659 + instructions: 4187146289 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 83738699843 + instructions: 83682701103 heap_increase: 0 stable_memory_increase: 3072 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 07ae4f4a..424e92cb 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -84,28 +84,14 @@ const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; /// Default number of slots in the direct-mapped node cache. /// -/// The B-tree has a branching factor of ~11 (max entries per node), so each -/// tree level contains roughly 11× more nodes than the one above: +/// The cache is disabled by default (0 slots) to avoid unexpected heap +/// usage. Users can opt in via [`BTreeMap::with_cache_entries`] or +/// [`BTreeMap::set_cache_entries`]. /// -/// | Level | Nodes | Cumulative | -/// |-------|-------|------------| -/// | 0 (root) | 1 | 1 | -/// | 1 | ~11 | ~12 | -/// | 2 | ~121 | ~133 | -/// | 3 | ~1 331 | ~1 464 | -/// -/// With 32 slots the top 2 levels (≤12 nodes) stay cached with zero -/// collisions because nodes are allocated at sequential addresses that map -/// to distinct slots. Every lookup traverses root → one level-1 child, so -/// those 2 cache hits save 2 stable-memory reads per operation regardless -/// of total tree size. -/// -/// * 64 slots would add partial level-2 coverage but doubles heap cost for -/// diminishing returns. -/// * 16 slots risks collisions among the 12 top-level nodes. -/// -/// 32 is the smallest power of two that fits levels 0 + 1 comfortably. -const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 32; +/// A good starting point is **32 slots** — the smallest power of two that +/// fits the top 2 levels of the B-tree (root + its ~11 children) with no +/// collisions, giving 2 cache hits per operation regardless of tree size. +const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; /// A direct-mapped node cache modeled after CPU caches. /// @@ -127,6 +113,12 @@ struct NodeCache { pub struct CacheStats { pub hits: u64, pub misses: u64, + /// Heap memory reserved for cache slots: `num_slots × page_size` bytes. + /// + /// This is the allocated budget, not the number of slots currently + /// occupied. Use it to understand how much heap the cache consumes + /// without having to know the page size up-front. + pub size_bytes: u64, } impl CacheStats { @@ -203,6 +195,7 @@ impl NodeCache { CacheStats { hits: self.hits, misses: self.misses, + size_bytes: self.slots.len() as u64 * self.page_size as u64, } } } @@ -427,16 +420,9 @@ where /// The cache is a direct-mapped cache that keeps frequently accessed /// B-tree nodes in heap memory to avoid repeated stable-memory reads. /// The byte budget is converted to a number of cache slots by dividing - /// by the node page size and rounding to the nearest power of two. - /// - /// Pass `0` to disable the cache entirely. + /// by the node page size and rounding up to the nearest power of two. /// - /// # Default - /// - /// The default cache holds 32 slots. - /// This is the smallest power of two that fits the top 2 levels of the - /// B-tree (root + its ~11 children) with no collisions, giving 2 cache - /// hits per lookup regardless of tree size. + /// Pass `0` to disable the cache (the default). /// /// # Examples /// @@ -447,13 +433,38 @@ where /// let map: BTreeMap = /// BTreeMap::init(DefaultMemoryImpl::default()) /// .with_cache_size(10 * 1024 * 1024); - /// - /// // Disable the cache - /// let map: BTreeMap = - /// BTreeMap::init(DefaultMemoryImpl::default()) - /// .with_cache_size(0); /// ``` pub fn with_cache_size(mut self, bytes: u64) -> Self { + self.set_cache_size(bytes); + self + } + + /// Resizes the node cache at runtime. + /// + /// Unlike [`with_cache_size`](Self::with_cache_size), this method operates + /// on an already-initialised map, allowing the cache to be tuned in + /// response to observed [`cache_stats`](Self::cache_stats). + /// + /// The byte budget is converted to a number of cache slots by dividing by + /// the node page size and rounding up to the nearest power of two. + /// Existing cache contents and performance counters are discarded. + /// + /// Pass `0` to disable the cache entirely. + /// + /// # Examples + /// + /// ```rust + /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; + /// + /// let mut map: BTreeMap = BTreeMap::init(DefaultMemoryImpl::default()); + /// + /// // After observing poor hit ratio, double the cache. + /// let stats = map.cache_stats(); + /// if stats.hit_ratio() < 0.5 { + /// map.set_cache_size(stats.size_bytes * 2); + /// } + /// ``` + pub fn set_cache_size(&mut self, bytes: u64) { let page_size = self.version.page_size().get() as u64; let num_slots = if bytes == 0 { 0 @@ -462,13 +473,63 @@ where }; self.cache_num_slots = num_slots; *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); + } + + /// Configures the cache size by number of entries (nodes) rather than bytes. + /// + /// The count is rounded up to the nearest power of two. A direct-mapped + /// cache requires a power-of-two slot count so that the slot index can be + /// computed with a bitwise AND rather than integer division. + /// + /// Pass `0` to disable the cache entirely. + /// + /// # Examples + /// + /// ```rust + /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; + /// + /// // Cache for 64 nodes + /// let map: BTreeMap = + /// BTreeMap::init(DefaultMemoryImpl::default()) + /// .with_cache_entries(64); + /// ``` + pub fn with_cache_entries(mut self, entries: usize) -> Self { + self.set_cache_entries(entries); self } + /// Resizes the node cache at runtime by number of entries. + /// + /// Equivalent to [`set_cache_size`](Self::set_cache_size) but accepts an + /// entry count rather than bytes. The count is rounded up to the nearest + /// power of two. Existing cache contents and performance counters are + /// discarded. + /// + /// Pass `0` to disable the cache entirely. + /// + /// # Examples + /// + /// ```rust + /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; + /// + /// let mut map: BTreeMap = BTreeMap::init(DefaultMemoryImpl::default()); + /// map.set_cache_entries(128); + /// ``` + pub fn set_cache_entries(&mut self, entries: usize) { + let num_slots = if entries == 0 { + 0 + } else { + entries.next_power_of_two() + }; + self.cache_num_slots = num_slots; + *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); + } + /// Returns cache performance counters. /// /// Use these to monitor cache effectiveness and tune the cache size - /// via [`with_cache_size`](Self::with_cache_size). + /// via [`set_cache_size`](Self::set_cache_size) or + /// [`set_cache_entries`](Self::set_cache_entries). /// /// # Examples /// @@ -3633,4 +3694,84 @@ mod test { assert_eq!(btree.allocator.num_allocated_chunks(), 0); } + + #[test] + fn cache_stats_size_bytes() { + let mem = make_memory(); + let map: BTreeMap = BTreeMap::new(mem); + let stats = map.cache_stats(); + let page_size = map.version.page_size().get() as u64; + assert_eq!( + stats.size_bytes, + DEFAULT_NODE_CACHE_NUM_SLOTS as u64 * page_size + ); + } + + #[test] + fn set_cache_size_resizes_at_runtime() { + let mem = make_memory(); + let mut map: BTreeMap = BTreeMap::new(mem).with_cache_entries(32); + let page_size = map.version.page_size().get() as u64; + + for i in 0..100u64 { + map.insert(i, i); + } + for i in 0..100u64 { + let _ = map.get(&i); + } + let before = map.cache_stats(); + assert!(before.hits > 0, "expected cache hits before resize"); + + // Resize to 64 slots – counters and entries are discarded. + map.set_cache_size(page_size * 64); + + let after = map.cache_stats(); + assert_eq!(after.hits, 0, "resize should reset counters"); + assert_eq!(after.misses, 0, "resize should reset counters"); + assert_eq!(after.size_bytes, page_size * 64); + + // Map must still be correct after resize. + for i in 0..100u64 { + assert_eq!(map.get(&i), Some(i)); + } + } + + #[test] + fn set_cache_size_disable_then_reenable() { + let mem = make_memory(); + let mut map: BTreeMap = BTreeMap::new(mem); + map.insert(42, 99); + + map.set_cache_size(0); + assert_eq!(map.cache_stats().size_bytes, 0); + assert_eq!(map.get(&42), Some(99)); + + // Re-enable cache. + let page_size = map.version.page_size().get() as u64; + map.set_cache_size(page_size * 32); + assert_eq!(map.cache_stats().size_bytes, page_size * 32); + assert_eq!(map.get(&42), Some(99)); + } + + #[test] + fn with_cache_entries_rounds_to_power_of_two() { + let mem = make_memory(); + // Request 50 entries → should round up to 64. + let map: BTreeMap = BTreeMap::new(mem).with_cache_entries(50); + let page_size = map.version.page_size().get() as u64; + assert_eq!(map.cache_stats().size_bytes, page_size * 64); + } + + #[test] + fn set_cache_entries_resizes_at_runtime() { + let mem = make_memory(); + let mut map: BTreeMap = BTreeMap::new(mem); + let page_size = map.version.page_size().get() as u64; + + map.set_cache_entries(100); // rounds to 128 + assert_eq!(map.cache_stats().size_bytes, page_size * 128); + + map.set_cache_entries(0); // disable + assert_eq!(map.cache_stats().size_bytes, 0); + } } From a4f64b451c3c9fb9ca726983eed53acc02d0e14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 27 Mar 2026 11:54:58 +0100 Subject: [PATCH 07/42] Address reviews --- benchmarks/btreemap/src/main.rs | 8 +- src/btreemap.rs | 235 +++++++++++++------------------- src/lib.rs | 2 +- 3 files changed, 103 insertions(+), 142 deletions(-) diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 9b0e3d28..9efabbca 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -822,22 +822,22 @@ fn range_count_helper_v2(count: usize, size: usize) -> BenchResult { // compared against the default (cache disabled) results above. fn insert_helper_v2_cached_32entry() -> BenchResult { - let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32); insert_helper::(btree) } fn get_helper_v2_cached_32entry() -> BenchResult { - let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32); get_helper::(btree) } fn remove_helper_v2_cached_32entry() -> BenchResult { - let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32); remove_helper::(btree) } fn contains_helper_v2_cached_32entry() -> BenchResult { - let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_cache_entries(32); + let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32); contains_helper::(btree) } diff --git a/src/btreemap.rs b/src/btreemap.rs index 424e92cb..20dc9fcf 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -85,19 +85,16 @@ const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; /// Default number of slots in the direct-mapped node cache. /// /// The cache is disabled by default (0 slots) to avoid unexpected heap -/// usage. Users can opt in via [`BTreeMap::with_cache_entries`] or -/// [`BTreeMap::set_cache_entries`]. +/// usage. Users can opt in via [`BTreeMap::with_node_cache`] or +/// [`BTreeMap::node_cache_resize`]. /// -/// A good starting point is **32 slots** — the smallest power of two that -/// fits the top 2 levels of the B-tree (root + its ~11 children) with no -/// collisions, giving 2 cache hits per operation regardless of tree size. +/// See [`BTreeMap::with_node_cache`] for guidance on choosing a size. const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; -/// A direct-mapped node cache modeled after CPU caches. +/// A direct-mapped node cache. /// -/// Each slot is indexed by `(node_address / page_size) % num_slots`. Lookup -/// is O(1) with ~5 instructions overhead. Collision = eviction (no LRU -/// tracking needed). +/// Each slot is indexed by `(node_address / page_size) % num_slots`. +/// Collision = eviction (no LRU tracking needed). /// /// Upper tree levels (root, depth-1) naturally stay cached because their /// addresses are stable and map to distinct slots. @@ -108,20 +105,14 @@ struct NodeCache { misses: u64, } -/// Cache performance counters. +/// Node-cache performance counters. #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CacheStats { +pub struct NodeCacheStats { pub hits: u64, pub misses: u64, - /// Heap memory reserved for cache slots: `num_slots × page_size` bytes. - /// - /// This is the allocated budget, not the number of slots currently - /// occupied. Use it to understand how much heap the cache consumes - /// without having to know the page size up-front. - pub size_bytes: u64, } -impl CacheStats { +impl NodeCacheStats { /// Returns the hit ratio as a value between 0.0 and 1.0. /// Returns 0.0 if no lookups have been performed. pub fn hit_ratio(&self) -> f64 { @@ -191,13 +182,20 @@ impl NodeCache { } } - fn stats(&self) -> CacheStats { - CacheStats { + fn stats(&self) -> NodeCacheStats { + NodeCacheStats { hits: self.hits, misses: self.misses, - size_bytes: self.slots.len() as u64 * self.page_size as u64, } } + + fn clear(&mut self) { + for slot in &mut self.slots { + *slot = (NULL, None); + } + self.hits = 0; + self.misses = 0; + } } /// A B-Tree map implementation that stores its data into a designated memory. @@ -415,121 +413,75 @@ where } } - /// Configures the size of the node cache in bytes. + /// Configures the number of node-cache slots during construction. /// /// The cache is a direct-mapped cache that keeps frequently accessed /// B-tree nodes in heap memory to avoid repeated stable-memory reads. - /// The byte budget is converted to a number of cache slots by dividing - /// by the node page size and rounding up to the nearest power of two. + /// Each slot can hold one deserialized node; collisions evict the + /// previous occupant. /// /// Pass `0` to disable the cache (the default). /// + /// A good starting point is **32** — the smallest value that fits the + /// top 2 levels of the B-tree (root + its ~11 children) with no + /// collisions, giving 2 cache hits per operation regardless of tree + /// size. + /// + /// # Note on cache size + /// + /// Any value is accepted, but future cache implementations (e.g. + /// set-associative) may require power-of-two sizes for efficient + /// indexing. Prefer powers of two for forward compatibility. + /// /// # Examples /// /// ```rust /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; /// - /// // 10 MB cache /// let map: BTreeMap = /// BTreeMap::init(DefaultMemoryImpl::default()) - /// .with_cache_size(10 * 1024 * 1024); + /// .with_node_cache(32); /// ``` - pub fn with_cache_size(mut self, bytes: u64) -> Self { - self.set_cache_size(bytes); + pub fn with_node_cache(mut self, num_slots: usize) -> Self { + self.node_cache_resize(num_slots); self } /// Resizes the node cache at runtime. /// - /// Unlike [`with_cache_size`](Self::with_cache_size), this method operates - /// on an already-initialised map, allowing the cache to be tuned in - /// response to observed [`cache_stats`](Self::cache_stats). - /// - /// The byte budget is converted to a number of cache slots by dividing by - /// the node page size and rounding up to the nearest power of two. /// Existing cache contents and performance counters are discarded. /// /// Pass `0` to disable the cache entirely. /// + /// See [`with_node_cache`](Self::with_node_cache) for guidance on + /// choosing a size. + /// /// # Examples /// /// ```rust /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; /// - /// let mut map: BTreeMap = BTreeMap::init(DefaultMemoryImpl::default()); + /// let mut map: BTreeMap = + /// BTreeMap::init(DefaultMemoryImpl::default()) + /// .with_node_cache(32); /// - /// // After observing poor hit ratio, double the cache. - /// let stats = map.cache_stats(); - /// if stats.hit_ratio() < 0.5 { - /// map.set_cache_size(stats.size_bytes * 2); + /// // After observing a poor hit ratio, grow the cache. + /// if map.node_cache_stats().hit_ratio() < 0.5 { + /// map.node_cache_resize(64); /// } /// ``` - pub fn set_cache_size(&mut self, bytes: u64) { - let page_size = self.version.page_size().get() as u64; - let num_slots = if bytes == 0 { - 0 - } else { - (bytes / page_size).max(1).next_power_of_two() as usize - }; + pub fn node_cache_resize(&mut self, num_slots: usize) { self.cache_num_slots = num_slots; *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); } - /// Configures the cache size by number of entries (nodes) rather than bytes. - /// - /// The count is rounded up to the nearest power of two. A direct-mapped - /// cache requires a power-of-two slot count so that the slot index can be - /// computed with a bitwise AND rather than integer division. - /// - /// Pass `0` to disable the cache entirely. - /// - /// # Examples - /// - /// ```rust - /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; - /// - /// // Cache for 64 nodes - /// let map: BTreeMap = - /// BTreeMap::init(DefaultMemoryImpl::default()) - /// .with_cache_entries(64); - /// ``` - pub fn with_cache_entries(mut self, entries: usize) -> Self { - self.set_cache_entries(entries); - self + /// Evicts all cached nodes and resets hit/miss counters, keeping the + /// current cache capacity. + pub fn node_cache_clear(&mut self) { + self.cache.get_mut().clear(); } - /// Resizes the node cache at runtime by number of entries. - /// - /// Equivalent to [`set_cache_size`](Self::set_cache_size) but accepts an - /// entry count rather than bytes. The count is rounded up to the nearest - /// power of two. Existing cache contents and performance counters are - /// discarded. - /// - /// Pass `0` to disable the cache entirely. - /// - /// # Examples - /// - /// ```rust - /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; - /// - /// let mut map: BTreeMap = BTreeMap::init(DefaultMemoryImpl::default()); - /// map.set_cache_entries(128); - /// ``` - pub fn set_cache_entries(&mut self, entries: usize) { - let num_slots = if entries == 0 { - 0 - } else { - entries.next_power_of_two() - }; - self.cache_num_slots = num_slots; - *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); - } - - /// Returns cache performance counters. - /// - /// Use these to monitor cache effectiveness and tune the cache size - /// via [`set_cache_size`](Self::set_cache_size) or - /// [`set_cache_entries`](Self::set_cache_entries). + /// Returns node-cache performance counters. /// /// # Examples /// @@ -537,14 +489,15 @@ where /// use ic_stable_structures::{BTreeMap, DefaultMemoryImpl}; /// /// let mut map: BTreeMap = - /// BTreeMap::init(DefaultMemoryImpl::default()); + /// BTreeMap::init(DefaultMemoryImpl::default()) + /// .with_node_cache(32); /// map.insert(1, 100); /// let _ = map.get(&1); /// - /// let stats = map.cache_stats(); + /// let stats = map.node_cache_stats(); /// println!("hit ratio: {:.1}%", stats.hit_ratio() * 100.0); /// ``` - pub fn cache_stats(&self) -> CacheStats { + pub fn node_cache_stats(&self) -> NodeCacheStats { self.cache.borrow().stats() } @@ -3696,22 +3649,19 @@ mod test { } #[test] - fn cache_stats_size_bytes() { + fn node_cache_stats_default() { let mem = make_memory(); let map: BTreeMap = BTreeMap::new(mem); - let stats = map.cache_stats(); - let page_size = map.version.page_size().get() as u64; - assert_eq!( - stats.size_bytes, - DEFAULT_NODE_CACHE_NUM_SLOTS as u64 * page_size - ); + let stats = map.node_cache_stats(); + assert_eq!(stats.hits, 0); + assert_eq!(stats.misses, 0); } #[test] - fn set_cache_size_resizes_at_runtime() { + fn node_cache_resize_at_runtime() { let mem = make_memory(); - let mut map: BTreeMap = BTreeMap::new(mem).with_cache_entries(32); - let page_size = map.version.page_size().get() as u64; + let mut map: BTreeMap = + BTreeMap::new(mem).with_node_cache(32); for i in 0..100u64 { map.insert(i, i); @@ -3719,59 +3669,70 @@ mod test { for i in 0..100u64 { let _ = map.get(&i); } - let before = map.cache_stats(); + let before = map.node_cache_stats(); assert!(before.hits > 0, "expected cache hits before resize"); - // Resize to 64 slots – counters and entries are discarded. - map.set_cache_size(page_size * 64); + map.node_cache_resize(64); - let after = map.cache_stats(); + let after = map.node_cache_stats(); assert_eq!(after.hits, 0, "resize should reset counters"); assert_eq!(after.misses, 0, "resize should reset counters"); - assert_eq!(after.size_bytes, page_size * 64); - // Map must still be correct after resize. for i in 0..100u64 { assert_eq!(map.get(&i), Some(i)); } } #[test] - fn set_cache_size_disable_then_reenable() { + fn node_cache_disable_and_reenable() { let mem = make_memory(); let mut map: BTreeMap = BTreeMap::new(mem); map.insert(42, 99); - map.set_cache_size(0); - assert_eq!(map.cache_stats().size_bytes, 0); + map.node_cache_resize(0); assert_eq!(map.get(&42), Some(99)); - // Re-enable cache. - let page_size = map.version.page_size().get() as u64; - map.set_cache_size(page_size * 32); - assert_eq!(map.cache_stats().size_bytes, page_size * 32); + map.node_cache_resize(32); assert_eq!(map.get(&42), Some(99)); } #[test] - fn with_cache_entries_rounds_to_power_of_two() { + fn node_cache_non_power_of_two() { let mem = make_memory(); - // Request 50 entries → should round up to 64. - let map: BTreeMap = BTreeMap::new(mem).with_cache_entries(50); - let page_size = map.version.page_size().get() as u64; - assert_eq!(map.cache_stats().size_bytes, page_size * 64); + let mut map: BTreeMap = + BTreeMap::new(mem).with_node_cache(50); + + for i in 0..100u64 { + map.insert(i, i); + } + let _ = map.get(&50); + let _ = map.get(&50); + assert!(map.node_cache_stats().hits > 0); } #[test] - fn set_cache_entries_resizes_at_runtime() { + fn node_cache_clear_resets_counters() { let mem = make_memory(); - let mut map: BTreeMap = BTreeMap::new(mem); - let page_size = map.version.page_size().get() as u64; + let mut map: BTreeMap = + BTreeMap::new(mem).with_node_cache(32); - map.set_cache_entries(100); // rounds to 128 - assert_eq!(map.cache_stats().size_bytes, page_size * 128); + for i in 0..50u64 { + map.insert(i, i); + } + for i in 0..50u64 { + let _ = map.get(&i); + } + let before = map.node_cache_stats(); + assert!(before.hits + before.misses > 0); + + map.node_cache_clear(); - map.set_cache_entries(0); // disable - assert_eq!(map.cache_stats().size_bytes, 0); + let after = map.node_cache_stats(); + assert_eq!(after.hits, 0); + assert_eq!(after.misses, 0); + + for i in 0..50u64 { + assert_eq!(map.get(&i), Some(i)); + } } } diff --git a/src/lib.rs b/src/lib.rs index 25074e0a..e51f2072 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ pub mod vec; pub mod vec_mem; pub mod writer; -pub use btreemap::{BTreeMap, BTreeMap as StableBTreeMap, CacheStats}; +pub use btreemap::{BTreeMap, BTreeMap as StableBTreeMap, NodeCacheStats}; pub use btreeset::{BTreeSet, BTreeSet as StableBTreeSet}; pub use file_mem::FileMemory; #[cfg(target_arch = "wasm32")] From 3313af070eb840c2e0327097e3af5aabfb7f5c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 27 Mar 2026 14:25:00 +0100 Subject: [PATCH 08/42] optimize disabled cache case --- benchmarks/btreemap/canbench_results.yml | 576 +++++++++++----------- benchmarks/btreeset/canbench_results.yml | 40 +- benchmarks/io_chunks/canbench_results.yml | 12 +- src/btreemap.rs | 45 +- 4 files changed, 339 insertions(+), 334 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 9ac141c0..93ec44db 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,1694 +2,1694 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142229570 + instructions: 142223444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 300167392 + instructions: 292251248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 4286397285 + instructions: 4278657425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 828790249 + instructions: 821052288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 301080947 + instructions: 293333653 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1318518633 + instructions: 1310779571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 335083916 + instructions: 327147005 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 332585344 + instructions: 324648699 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 332576427 + instructions: 324637021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 245878499 + instructions: 245659274 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 325435860 + instructions: 317500664 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 330793474 + instructions: 322854230 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 335022835 + instructions: 327087164 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 328835359 + instructions: 320899527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 328788296 + instructions: 320852457 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 331384312 + instructions: 323449943 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 330764242 + instructions: 322825815 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 250950007 + instructions: 244885342 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 2290387899 + instructions: 2282455141 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 408981840 + instructions: 401240082 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 273650788 + instructions: 265723252 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 355737299 + instructions: 346737080 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 226482899 + instructions: 218655247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 229607502 + instructions: 221776623 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 162978425 + instructions: 162855054 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 226482899 + instructions: 218655247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 381755139 + instructions: 373755909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1860576961 + instructions: 1851466971 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 568870538 + instructions: 559772809 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 441474534 + instructions: 432384968 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 900622956 + instructions: 891524104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 365610144 + instructions: 357596127 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 493941216 + instructions: 485955886 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 421455526 + instructions: 413454913 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 290697001 + instructions: 290399668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 373320046 + instructions: 365307336 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 439607589 + instructions: 431609647 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 362903003 + instructions: 354890140 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 375619686 + instructions: 367606496 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 458608779 + instructions: 450614263 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 409735939 + instructions: 401728737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 376062932 + instructions: 368047115 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 404701150 + instructions: 397489879 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1235984162 + instructions: 1227992746 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 503153094 + instructions: 494053293 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 399063664 + instructions: 391070102 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388604627 + instructions: 388598599 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 304726975 + instructions: 296801695 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 4291440795 + instructions: 4283690935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 833840112 + instructions: 826092151 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 306048666 + instructions: 298291372 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 1323549944 + instructions: 1315800882 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 336793946 + instructions: 328847079 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 343218346 + instructions: 335271701 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 337516150 + instructions: 329566744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 250557772 + instructions: 250318547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 329686154 + instructions: 321740958 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 336390450 + instructions: 328441206 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 339421666 + instructions: 331475995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 332566900 + instructions: 324621068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 336384847 + instructions: 328439008 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 335954966 + instructions: 328010597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 334806316 + instructions: 326857889 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 256050245 + instructions: 249975580 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 2295436807 + instructions: 2287494049 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 414041110 + instructions: 406289352 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 278781207 + instructions: 270843671 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 357598026 + instructions: 348608271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 230605141 + instructions: 222816150 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 234129779 + instructions: 226338411 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 167602451 + instructions: 167507739 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 230909165 + instructions: 223120174 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 386523249 + instructions: 378534019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1871057563 + instructions: 1861977573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 576645044 + instructions: 567577313 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 447782546 + instructions: 438717716 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 908544922 + instructions: 899476068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 367448830 + instructions: 359444813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 517190987 + instructions: 509235657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 427990005 + instructions: 420014588 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 297195939 + instructions: 296898606 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 377969171 + instructions: 369966461 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 452603736 + instructions: 444635792 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 367711808 + instructions: 359708945 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 380149092 + instructions: 372145902 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 475468755 + instructions: 467504237 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 414911394 + instructions: 406919388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 380632402 + instructions: 372626585 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 410752111 + instructions: 403559390 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1243811689 + instructions: 1235850271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 510129615 + instructions: 501058182 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 405215725 + instructions: 397241661 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4387226708 + instructions: 4387226377 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 436709225 + instructions: 436622114 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496293245 + instructions: 5496163594 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1180911684 + instructions: 1180782137 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486322476 + instructions: 486213167 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1789108884 + instructions: 1788979849 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 490533629 + instructions: 490411198 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 703571159 + instructions: 703450500 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 542638910 + instructions: 542518807 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_128_cached_32entry: total: calls: 1 - instructions: 543217544 + instructions: 543345427 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519188260 + instructions: 519066567 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 570762598 + instructions: 570640531 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 529023348 + instructions: 528902035 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509451702 + instructions: 509330487 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610134685 + instructions: 610013432 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 534992272 + instructions: 534872275 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 517665219 + instructions: 517544774 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407355164 + instructions: 407316857 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041295219 + instructions: 3041165188 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661249041 + instructions: 661124294 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 458692022 + instructions: 458606393 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 503377605 + instructions: 501982945 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 406794043 + instructions: 406695881 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 414627878 + instructions: 414530721 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 415216844 + instructions: 415372101 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410422360 + instructions: 410324198 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 592889950 + instructions: 592820136 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2744588956 + instructions: 2743145193 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1012703027 + instructions: 1011265889 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 709060566 + instructions: 707653590 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1402257128 + instructions: 1400814198 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 620606035 + instructions: 620501569 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1180806288 + instructions: 1180703560 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 754841043 + instructions: 754738693 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 755419677 + instructions: 755565313 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 664935313 + instructions: 664831919 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 867954938 + instructions: 867850710 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 660394990 + instructions: 660291790 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 659099490 + instructions: 658996206 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 972374030 + instructions: 972270626 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 690378034 + instructions: 690276014 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 658596666 + instructions: 658493986 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604437139 + instructions: 603190644 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1857853966 + instructions: 1857741950 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846371292 + instructions: 844932768 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 665066425 + instructions: 664998503 heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 2358760299 + instructions: 2350826568 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 285805346 + instructions: 277975211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 289714366 + instructions: 281883487 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 368616168 + instructions: 360784676 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1267371016 + instructions: 1259378621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 2365920667 + instructions: 2357976936 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 294270839 + instructions: 286479343 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 295027558 + instructions: 287236190 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 383090319 + instructions: 375337462 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1275457142 + instructions: 1267494745 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3127942006 + instructions: 3127812849 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: calls: 1 - instructions: 607527955 + instructions: 607431275 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 520787649 + instructions: 520690492 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 834455991 + instructions: 834359311 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1963448345 + instructions: 1963337173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4310758963 + instructions: 4310335711 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 883593492 + instructions: 883184506 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 737401273 + instructions: 736990551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1224605909 + instructions: 1224139935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3084275696 + instructions: 3083817917 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 599444870 + instructions: 599151004 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8387866497 + instructions: 8387504673 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1824981182 + instructions: 1824625842 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 743301756 + instructions: 742979122 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2764167882 + instructions: 2763809068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 751729105 + instructions: 751383937 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1121712594 + instructions: 1121367598 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 860518357 + instructions: 860170573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 795323065 + instructions: 794980491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 891973131 + instructions: 891627329 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 808788096 + instructions: 808446434 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 779096766 + instructions: 778752478 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 957804106 + instructions: 957459834 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 817635848 + instructions: 817293552 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 797013498 + instructions: 796665272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 371556043 + instructions: 371391381 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4613959936 + instructions: 4613600846 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1031950490 + instructions: 1031597072 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 605165233 + instructions: 604888373 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 800436737 + instructions: 799174569 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 669514103 + instructions: 669158779 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 681505055 + instructions: 681143117 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 672067271 + instructions: 671716845 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 782339951 + instructions: 782070215 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4049411251 + instructions: 4048053559 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1503451079 + instructions: 1502104847 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1024989939 + instructions: 1023809551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2020084943 + instructions: 2018716834 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 862284896 + instructions: 861954194 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1689068528 + instructions: 1688676486 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1088187240 + instructions: 1087802472 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 927596586 + instructions: 927266035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1214784693 + instructions: 1214401260 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 930357336 + instructions: 930028204 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 914087279 + instructions: 913757288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1372555472 + instructions: 1372171196 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 972064704 + instructions: 971718315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 924303586 + instructions: 923969225 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 541115642 + instructions: 540470482 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2715582172 + instructions: 2715180077 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1234767342 + instructions: 1233441916 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 850211681 + instructions: 849923373 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 575908780 + instructions: 575613656 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8055518981 + instructions: 8055154467 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1755774253 + instructions: 1755416087 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 716784102 + instructions: 716459124 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2669998617 + instructions: 2669637023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 723573793 + instructions: 723225579 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1085692619 + instructions: 1085345039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 826145903 + instructions: 825795569 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 767140365 + instructions: 766795291 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 861123382 + instructions: 860774944 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 776173867 + instructions: 775829677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 755364541 + instructions: 755017437 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 932562547 + instructions: 932215641 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 791784273 + instructions: 791439355 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 768406742 + instructions: 768055658 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 358071231 + instructions: 357905025 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4444837489 + instructions: 4444475877 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 1000005266 + instructions: 999649204 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 599183465 + instructions: 598904829 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 780512483 + instructions: 779236650 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 646177878 + instructions: 645819930 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 657824058 + instructions: 657459834 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 648634600 + instructions: 648281584 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 759030848 + instructions: 758760021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4254971827 + instructions: 4253598932 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1509892495 + instructions: 1508544711 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1006353968 + instructions: 1005176745 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2073569697 + instructions: 2072209623 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 845443577 + instructions: 845108496 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1663693008 + instructions: 1663299384 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1063942986 + instructions: 1063556514 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 902319398 + instructions: 901987630 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1192783015 + instructions: 1192398310 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 909833763 + instructions: 909502456 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 898328913 + instructions: 897995224 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1356209155 + instructions: 1355822245 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 949121024 + instructions: 948772298 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 901822710 + instructions: 901485684 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 527201582 + instructions: 526558721 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2807429728 + instructions: 2807025323 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1221046203 + instructions: 1219724906 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 850087795 + instructions: 849795327 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1759,322 +1759,322 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4709566185 + instructions: 4709565637 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 584961228 + instructions: 584603012 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7364162621 + instructions: 7363742441 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1589112722 + instructions: 1588698430 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665656233 + instructions: 665261563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2422055032 + instructions: 2421641307 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 654579216 + instructions: 654172400 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 985648444 + instructions: 985247212 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 746930902 + instructions: 746530989 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 748108750 + instructions: 748213616 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 700379720 + instructions: 699981236 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784447437 + instructions: 784047597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 712242366 + instructions: 711840362 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696545085 + instructions: 696137589 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 858265527 + instructions: 857858171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 737412253 + instructions: 736997963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 696375353 + instructions: 695978163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 453069395 + instructions: 452862617 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4071869567 + instructions: 4071448837 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 910390114 + instructions: 909991932 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599629254 + instructions: 599278644 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 684480216 + instructions: 683098045 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566517736 + instructions: 566115465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 587161715 + instructions: 586750993 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 588373961 + instructions: 588482760 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 571785395 + instructions: 571385552 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 755155844 + instructions: 754807192 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4476158704 + instructions: 4474696476 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1418524112 + instructions: 1417086039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 921411284 + instructions: 920022911 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2244929518 + instructions: 2243497655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 833674437 + instructions: 833289651 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1700784231 + instructions: 1700339959 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1036266814 + instructions: 1035835907 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1037435170 + instructions: 1037504974 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 870649277 + instructions: 870269660 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1239481192 + instructions: 1239040715 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 866890672 + instructions: 866506222 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 861481287 + instructions: 861093062 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1405227943 + instructions: 1404785875 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 967639488 + instructions: 967234637 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 855796413 + instructions: 855413255 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 662260967 + instructions: 661105186 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3081991962 + instructions: 3081535655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1184235903 + instructions: 1182814609 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 821067705 + instructions: 820703465 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index e7967ac3..04feea00 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: 7266173964 + instructions: 7266034104 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1637048994 + instructions: 1636909134 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 715945918 + instructions: 715806058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2445506713 + instructions: 2445366853 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 815000302 + instructions: 814860442 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4050121028 + instructions: 4049981168 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 980750853 + instructions: 980610993 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 694324953 + instructions: 694185093 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 540446455 + instructions: 540306595 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 561779534 + instructions: 561639674 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,70 +492,70 @@ benches: btreeset_remove_blob_1024: total: calls: 1 - instructions: 7723051396 + instructions: 7722770224 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1666717704 + instructions: 1666436532 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 705766178 + instructions: 705482522 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2534428956 + instructions: 2534147784 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 802397113 + instructions: 802119271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4261765171 + instructions: 4261483999 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 987430982 + instructions: 987153140 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 683883623 + instructions: 683603297 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 528437094 + instructions: 528185054 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 553342799 + instructions: 553090759 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/io_chunks/canbench_results.yml b/benchmarks/io_chunks/canbench_results.yml index bb4a39cb..335016b8 100644 --- a/benchmarks/io_chunks/canbench_results.yml +++ b/benchmarks/io_chunks/canbench_results.yml @@ -2,21 +2,21 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 148723619 + instructions: 148723478 heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 509357411 + instructions: 508817794 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 40809911847 + instructions: 39710943416 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 357205416 + instructions: 357205402 heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4187146289 + instructions: 4187131611 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 83682701103 + instructions: 83679286075 heap_increase: 0 stable_memory_increase: 3072 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 20dc9fcf..d6b33cce 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -149,10 +149,7 @@ impl NodeCache { } fn take(&mut self, addr: Address) -> Option> { - if !self.is_enabled() { - self.misses += 1; - return None; - } + debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); if self.slots[idx].0 == addr { self.slots[idx].0 = NULL; @@ -165,17 +162,13 @@ impl NodeCache { } fn put(&mut self, addr: Address, node: Node) { - if !self.is_enabled() { - return; - } + debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); self.slots[idx] = (addr, Some(node)); } fn invalidate(&mut self, addr: Address) { - if !self.is_enabled() { - return; - } + debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); if self.slots[idx].0 == addr { self.slots[idx] = (NULL, None); @@ -1519,11 +1512,13 @@ where fn merge(&mut self, source: Node, mut into: Node, median: Entry) -> Node { let source_addr = source.address(); into.merge(source, median, &mut self.allocator); - // Node::merge saves `into` and deallocates `source` directly through - // the allocator, so we must invalidate both cache slots here. - let cache = self.cache.get_mut(); - cache.invalidate(into.address()); - cache.invalidate(source_addr); + if self.cache_num_slots > 0 { + // Node::merge saves `into` and deallocates `source` directly through + // the allocator, so we must invalidate both cache slots here. + let cache = self.cache.get_mut(); + cache.invalidate(into.address()); + cache.invalidate(source_addr); + } into } @@ -1540,23 +1535,31 @@ where fn deallocate_node(&mut self, node: Node) { let addr = node.address(); node.deallocate(self.allocator_mut()); - self.cache.get_mut().invalidate(addr); + if self.cache_num_slots > 0 { + self.cache.get_mut().invalidate(addr); + } } /// Takes a node from the cache, or loads it from memory if not cached. /// /// Used by read paths (`&self`). The caller must call `return_node` when /// done to put the node back into the cache. + #[inline(always)] fn take_or_load_node(&self, address: Address) -> Node { - if let Some(node) = self.cache.borrow_mut().take(address) { - return node; + if self.cache_num_slots > 0 { + if let Some(node) = self.cache.borrow_mut().take(address) { + return node; + } } Node::load(address, self.version.page_size(), self.memory()) } /// Returns a node to the cache after use on a read path. + #[inline(always)] fn return_node(&self, node: Node) { - self.cache.borrow_mut().put(node.address(), node); + if self.cache_num_slots > 0 { + self.cache.borrow_mut().put(node.address(), node); + } } /// Loads a node from memory, bypassing the cache. @@ -1569,7 +1572,9 @@ where #[inline] fn save_node(&mut self, node: &mut Node) { node.save(self.allocator_mut()); - self.cache.get_mut().invalidate(node.address()); + if self.cache_num_slots > 0 { + self.cache.get_mut().invalidate(node.address()); + } } /// Replaces the value at `idx` in the node, saves the node, and returns the old value. From 1100a19eef75b809da1c4e12303c90fdd9ab9612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 27 Mar 2026 14:37:53 +0100 Subject: [PATCH 09/42] rename and extend cache metrics --- src/btreemap.rs | 178 ++++++++++++++++++++++++++++++++---------------- src/lib.rs | 2 +- 2 files changed, 122 insertions(+), 58 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index d6b33cce..d2385981 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -91,38 +91,67 @@ const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; /// See [`BTreeMap::with_node_cache`] for guidance on choosing a size. const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; -/// A direct-mapped node cache. -/// -/// Each slot is indexed by `(node_address / page_size) % num_slots`. -/// Collision = eviction (no LRU tracking needed). -/// -/// Upper tree levels (root, depth-1) naturally stay cached because their -/// addresses are stable and map to distinct slots. -struct NodeCache { - slots: Vec<(Address, Option>)>, - page_size: u32, +/// Node-cache performance metrics. +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub struct NodeCacheMetrics { hits: u64, misses: u64, } -/// Node-cache performance counters. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct NodeCacheStats { - pub hits: u64, - pub misses: u64, -} +impl NodeCacheMetrics { + pub fn new() -> Self { + Self::default() + } + + /// Resets all counters to zero. + pub fn clear(&mut self) { + self.hits = 0; + self.misses = 0; + } + + pub fn hits(&self) -> u64 { + self.hits + } + + pub fn misses(&self) -> u64 { + self.misses + } + + pub fn total(&self) -> u64 { + self.hits + self.misses + } -impl NodeCacheStats { /// Returns the hit ratio as a value between 0.0 and 1.0. /// Returns 0.0 if no lookups have been performed. pub fn hit_ratio(&self) -> f64 { - let total = self.hits + self.misses; + let total = self.total(); if total == 0 { 0.0 } else { self.hits as f64 / total as f64 } } + + pub(crate) fn observe_hit(&mut self) { + self.hits += 1; + } + + pub(crate) fn observe_miss(&mut self) { + self.misses += 1; + } +} + +/// A direct-mapped node cache. +/// +/// Each slot is indexed by `(node_address / page_size) % num_slots`. +/// Collision = eviction (no LRU tracking needed). +/// +/// Upper tree levels (root, depth-1) naturally stay cached because their +/// addresses are stable and map to distinct slots. +struct NodeCache { + slots: Vec<(Address, Option>)>, + page_size: u32, + metrics: NodeCacheMetrics, } impl NodeCache { @@ -134,8 +163,7 @@ impl NodeCache { Self { slots, page_size, - hits: 0, - misses: 0, + metrics: NodeCacheMetrics::new(), } } @@ -153,10 +181,10 @@ impl NodeCache { let idx = self.slot_index(addr); if self.slots[idx].0 == addr { self.slots[idx].0 = NULL; - self.hits += 1; + self.metrics.observe_hit(); self.slots[idx].1.take() } else { - self.misses += 1; + self.metrics.observe_miss(); None } } @@ -175,19 +203,19 @@ impl NodeCache { } } - fn stats(&self) -> NodeCacheStats { - NodeCacheStats { - hits: self.hits, - misses: self.misses, - } + fn metrics(&self) -> NodeCacheMetrics { + self.metrics + } + + fn clear_metrics(&mut self) { + self.metrics.clear(); } fn clear(&mut self) { for slot in &mut self.slots { *slot = (NULL, None); } - self.hits = 0; - self.misses = 0; + self.metrics.clear(); } } @@ -459,7 +487,7 @@ where /// .with_node_cache(32); /// /// // After observing a poor hit ratio, grow the cache. - /// if map.node_cache_stats().hit_ratio() < 0.5 { + /// if map.node_cache_metrics().hit_ratio() < 0.5 { /// map.node_cache_resize(64); /// } /// ``` @@ -468,13 +496,19 @@ where *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); } - /// Evicts all cached nodes and resets hit/miss counters, keeping the + /// Evicts all cached nodes and resets metrics, keeping the /// current cache capacity. pub fn node_cache_clear(&mut self) { self.cache.get_mut().clear(); } - /// Returns node-cache performance counters. + /// Resets cache metrics (hit/miss counters) without evicting + /// cached nodes. + pub fn node_cache_clear_metrics(&mut self) { + self.cache.get_mut().clear_metrics(); + } + + /// Returns node-cache performance metrics. /// /// # Examples /// @@ -487,11 +521,11 @@ where /// map.insert(1, 100); /// let _ = map.get(&1); /// - /// let stats = map.node_cache_stats(); - /// println!("hit ratio: {:.1}%", stats.hit_ratio() * 100.0); + /// let metrics = map.node_cache_metrics(); + /// println!("hit ratio: {:.1}%", metrics.hit_ratio() * 100.0); /// ``` - pub fn node_cache_stats(&self) -> NodeCacheStats { - self.cache.borrow().stats() + pub fn node_cache_metrics(&self) -> NodeCacheMetrics { + self.cache.borrow().metrics() } /// Initializes a v1 `BTreeMap`. @@ -3654,19 +3688,18 @@ mod test { } #[test] - fn node_cache_stats_default() { + fn node_cache_metrics_default() { let mem = make_memory(); let map: BTreeMap = BTreeMap::new(mem); - let stats = map.node_cache_stats(); - assert_eq!(stats.hits, 0); - assert_eq!(stats.misses, 0); + let metrics = map.node_cache_metrics(); + assert_eq!(metrics.hits(), 0); + assert_eq!(metrics.misses(), 0); } #[test] fn node_cache_resize_at_runtime() { let mem = make_memory(); - let mut map: BTreeMap = - BTreeMap::new(mem).with_node_cache(32); + let mut map: BTreeMap = BTreeMap::new(mem).with_node_cache(32); for i in 0..100u64 { map.insert(i, i); @@ -3674,14 +3707,14 @@ mod test { for i in 0..100u64 { let _ = map.get(&i); } - let before = map.node_cache_stats(); - assert!(before.hits > 0, "expected cache hits before resize"); + let before = map.node_cache_metrics(); + assert!(before.hits() > 0, "expected cache hits before resize"); map.node_cache_resize(64); - let after = map.node_cache_stats(); - assert_eq!(after.hits, 0, "resize should reset counters"); - assert_eq!(after.misses, 0, "resize should reset counters"); + let after = map.node_cache_metrics(); + assert_eq!(after.hits(), 0, "resize should reset counters"); + assert_eq!(after.misses(), 0, "resize should reset counters"); for i in 0..100u64 { assert_eq!(map.get(&i), Some(i)); @@ -3704,22 +3737,20 @@ mod test { #[test] fn node_cache_non_power_of_two() { let mem = make_memory(); - let mut map: BTreeMap = - BTreeMap::new(mem).with_node_cache(50); + let mut map: BTreeMap = BTreeMap::new(mem).with_node_cache(50); for i in 0..100u64 { map.insert(i, i); } let _ = map.get(&50); let _ = map.get(&50); - assert!(map.node_cache_stats().hits > 0); + assert!(map.node_cache_metrics().hits() > 0); } #[test] fn node_cache_clear_resets_counters() { let mem = make_memory(); - let mut map: BTreeMap = - BTreeMap::new(mem).with_node_cache(32); + let mut map: BTreeMap = BTreeMap::new(mem).with_node_cache(32); for i in 0..50u64 { map.insert(i, i); @@ -3727,17 +3758,50 @@ mod test { for i in 0..50u64 { let _ = map.get(&i); } - let before = map.node_cache_stats(); - assert!(before.hits + before.misses > 0); + let before = map.node_cache_metrics(); + assert!(before.total() > 0); map.node_cache_clear(); - let after = map.node_cache_stats(); - assert_eq!(after.hits, 0); - assert_eq!(after.misses, 0); + let after = map.node_cache_metrics(); + assert_eq!(after.hits(), 0); + assert_eq!(after.misses(), 0); for i in 0..50u64 { assert_eq!(map.get(&i), Some(i)); } } + + #[test] + fn node_cache_clear_metrics_preserves_cache() { + let mem = make_memory(); + let mut map: BTreeMap = BTreeMap::new(mem).with_node_cache(32); + + for i in 0..50u64 { + map.insert(i, i); + } + // Populate cache with reads. + for i in 0..50u64 { + let _ = map.get(&i); + } + let before = map.node_cache_metrics(); + assert!(before.total() > 0); + + // Clear only metrics, not the cached nodes. + map.node_cache_clear_metrics(); + + let after = map.node_cache_metrics(); + assert_eq!(after.hits(), 0); + assert_eq!(after.misses(), 0); + + // Reads should still hit the cache since nodes weren't evicted. + for i in 0..50u64 { + assert_eq!(map.get(&i), Some(i)); + } + let final_metrics = map.node_cache_metrics(); + assert!( + final_metrics.hits() > 0, + "cached nodes should still be present" + ); + } } diff --git a/src/lib.rs b/src/lib.rs index e51f2072..ce433676 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ pub mod vec; pub mod vec_mem; pub mod writer; -pub use btreemap::{BTreeMap, BTreeMap as StableBTreeMap, NodeCacheStats}; +pub use btreemap::{BTreeMap, BTreeMap as StableBTreeMap, NodeCacheMetrics}; pub use btreeset::{BTreeSet, BTreeSet as StableBTreeSet}; pub use file_mem::FileMemory; #[cfg(target_arch = "wasm32")] From 9516ea99877b4226e887368a727eb545e2780739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 27 Mar 2026 15:17:34 +0100 Subject: [PATCH 10/42] Added an approximate node cache size in bytes --- src/btreemap.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/btreemap.rs b/src/btreemap.rs index d2385981..5b93e815 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -528,6 +528,31 @@ where self.cache.borrow().metrics() } + /// Returns an estimate of the cache's heap usage in bytes. + /// + /// The estimate is `num_slots * (page_size + per_slot_overhead)`. + /// Actual usage depends on key size and access patterns: + /// + /// - **Small keys** (≤ 16 bytes, e.g. `u64`): the estimate is roughly + /// **2×** actual usage, because cached nodes only hold compact keys + /// and child pointers — values are not cached. + /// - **Large keys** (> 16 bytes, e.g. 100-byte `String`): keys are + /// lazily loaded into an `OnceCell` during search and remain + /// materialized in the cache, so actual usage can **exceed** this + /// estimate. + /// + /// For example, with 32 slots and the default 1024-byte page size: + /// ~35 KB estimated vs ~17 KB actual (`u64` keys) or ~50 KB actual + /// (100-byte `String` keys). + /// + /// Use this as a rough order-of-magnitude guide, not a precise budget. + /// For exact heap profiling, use platform-specific tools. + pub fn node_cache_size_bytes_approx(&self) -> usize { + self.cache_num_slots + * (self.version.page_size().get() as usize + + std::mem::size_of::<(Address, Option>)>()) + } + /// Initializes a v1 `BTreeMap`. /// /// This is exposed only in testing. From a5ac1fc892553b8e89167a7b606bafc9abd820b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Fri, 27 Mar 2026 15:45:01 +0100 Subject: [PATCH 11/42] Add cache tests and fix clippy --- benchmarks/nns/src/nns_vote_cascading/tests.rs | 2 +- src/btreemap.rs | 5 +++++ src/btreemap/proptests.rs | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/benchmarks/nns/src/nns_vote_cascading/tests.rs b/benchmarks/nns/src/nns_vote_cascading/tests.rs index a6b7fd2f..2c26b725 100644 --- a/benchmarks/nns/src/nns_vote_cascading/tests.rs +++ b/benchmarks/nns/src/nns_vote_cascading/tests.rs @@ -168,7 +168,7 @@ fn set_up_worst_case( for neuron_id in num_followees..num_neurons { let previous_neuron_ids = (neuron_id - num_half_followees - 1)..neuron_id; let followee_neuron_ids = previous_neuron_ids - .map(|id| NeuronId::from(id)) + .map(NeuronId::from) .chain(not_voting_neuron_ids.clone().into_iter()) .collect::>(); neuron_store.set_followees( diff --git a/src/btreemap.rs b/src/btreemap.rs index 5b93e815..b3a2602a 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -1839,6 +1839,11 @@ mod test { let mem = make_memory(); let tree_v2 = BTreeMap::new(mem); f(tree_v2); + + // Test with V2 and node cache enabled. + let mem = make_memory(); + let tree_v2_cached = BTreeMap::new(mem).with_node_cache(32); + f(tree_v2_cached); } /// Checks that objects from boundary u32 values are strictly increasing. diff --git a/src/btreemap/proptests.rs b/src/btreemap/proptests.rs index 4403a42b..1b5f8606 100644 --- a/src/btreemap/proptests.rs +++ b/src/btreemap/proptests.rs @@ -69,6 +69,18 @@ fn comprehensive(#[strategy(pvec(operation_strategy(), 100..5_000))] ops: Vec) { + let mem = make_memory(); + let mut btree = BTreeMap::new(mem).with_node_cache(32); + let mut std_btree = StdBTreeMap::new(); + + for op in ops.into_iter() { + execute_operation(&mut std_btree, &mut btree, op); + } +} + // A comprehensive fuzz test that runs until it's explicitly terminated. To run: // // ``` From d0dffc4089db0f5c89984653bed297e61140323a Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 12:23:29 +0200 Subject: [PATCH 12/42] add mem_size --- src/lib.rs | 1 + src/mem_size.rs | 182 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 src/mem_size.rs diff --git a/src/lib.rs b/src/lib.rs index ce433676..8a76a4e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ pub mod file_mem; #[cfg(target_arch = "wasm32")] mod ic0_memory; // Memory API for canisters. pub mod log; +mod mem_size; pub mod memory_manager; pub mod min_heap; pub mod reader; diff --git a/src/mem_size.rs b/src/mem_size.rs new file mode 100644 index 00000000..a12397a3 --- /dev/null +++ b/src/mem_size.rs @@ -0,0 +1,182 @@ +/// Estimates the in-process memory footprint of a value in bytes, +/// covering both inline (stack) and heap-allocated data. +/// +/// Reports the logical data size, not the physical layout. Alignment +/// padding and allocator overhead are intentionally excluded — the +/// goal is to measure how much memory the data itself occupies. +/// +/// ## Performance +/// +/// Primitives, strings, and fixed-size containers are always O(1). +/// +/// Vectors of types with a known `ELEMENT_SIZE` are also O(1), +/// using simple multiplication instead of traversal. +/// +/// Types with a variable or unknown element size fall back to +/// per-element iteration, which is O(n). Implement `ELEMENT_SIZE` +/// for your fixed-size types to stay on the fast path. +pub trait MemSize { + /// Fixed per-element size, if known at compile time. + /// When `Some`, `Vec::mem_size()` uses `len * ELEMENT_SIZE` (O(1)) + /// instead of iterating (O(n)). Defaults to `None`. + const ELEMENT_SIZE: Option = None; + + /// Returns the estimated memory footprint of this value in bytes. + fn mem_size(&self) -> usize; +} + +impl MemSize for () { + #[inline] + fn mem_size(&self) -> usize { + 0 + } +} + +impl MemSize for u8 { + const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); + + #[inline] + fn mem_size(&self) -> usize { + std::mem::size_of::() + } +} + +impl MemSize for [u8] { + #[inline] + fn mem_size(&self) -> usize { + std::mem::size_of_val(self) + } +} + +impl MemSize for u32 { + const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); + + #[inline] + fn mem_size(&self) -> usize { + std::mem::size_of::() + } +} + +impl MemSize for u64 { + const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); + + #[inline] + fn mem_size(&self) -> usize { + std::mem::size_of::() + } +} + +impl MemSize for &str { + #[inline] + fn mem_size(&self) -> usize { + self.as_bytes().mem_size() + } +} + +impl MemSize for Vec { + #[inline] + fn mem_size(&self) -> usize { + let elements_size = match T::ELEMENT_SIZE { + Some(el_size) => self.len() * el_size, + None => self.iter().map(|x| x.mem_size()).sum::(), + }; + std::mem::size_of::() + elements_size + } +} + +impl MemSize for (A, B) { + #[inline] + fn mem_size(&self) -> usize { + self.0.mem_size() + self.1.mem_size() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_mem_size_unit() { + assert_eq!(().mem_size(), 0); + } + + #[test] + fn test_mem_size_u8() { + assert_eq!(0_u8.mem_size(), 1); + assert_eq!(42_u8.mem_size(), 1); + } + + #[test] + fn test_mem_size_u8_slice() { + let a: [u8; 0] = []; + assert_eq!(a.mem_size(), 0); + assert_eq!([1_u8].mem_size(), 1); + assert_eq!([1_u8, 2_u8].mem_size(), 2); + } + + #[test] + fn test_mem_size_u32() { + assert_eq!(0_u32.mem_size(), 4); + assert_eq!(42_u32.mem_size(), 4); + } + + #[test] + fn test_mem_size_u64() { + assert_eq!(0_u64.mem_size(), 8); + assert_eq!(42_u64.mem_size(), 8); + } + + #[test] + fn test_mem_size_u8_vec() { + let base = std::mem::size_of::>(); + assert_eq!(Vec::::from([]).mem_size(), base); + assert_eq!(Vec::::from([1]).mem_size(), base + 1); + assert_eq!(Vec::::from([1, 2]).mem_size(), base + 2); + } + + #[test] + fn test_mem_size_str() { + assert_eq!("a".mem_size(), 1); + assert_eq!("ab".mem_size(), 2); + } + + #[test] + fn test_mem_size_vec_with_element_size() { + // Vec uses the ELEMENT_SIZE fast path (Some(4)). + let base = std::mem::size_of::>(); + assert_eq!(Vec::::new().mem_size(), base); + assert_eq!(vec![1_u32].mem_size(), base + 4); + assert_eq!(vec![1_u32, 2, 3].mem_size(), base + 12); + } + + #[test] + fn test_mem_size_vec_without_element_size() { + type Blob = Vec; + // Vec has ELEMENT_SIZE = None, falls back to per-element iteration. + let base = std::mem::size_of::>(); + let blob_base = std::mem::size_of::(); + assert_eq!(Vec::::new().mem_size(), base); + // Each Blob reports size_of::() + content_len. + assert_eq!(vec![Blob::from([1, 2])].mem_size(), base + blob_base + 2); + assert_eq!( + vec![Blob::from([1]), Blob::from([2, 3])].mem_size(), + base + 2 * blob_base + 3 + ); + } + + #[test] + fn test_mem_size_tuple() { + // Measures logical data size, not physical layout. + // (u32, u64) = 4 + 8 = 12 bytes (padding excluded). + assert_eq!((1_u32, 2_u64).mem_size(), 4 + 8); + } + + #[test] + fn test_element_size_constants() { + assert_eq!(::ELEMENT_SIZE, Some(1)); + assert_eq!(::ELEMENT_SIZE, Some(4)); + assert_eq!(::ELEMENT_SIZE, Some(8)); + // Vec has no fixed element size. + assert_eq!( as MemSize>::ELEMENT_SIZE, None); + } +} From 6515edfd8db2e5fe7cdb8ed6379d278c725f784e Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 12:34:15 +0200 Subject: [PATCH 13/42] add impl MemSize for Node --- src/btreemap.rs | 17 ++++++++ src/btreemap/allocator.rs | 18 ++++++-- src/btreemap/node.rs | 86 ++++++++++++++++++++++++++++++++++++-- src/btreemap/node/tests.rs | 67 +++++++++++++++++++++++++++++ src/types.rs | 21 ++++++++++ 5 files changed, 202 insertions(+), 7 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index b3a2602a..44078327 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -53,6 +53,7 @@ mod iter; mod node; use crate::btreemap::iter::{IterInternal, KeysIter, ValuesIter}; use crate::{ + mem_size::MemSize, storable::Bound as StorableBound, types::{Address, NULL}, Memory, Storable, @@ -397,6 +398,22 @@ where _phantom: PhantomData<(K, V)>, } +impl MemSize for BTreeMap +where + K: Storable + Ord + Clone, + V: Storable, + M: Memory, +{ + fn mem_size(&self) -> usize { + // Excludes _phantom (zero-size) and the Memory handle + // (reported separately via stable_memory_size). + self.root_addr.mem_size() + + self.version.mem_size() + + self.allocator.mem_size() + + self.length.mem_size() + } +} + #[derive(PartialEq, Debug)] /// The packed header size must be <= ALLOCATOR_OFFSET. struct BTreeHeader { diff --git a/src/btreemap/allocator.rs b/src/btreemap/allocator.rs index 68544599..a0ffaa3b 100644 --- a/src/btreemap/allocator.rs +++ b/src/btreemap/allocator.rs @@ -1,4 +1,5 @@ use crate::{ + mem_size::MemSize, read_struct, types::{Address, Bytes, NULL}, write_struct, Memory, @@ -45,6 +46,17 @@ pub struct Allocator { memory: M, } +impl MemSize for Allocator { + fn mem_size(&self) -> usize { + // Excludes `memory: M` — it's a handle to the backing store, + // not data owned by the allocator. + self.header_addr.mem_size() + + self.allocation_size.mem_size() + + self.num_allocated_chunks.mem_size() + + self.free_list_head.mem_size() + } +} + #[repr(C, packed)] #[derive(PartialEq, Debug)] struct AllocatorHeader { @@ -230,9 +242,9 @@ impl Allocator { self.num_allocated_chunks } - // The full size of a chunk, which is the size of the header + the `allocation_size` that's - // available to the user. - fn chunk_size(&self) -> Bytes { + /// The full size of a chunk, which is the size of the header + the `allocation_size` that's + /// available to the user. + pub(crate) fn chunk_size(&self) -> Bytes { self.allocation_size + ChunkHeader::size() } diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index ea912c70..47dfe089 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -1,5 +1,6 @@ use crate::{ btreemap::Allocator, + mem_size::MemSize, read_address_vec, read_struct, read_to_vec, read_u32, read_u64, storable::Storable, types::{Address, Bytes}, @@ -36,6 +37,12 @@ pub enum NodeType { Internal, } +impl MemSize for NodeType { + fn mem_size(&self) -> usize { + core::mem::size_of::() + } +} + pub type Entry = (K, Vec); pub type EntryRef<'a, K> = (&'a K, &'a [u8]); @@ -66,6 +73,17 @@ pub struct Node { overflows: Vec
, } +impl MemSize for Node { + fn mem_size(&self) -> usize { + self.address.mem_size() + + self.entries.mem_size() + + self.children.mem_size() + + self.node_type.mem_size() + + self.version.mem_size() + + self.overflows.mem_size() + } +} + impl Node { /// Loads a node from memory at the given address. pub fn load(address: Address, page_size: PageSize, memory: &M) -> Self { @@ -528,7 +546,7 @@ impl NodeHeader { /// A lazily-loaded object, which can be either an immediate value or a deferred reference. #[derive(Debug)] -enum LazyObject { +enum LazyObject { ByVal(T), ByRef { offset: Bytes, @@ -537,7 +555,31 @@ enum LazyObject { }, } -impl LazyObject { +impl LazyObject { + /// Reports the serialized data size for loaded values, or just the + /// fixed fields for unloaded references. Uses `Storable::to_bytes()` + /// to measure ByVal — avoids requiring `T: MemSize`. + fn mem_size(&self) -> usize { + match self { + LazyObject::ByVal(value) => value.to_bytes().len(), + LazyObject::ByRef { + offset, + size, + loaded, + } => { + offset.mem_size() + + size.mem_size() + + if loaded.get().is_some() { + *size as usize + } else { + 0 + } + } + } + } +} + +impl LazyObject { #[inline(always)] pub fn by_value(value: T) -> Self { LazyObject::ByVal(value) @@ -582,6 +624,12 @@ type Blob = Vec; #[derive(Debug)] struct LazyValue(LazyObject); +impl MemSize for LazyValue { + fn mem_size(&self) -> usize { + self.0.mem_size() + } +} + impl LazyValue { #[inline(always)] pub fn by_value(value: Blob) -> Self { @@ -623,9 +671,15 @@ impl LazyValue { } #[derive(Debug)] -struct LazyKey(LazyObject); +struct LazyKey(LazyObject); -impl LazyKey { +impl MemSize for LazyKey { + fn mem_size(&self) -> usize { + self.0.mem_size() + } +} + +impl LazyKey { #[inline(always)] pub fn by_value(value: K) -> Self { Self(LazyObject::by_value(value)) @@ -647,6 +701,15 @@ impl LazyKey { } } +impl MemSize for Version { + fn mem_size(&self) -> usize { + match self { + Version::V1(page_size) => page_size.mem_size(), + Version::V2(page_size) => page_size.mem_size(), + } + } +} + /// Stores version-specific data. #[derive(Debug, PartialEq, Copy, Clone, Eq)] pub enum Version { @@ -678,6 +741,15 @@ pub enum PageSize { Value(u32), } +impl MemSize for PageSize { + fn mem_size(&self) -> usize { + match self { + Self::Value(page_size) => page_size.mem_size(), + Self::Derived(derived) => derived.mem_size(), + } + } +} + impl PageSize { pub fn get(&self) -> u32 { match self { @@ -700,3 +772,9 @@ impl DerivedPageSize { v1::size_v1(self.max_key_size, self.max_value_size).get() as u32 } } + +impl MemSize for DerivedPageSize { + fn mem_size(&self) -> usize { + self.max_key_size.mem_size() + self.max_value_size.mem_size() + } +} diff --git a/src/btreemap/node/tests.rs b/src/btreemap/node/tests.rs index ff1158ca..622dac1e 100644 --- a/src/btreemap/node/tests.rs +++ b/src/btreemap/node/tests.rs @@ -309,3 +309,70 @@ fn can_call_node_value_multiple_times_on_same_index() { let value2 = node.value(0, &mem); assert_eq!(value1, value2); } + +mod mem_size_tests { + use super::*; + use crate::mem_size::MemSize; + + #[test] + fn lazy_value_by_value() { + // ByVal with a 5-byte blob: reports the serialized length. + let val = LazyValue::by_value(vec![1, 2, 3, 4, 5]); + assert_eq!(val.mem_size(), 5); + } + + #[test] + fn lazy_value_by_ref_not_loaded() { + // ByRef before loading: offset (8) + size (4) = 12, no data. + let val = LazyValue::by_ref(Bytes::new(100), 42); + assert_eq!(val.mem_size(), 8 + 4); + } + + #[test] + fn lazy_value_by_ref_loaded() { + // ByRef after loading: offset (8) + size (4) + data (42) = 54. + let val = LazyValue::by_ref(Bytes::new(100), 42); + val.get_or_load(|_, size| vec![0u8; size as usize]); + assert_eq!(val.mem_size(), 8 + 4 + 42); + } + + #[test] + fn lazy_key_u32_by_value() { + // u32 serializes to 4 bytes. + let key = LazyKey::::by_value(42); + assert_eq!(key.mem_size(), 4); + } + + #[test] + fn lazy_key_u32_by_ref_not_loaded() { + let key = LazyKey::::by_ref(Bytes::new(100), 4); + assert_eq!(key.mem_size(), 8 + 4); + } + + #[test] + fn lazy_key_u32_by_ref_loaded() { + let key = LazyKey::::by_ref(Bytes::new(100), 4); + key.get_or_load(|_, _| 42u32); + assert_eq!(key.mem_size(), 8 + 4 + 4); + } + + #[test] + fn lazy_key_vec_by_value() { + // Vec key with 10 bytes of data. + let key = LazyKey::>::by_value(vec![0u8; 10]); + assert_eq!(key.mem_size(), 10); + } + + #[test] + fn lazy_key_vec_by_ref_not_loaded() { + let key = LazyKey::>::by_ref(Bytes::new(100), 10); + assert_eq!(key.mem_size(), 8 + 4); + } + + #[test] + fn lazy_key_vec_by_ref_loaded() { + let key = LazyKey::>::by_ref(Bytes::new(100), 10); + key.get_or_load(|_, size| vec![0u8; size as usize]); + assert_eq!(key.mem_size(), 8 + 4 + 10); + } +} diff --git a/src/types.rs b/src/types.rs index 0c9bbf7f..3a3aacc9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,3 +1,4 @@ +use crate::mem_size::MemSize; use core::ops::{Add, AddAssign, Div, Mul, Rem, Sub, SubAssign}; pub const NULL: Address = Address(0); @@ -53,6 +54,16 @@ impl AddAssign for Address { } } +impl MemSize for Address { + const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); + + #[inline] + fn mem_size(&self) -> usize { + let val = self.0; + val.mem_size() + } +} + #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Ord, Eq)] pub struct Bytes(u64); @@ -140,6 +151,16 @@ impl SubAssign for Bytes { } } +impl MemSize for Bytes { + const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); + + #[inline] + fn mem_size(&self) -> usize { + let val = self.0; + val.mem_size() + } +} + impl Bytes { pub const fn new(val: u64) -> Self { Self(val) From 6fd83b382b3dfe281b02b09006d58eaacc2c57cd Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 13:10:23 +0200 Subject: [PATCH 14/42] add node_cache_memory_used --- benchmarks/btreemap/canbench_results.yml | 536 +++++++++++------------ src/btreemap.rs | 56 ++- src/btreemap/node.rs | 6 +- 3 files changed, 312 insertions(+), 286 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 93ec44db..27b8d5b3 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,1036 +2,1036 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142223444 + instructions: 142223410 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 292251248 + instructions: 292222655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 4278657425 + instructions: 4278628754 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 821052288 + instructions: 821023629 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 293333653 + instructions: 293304935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1310779571 + instructions: 1310750905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 327147005 + instructions: 327168315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 324648699 + instructions: 324670011 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 324637021 + instructions: 324658316 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 245659274 + instructions: 269805516 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 317500664 + instructions: 317521985 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 322854230 + instructions: 322875526 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 327087164 + instructions: 327108482 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 320899527 + instructions: 320920844 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 320852457 + instructions: 320873774 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 323449943 + instructions: 323471269 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 322825815 + instructions: 322847116 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 244885342 + instructions: 244847083 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 2282455141 + instructions: 2282426481 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 401240082 + instructions: 401261395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 265723252 + instructions: 265694624 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 346737080 + instructions: 346980315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 218655247 + instructions: 218521322 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 221776623 + instructions: 221649308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 162855054 + instructions: 185671364 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 218655247 + instructions: 218521322 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 373755909 + instructions: 373998879 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1851466971 + instructions: 1851710326 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 559772809 + instructions: 560016104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 432384968 + instructions: 432628553 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 891524104 + instructions: 891767429 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 357596127 + instructions: 357839547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 485955886 + instructions: 486199306 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 413454913 + instructions: 413698418 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 290399668 + instructions: 316056098 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 365307336 + instructions: 365550716 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 431609647 + instructions: 431853147 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 354890140 + instructions: 355133525 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 367606496 + instructions: 367849891 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 450614263 + instructions: 450857658 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 401728737 + instructions: 401972087 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 368047115 + instructions: 368290590 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 397489879 + instructions: 397681169 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1227992746 + instructions: 1228236046 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 494053293 + instructions: 494296708 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 391070102 + instructions: 391313217 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388598599 + instructions: 388598565 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 296801695 + instructions: 296773102 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 4283690935 + instructions: 4283662264 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 826092151 + instructions: 826063492 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 298291372 + instructions: 298262654 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 1315800882 + instructions: 1315772216 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 328847079 + instructions: 328868389 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 335271701 + instructions: 335293013 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 329566744 + instructions: 329588039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 250318547 + instructions: 274464789 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 321740958 + instructions: 321762279 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 328441206 + instructions: 328462502 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 331475995 + instructions: 331497313 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 324621068 + instructions: 324642385 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 328439008 + instructions: 328460325 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 328010597 + instructions: 328031923 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 326857889 + instructions: 326879190 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 249975580 + instructions: 249937321 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 2287494049 + instructions: 2287465389 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 406289352 + instructions: 406310665 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 270843671 + instructions: 270815043 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 348608271 + instructions: 348851506 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 222816150 + instructions: 222682225 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 226338411 + instructions: 226211096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 167507739 + instructions: 190324049 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 223120174 + instructions: 222986249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 378534019 + instructions: 378776989 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1861977573 + instructions: 1862220928 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 567577313 + instructions: 567820608 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 438717716 + instructions: 438961301 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 899476068 + instructions: 899719393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 359444813 + instructions: 359688233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 509235657 + instructions: 509479077 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 420014588 + instructions: 420258093 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 296898606 + instructions: 322555036 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 369966461 + instructions: 370209841 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 444635792 + instructions: 444879292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 359708945 + instructions: 359952330 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 372145902 + instructions: 372389297 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 467504237 + instructions: 467747632 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 406919388 + instructions: 407162738 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 372626585 + instructions: 372870060 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 403559390 + instructions: 403750680 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1235850271 + instructions: 1236093571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501058182 + instructions: 501301597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 397241661 + instructions: 397484776 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4387226377 + instructions: 4387226356 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 436622114 + instructions: 436612113 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496163594 + instructions: 5496153593 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1180782137 + instructions: 1180772136 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486213167 + instructions: 486203166 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1788979849 + instructions: 1788969848 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 490411198 + instructions: 490401197 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 703450500 + instructions: 703440499 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 542518807 + instructions: 542508806 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_128_cached_32entry: total: calls: 1 - instructions: 543345427 + instructions: 543528304 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519066567 + instructions: 519056566 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 570640531 + instructions: 570630530 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 528902035 + instructions: 528892034 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509330487 + instructions: 509320486 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610013432 + instructions: 610003431 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 534872275 + instructions: 534862274 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 517544774 + instructions: 517534773 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407316857 + instructions: 407306856 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041165188 + instructions: 3041155187 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661124294 + instructions: 661114293 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 458606393 + instructions: 458596392 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 501982945 + instructions: 501972944 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 406695881 + instructions: 406685880 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 414530721 + instructions: 414520720 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 415372101 + instructions: 415558422 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410324198 + instructions: 410314197 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 592820136 + instructions: 592810135 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2743145193 + instructions: 2743135192 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1011265889 + instructions: 1011255888 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 707653590 + instructions: 707643589 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1400814198 + instructions: 1400804197 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 620501569 + instructions: 620491568 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1180703560 + instructions: 1180693559 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 754738693 + instructions: 754728692 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 755565313 + instructions: 755748190 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 664831919 + instructions: 664821918 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 867850710 + instructions: 867840709 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 660291790 + instructions: 660281789 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 658996206 + instructions: 658986205 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 972270626 + instructions: 972260625 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 690276014 + instructions: 690266013 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 658493986 + instructions: 658483985 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 603190644 + instructions: 603180643 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1857741950 + instructions: 1857731949 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 844932768 + instructions: 844922767 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 664998503 + instructions: 664988502 heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 2350826568 + instructions: 2350797902 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 277975211 + instructions: 277847358 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 281883487 + instructions: 281756172 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 360784676 + instructions: 360656823 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1259378621 + instructions: 1259573285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 2357976936 + instructions: 2357948270 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 286479343 + instructions: 286351490 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 287236190 + instructions: 287108875 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 375337462 + instructions: 375209609 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1267494745 + instructions: 1267689409 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1108,651 +1108,651 @@ benches: btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 599151004 + instructions: 599143210 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8387504673 + instructions: 8387494680 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1824625842 + instructions: 1824615932 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 742979122 + instructions: 742970166 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2763809068 + instructions: 2763799109 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 751383937 + instructions: 751374399 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1121367598 + instructions: 1121358047 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 860170573 + instructions: 860161023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 794980491 + instructions: 794970918 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 891627329 + instructions: 891617743 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 808446434 + instructions: 808436898 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 778752478 + instructions: 778742925 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 957459834 + instructions: 957450271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 817293552 + instructions: 817284040 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 796665272 + instructions: 796655719 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 371391381 + instructions: 371386206 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4613600846 + instructions: 4613590866 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1031597072 + instructions: 1031587286 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 604888373 + instructions: 604880670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 799174569 + instructions: 799164734 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 669158779 + instructions: 669148779 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 681143117 + instructions: 681133117 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 671716845 + instructions: 671706845 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 782070215 + instructions: 782062430 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4048053559 + instructions: 4048043566 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1502104847 + instructions: 1502094938 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1023809551 + instructions: 1023800597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2018716834 + instructions: 2018706876 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 861954194 + instructions: 861944659 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1688676486 + instructions: 1688666940 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1087802472 + instructions: 1087792924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 927266035 + instructions: 927256464 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1214401260 + instructions: 1214391675 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 930028204 + instructions: 930018670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 913757288 + instructions: 913747735 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1372171196 + instructions: 1372161635 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 971718315 + instructions: 971708804 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 923969225 + instructions: 923959674 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 540470482 + instructions: 540465321 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2715180077 + instructions: 2715170097 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1233441916 + instructions: 1233432131 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 849923373 + instructions: 849915681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 575613656 + instructions: 575605862 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8055154467 + instructions: 8055144474 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1755416087 + instructions: 1755406177 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 716459124 + instructions: 716450168 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2669637023 + instructions: 2669627064 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 723225579 + instructions: 723216041 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1085345039 + instructions: 1085335488 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 825795569 + instructions: 825786019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 766795291 + instructions: 766785718 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 860774944 + instructions: 860765358 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 775829677 + instructions: 775820141 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 755017437 + instructions: 755007884 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 932215641 + instructions: 932206078 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 791439355 + instructions: 791429843 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 768055658 + instructions: 768046105 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 357905025 + instructions: 357899850 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4444475877 + instructions: 4444465897 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 999649204 + instructions: 999639418 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 598904829 + instructions: 598897126 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 779236650 + instructions: 779226815 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 645819930 + instructions: 645809930 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 657459834 + instructions: 657449834 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 648281584 + instructions: 648271584 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 758760021 + instructions: 758752236 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4253598932 + instructions: 4253588939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1508544711 + instructions: 1508534802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1005176745 + instructions: 1005167791 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2072209623 + instructions: 2072199665 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 845108496 + instructions: 845098961 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1663299384 + instructions: 1663289838 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1063556514 + instructions: 1063546966 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 901987630 + instructions: 901978059 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1192398310 + instructions: 1192388725 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 909502456 + instructions: 909492922 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 897995224 + instructions: 897985671 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1355822245 + instructions: 1355812684 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 948772298 + instructions: 948762787 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 901485684 + instructions: 901476133 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 526558721 + instructions: 526553560 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2807025323 + instructions: 2807015343 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1219724906 + instructions: 1219715121 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 849795327 + instructions: 849787635 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_0b: total: calls: 1 - instructions: 16964 + instructions: 16962 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2507198 + instructions: 2507196 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 18468767 + instructions: 18468765 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_0b: total: calls: 1 - instructions: 16935 + instructions: 16933 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 2572996 + instructions: 2572994 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 18470001 + instructions: 18469999 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_0b: total: calls: 1 - instructions: 17302 + instructions: 17300 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 20668620 + instructions: 20668618 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 398305228 + instructions: 398305226 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1766,168 +1766,168 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 584603012 + instructions: 584583014 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7363742441 + instructions: 7363722441 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1588698430 + instructions: 1588678430 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665261563 + instructions: 665241563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2421641307 + instructions: 2421621307 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 654172400 + instructions: 654152400 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 985247212 + instructions: 985227212 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 746530989 + instructions: 746510989 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 748213616 + instructions: 748586232 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 699981236 + instructions: 699961236 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784047597 + instructions: 784027597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 711840362 + instructions: 711820362 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696137589 + instructions: 696117589 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 857858171 + instructions: 857838171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 736997963 + instructions: 736977963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 695978163 + instructions: 695958163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 452862617 + instructions: 452842619 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4071448837 + instructions: 4071428837 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 909991932 + instructions: 909971932 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599278644 + instructions: 599258644 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 683098045 + instructions: 683078045 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566115465 + instructions: 566095465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 586750993 + instructions: 586730993 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 588482760 + instructions: 588866842 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1941,7 +1941,7 @@ benches: btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 754807192 + instructions: 754787194 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1976,7 +1976,7 @@ benches: btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 833289651 + instructions: 833269651 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1997,7 +1997,7 @@ benches: btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1037504974 + instructions: 1037894426 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 44078327..1d8f9efd 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -95,8 +95,9 @@ const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; /// Node-cache performance metrics. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub struct NodeCacheMetrics { - hits: u64, - misses: u64, + hits_counter: u64, + misses_counter: u64, + memory_used_gauge: u64, } impl NodeCacheMetrics { @@ -105,21 +106,22 @@ impl NodeCacheMetrics { } /// Resets all counters to zero. - pub fn clear(&mut self) { - self.hits = 0; - self.misses = 0; + pub fn clear_counters(&mut self) { + self.hits_counter = 0; + self.misses_counter = 0; + // memory_used is not a counter but a gauge, so we don't reset it here. } pub fn hits(&self) -> u64 { - self.hits + self.hits_counter } pub fn misses(&self) -> u64 { - self.misses + self.misses_counter } pub fn total(&self) -> u64 { - self.hits + self.misses + self.hits_counter + self.misses_counter } /// Returns the hit ratio as a value between 0.0 and 1.0. @@ -129,16 +131,28 @@ impl NodeCacheMetrics { if total == 0 { 0.0 } else { - self.hits as f64 / total as f64 + self.hits_counter as f64 / total as f64 } } pub(crate) fn observe_hit(&mut self) { - self.hits += 1; + self.hits_counter += 1; } pub(crate) fn observe_miss(&mut self) { - self.misses += 1; + self.misses_counter += 1; + } + + pub fn memory_used(&self) -> usize { + self.memory_used_gauge as usize + } + + pub(crate) fn add_memory_used(&mut self, bytes: usize) { + self.memory_used_gauge = self.memory_used_gauge.saturating_add(bytes as u64); + } + + pub(crate) fn subtract_memory_used(&mut self, bytes: usize) { + self.memory_used_gauge = self.memory_used_gauge.saturating_sub(bytes as u64); } } @@ -183,7 +197,11 @@ impl NodeCache { if self.slots[idx].0 == addr { self.slots[idx].0 = NULL; self.metrics.observe_hit(); - self.slots[idx].1.take() + let result = self.slots[idx].1.take(); + if let Some(node) = &result { + self.metrics.subtract_memory_used(node.heap_memory_used()); + } + result } else { self.metrics.observe_miss(); None @@ -192,6 +210,7 @@ impl NodeCache { fn put(&mut self, addr: Address, node: Node) { debug_assert!(self.is_enabled()); + self.metrics.add_memory_used(node.heap_memory_used()); let idx = self.slot_index(addr); self.slots[idx] = (addr, Some(node)); } @@ -200,6 +219,9 @@ impl NodeCache { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); if self.slots[idx].0 == addr { + if let Some(node) = &self.slots[idx].1 { + self.metrics.subtract_memory_used(node.heap_memory_used()); + } self.slots[idx] = (NULL, None); } } @@ -209,14 +231,15 @@ impl NodeCache { } fn clear_metrics(&mut self) { - self.metrics.clear(); + self.metrics.clear_counters(); } fn clear(&mut self) { for slot in &mut self.slots { *slot = (NULL, None); } - self.metrics.clear(); + self.metrics.clear_counters(); + self.metrics.memory_used_gauge = 0; } } @@ -411,6 +434,7 @@ where + self.version.mem_size() + self.allocator.mem_size() + self.length.mem_size() + + self.node_cache_memory_used() } } @@ -570,6 +594,10 @@ where + std::mem::size_of::<(Address, Option>)>()) } + pub fn node_cache_memory_used(&self) -> usize { + self.cache.borrow().metrics().memory_used() + } + /// Initializes a v1 `BTreeMap`. /// /// This is exposed only in testing. diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index 47dfe089..3d64e267 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -73,8 +73,8 @@ pub struct Node { overflows: Vec
, } -impl MemSize for Node { - fn mem_size(&self) -> usize { +impl Node { + pub fn heap_memory_used(&self) -> usize { self.address.mem_size() + self.entries.mem_size() + self.children.mem_size() @@ -82,9 +82,7 @@ impl MemSize for Node { + self.version.mem_size() + self.overflows.mem_size() } -} -impl Node { /// Loads a node from memory at the given address. pub fn load(address: Address, page_size: PageSize, memory: &M) -> Self { // Load the header to determine which version the node is, then load the node accordingly. From d32047fbed0542614662d35cc6c46c2e4c7203f0 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 15:05:30 +0200 Subject: [PATCH 15/42] subtract evicted on put --- src/btreemap.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/btreemap.rs b/src/btreemap.rs index 1d8f9efd..0307f292 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -210,6 +210,10 @@ impl NodeCache { fn put(&mut self, addr: Address, node: Node) { debug_assert!(self.is_enabled()); + if let Some(evicted_node) = &self.slots[self.slot_index(addr)].1 { + self.metrics + .subtract_memory_used(evicted_node.heap_memory_used()); + } self.metrics.add_memory_used(node.heap_memory_used()); let idx = self.slot_index(addr); self.slots[idx] = (addr, Some(node)); From 4a954b2dd3ee7db70d08832a8dddce228373aa86 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 15:19:35 +0200 Subject: [PATCH 16/42] canbench persist --- benchmarks/btreemap/canbench_results.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 27b8d5b3..5b37cea8 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -65,7 +65,7 @@ benches: btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 269805516 + instructions: 283754143 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -170,7 +170,7 @@ benches: btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 185671364 + instructions: 198724435 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -240,7 +240,7 @@ benches: btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 316056098 + instructions: 330221811 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -387,7 +387,7 @@ benches: btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 274464789 + instructions: 288413416 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 190324049 + instructions: 203377120 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -562,7 +562,7 @@ benches: btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 322555036 + instructions: 336720749 heap_increase: 0 stable_memory_increase: 0 scopes: {} From 975bddb0f914667f0bfdca46593f2f4861696265 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 15:37:44 +0200 Subject: [PATCH 17/42] update ByVal --- benchmarks/btreemap/canbench_results.yml | 12 ++++++------ src/btreemap.rs | 12 +++++++----- src/btreemap/node.rs | 8 +++++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 5b37cea8..56c09509 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -65,7 +65,7 @@ benches: btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 283754143 + instructions: 285568540 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -170,7 +170,7 @@ benches: btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 198724435 + instructions: 216549343 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -240,7 +240,7 @@ benches: btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 330221811 + instructions: 333242771 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -387,7 +387,7 @@ benches: btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 288413416 + instructions: 290227813 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 203377120 + instructions: 221202028 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -562,7 +562,7 @@ benches: btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 336720749 + instructions: 339741709 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 0307f292..9d8ed1f4 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -195,11 +195,12 @@ impl NodeCache { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); if self.slots[idx].0 == addr { - self.slots[idx].0 = NULL; self.metrics.observe_hit(); + self.slots[idx].0 = NULL; let result = self.slots[idx].1.take(); - if let Some(node) = &result { - self.metrics.subtract_memory_used(node.heap_memory_used()); + if let Some(evicted_node) = &result { + self.metrics + .subtract_memory_used(evicted_node.heap_memory_used()); } result } else { @@ -223,8 +224,9 @@ impl NodeCache { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); if self.slots[idx].0 == addr { - if let Some(node) = &self.slots[idx].1 { - self.metrics.subtract_memory_used(node.heap_memory_used()); + if let Some(evicted_node) = &self.slots[idx].1 { + self.metrics + .subtract_memory_used(evicted_node.heap_memory_used()); } self.slots[idx] = (NULL, None); } diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index 3d64e267..8efd1e9b 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -559,7 +559,13 @@ impl LazyObject { /// to measure ByVal — avoids requiring `T: MemSize`. fn mem_size(&self) -> usize { match self { - LazyObject::ByVal(value) => value.to_bytes().len(), + LazyObject::ByVal(value) => { + if T::BOUND.is_fixed_size() { + T::BOUND.max_size() as usize + } else { + value.to_bytes().len() + } + } LazyObject::ByRef { offset, size, From 7f69bddac318d10381b3150e800928796586f06d Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 15:40:07 +0200 Subject: [PATCH 18/42] cleanup --- src/btreemap/allocator.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/btreemap/allocator.rs b/src/btreemap/allocator.rs index a0ffaa3b..01e07a93 100644 --- a/src/btreemap/allocator.rs +++ b/src/btreemap/allocator.rs @@ -242,9 +242,9 @@ impl Allocator { self.num_allocated_chunks } - /// The full size of a chunk, which is the size of the header + the `allocation_size` that's - /// available to the user. - pub(crate) fn chunk_size(&self) -> Bytes { + // The full size of a chunk, which is the size of the header + the `allocation_size` that's + // available to the user. + fn chunk_size(&self) -> Bytes { self.allocation_size + ChunkHeader::size() } From 259f35d0cfc65fa14f0e9ed3d8716091148ea358 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 15:51:50 +0200 Subject: [PATCH 19/42] fix computing slot_index twice in put --- benchmarks/btreemap/canbench_results.yml | 12 ++++++------ src/btreemap.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 56c09509..2ceb6887 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -65,7 +65,7 @@ benches: btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 285568540 + instructions: 284204912 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -170,7 +170,7 @@ benches: btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 216549343 + instructions: 215186891 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -240,7 +240,7 @@ benches: btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 333242771 + instructions: 331879143 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -387,7 +387,7 @@ benches: btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 290227813 + instructions: 288864185 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 221202028 + instructions: 219839576 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -562,7 +562,7 @@ benches: btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 339741709 + instructions: 338378081 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 9d8ed1f4..325fd2e3 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -211,12 +211,12 @@ impl NodeCache { fn put(&mut self, addr: Address, node: Node) { debug_assert!(self.is_enabled()); - if let Some(evicted_node) = &self.slots[self.slot_index(addr)].1 { + let idx = self.slot_index(addr); + if let Some(evicted_node) = &self.slots[idx].1 { self.metrics .subtract_memory_used(evicted_node.heap_memory_used()); } self.metrics.add_memory_used(node.heap_memory_used()); - let idx = self.slot_index(addr); self.slots[idx] = (addr, Some(node)); } From b78ee0cc3dd43bdc855b0395391b5f85c3828dd1 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 16:01:31 +0200 Subject: [PATCH 20/42] reduce nesting in traverse --- src/btreemap.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 325fd2e3..562534b0 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -1007,21 +1007,21 @@ where let node = self.take_or_load_node(node_addr); match node.search(key, self.memory()) { Ok(idx) => { - let result = f(&node, idx); + let result = f(&node, idx); // Key found: apply `f`. self.return_node(node); Some(result) } - Err(idx) => { - let child_addr = match node.node_type() { - NodeType::Leaf => { - self.return_node(node); - return None; - } - NodeType::Internal => node.child(idx), - }; - self.return_node(node); - self.traverse(child_addr, key, f) - } + Err(idx) => match node.node_type() { + NodeType::Leaf => { + self.return_node(node); + None // At a leaf: key not present. + } + NodeType::Internal => { + let child_addr = node.child(idx); + self.return_node(node); + self.traverse(child_addr, key, f) // Continue search in child. + } + }, } } From ec1286f2387ae2d32ee6352e835a58b81468d406 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 16:36:57 +0200 Subject: [PATCH 21/42] use cache for first/last entries --- benchmarks/btreemap/canbench_results.yml | 268 +++++++++++------------ src/btreemap.rs | 47 +++- src/btreemap/node.rs | 50 +---- 3 files changed, 183 insertions(+), 182 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 2ceb6887..03398c9c 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -1073,623 +1073,623 @@ benches: btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4310335711 + instructions: 4360827755 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 883184506 + instructions: 890149354 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 736990551 + instructions: 745401836 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1224139935 + instructions: 1233685158 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3083817917 + instructions: 3102282618 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 599143210 + instructions: 633123051 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8387494680 + instructions: 8635603553 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1824615932 + instructions: 1881614557 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 742970166 + instructions: 776901033 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2763799109 + instructions: 2849188285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 751374399 + instructions: 792118825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1121358047 + instructions: 1131974963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 860161023 + instructions: 893141021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 794970918 + instructions: 828413013 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 891617743 + instructions: 925678617 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 808436898 + instructions: 842142487 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 778742925 + instructions: 818165148 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 957450271 + instructions: 980062863 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 817284040 + instructions: 851753597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 796655719 + instructions: 833297777 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 371386206 + instructions: 386689795 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4613590866 + instructions: 4748450933 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1031587286 + instructions: 1062306171 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 604880670 + instructions: 630586450 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 799164734 + instructions: 836014744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 669148779 + instructions: 699581764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 681133117 + instructions: 715567087 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 671706845 + instructions: 701384393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 782062430 + instructions: 814174020 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4048043566 + instructions: 4092199716 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1502094938 + instructions: 1522999847 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1023800597 + instructions: 1066901366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2018706876 + instructions: 2054014428 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 861944659 + instructions: 890395551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1688666940 + instructions: 1678303699 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1087792924 + instructions: 1103730834 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 927256464 + instructions: 949192095 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1214391675 + instructions: 1228145640 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 930018670 + instructions: 947327110 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 913747735 + instructions: 939125663 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1372161635 + instructions: 1379527991 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 971708804 + instructions: 987860447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 923959674 + instructions: 946798282 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 540465321 + instructions: 559855285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2715170097 + instructions: 2749827645 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1233432131 + instructions: 1249345476 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 849915681 + instructions: 881593627 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 575605862 + instructions: 607501209 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8055144474 + instructions: 8299832211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1755406177 + instructions: 1802804951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 716450168 + instructions: 749969685 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2669627064 + instructions: 2762442963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 723216041 + instructions: 759978435 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1085335488 + instructions: 1096491877 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 825786019 + instructions: 856669055 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 766785718 + instructions: 803967725 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 860765358 + instructions: 888848944 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 775820141 + instructions: 808577312 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 755007884 + instructions: 792051074 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 932206078 + instructions: 952725305 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 791429843 + instructions: 821588319 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 768046105 + instructions: 805940241 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 357899850 + instructions: 374325531 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4444465897 + instructions: 4586942887 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 999639418 + instructions: 1028147459 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 598897126 + instructions: 625849698 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 779226815 + instructions: 830521500 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 645809930 + instructions: 676536149 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 657449834 + instructions: 691808145 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 648271584 + instructions: 678248438 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 758752236 + instructions: 793367683 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4253588939 + instructions: 4297820080 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1508534802 + instructions: 1529490359 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1005167791 + instructions: 1047963941 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2072199665 + instructions: 2094729463 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 845098961 + instructions: 871015131 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1663289838 + instructions: 1652833819 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1063546966 + instructions: 1078845090 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 901978059 + instructions: 925046487 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1192388725 + instructions: 1207335306 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 909492922 + instructions: 927160433 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 897985671 + instructions: 922358498 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1355812684 + instructions: 1363937802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 948762787 + instructions: 965167027 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 901476133 + instructions: 924991173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 526553560 + instructions: 548163087 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2807015343 + instructions: 2838002233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1219715121 + instructions: 1236471150 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 849787635 + instructions: 882403922 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1766,315 +1766,315 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 584583014 + instructions: 591022179 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7363722441 + instructions: 7446404264 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1588678430 + instructions: 1606247832 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665241563 + instructions: 673147884 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2421621307 + instructions: 2448606793 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 654152400 + instructions: 662245972 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 985227212 + instructions: 990687347 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 746510989 + instructions: 754186063 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 748586232 + instructions: 763545809 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 699961236 + instructions: 707908218 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784027597 + instructions: 791650003 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 711820362 + instructions: 719347836 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696117589 + instructions: 704158173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 857838171 + instructions: 864432715 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 736977963 + instructions: 744691274 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 695958163 + instructions: 704263295 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 452842619 + instructions: 456822296 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4071428837 + instructions: 4115740816 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 909971932 + instructions: 918522524 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599258644 + instructions: 605424905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 683078045 + instructions: 691640707 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566095465 + instructions: 572234711 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 586730993 + instructions: 592957300 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 588866842 + instructions: 606015520 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 571385552 + instructions: 577504576 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 754787194 + instructions: 764619923 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4474696476 + instructions: 4496637364 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1417086039 + instructions: 1427114270 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 920022911 + instructions: 931150104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2243497655 + instructions: 2257560846 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 833269651 + instructions: 839433367 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1700339959 + instructions: 1707456200 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1035835907 + instructions: 1043932464 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1037894426 + instructions: 1047382341 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 870269660 + instructions: 876977119 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1239040715 + instructions: 1247052194 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 866506222 + instructions: 872540455 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 861093062 + instructions: 867395546 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1404785875 + instructions: 1412176440 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 967234637 + instructions: 974652285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 855413255 + instructions: 861747549 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 661105186 + instructions: 667570143 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3081535655 + instructions: 3098554539 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1182814609 + instructions: 1192022272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 820703465 + instructions: 830399862 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 562534b0..e9659818 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -1025,6 +1025,41 @@ where } } + fn get_min_or_max_child(&self, node_addr: Address, is_min: bool) -> Entry { + let node = self.take_or_load_node(node_addr); + match node.node_type() { + NodeType::Leaf => { + let idx = if is_min { 0 } else { node.num_entries() - 1 }; + let entry = node.get_key_read_value_uncached(idx, self.memory()); + self.return_node(node); + entry + } + NodeType::Internal => { + // An internal node with N entries has N+1 children. + // Min is child(0), max is child(N) — the rightmost child. + let child_addr = if is_min { + node.child(0) + } else { + node.child(node.num_entries()) + }; + self.return_node(node); + self.get_min_or_max_child(child_addr, is_min) + } + } + } + + /// Returns the entry with min key in the subtree. + #[inline(always)] + fn get_min(&self, node_addr: Address) -> Entry { + self.get_min_or_max_child(node_addr, true) + } + + /// Returns the entry with max key in the subtree. + #[inline(always)] + fn get_max(&self, node_addr: Address) -> Entry { + self.get_min_or_max_child(node_addr, false) + } + /// Returns `true` if the map contains no elements. pub fn is_empty(&self) -> bool { self.length == 0 @@ -1068,7 +1103,7 @@ where return None; } let root = self.take_or_load_node(self.root_addr); - let (k, encoded_v) = root.get_min(self.memory()); + let (k, encoded_v) = self.get_min(root.address()); self.return_node(root); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1080,7 +1115,7 @@ where return None; } let root = self.take_or_load_node(self.root_addr); - let (k, encoded_v) = root.get_max(self.memory()); + let (k, encoded_v) = self.get_max(root.address()); self.return_node(root); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1112,7 +1147,7 @@ where } let root = self.load_node(self.root_addr); - let (max_key, _) = root.get_max(self.memory()); + let (max_key, _) = self.get_max(root.address()); self.remove_helper(root, &max_key) .map(|v| (max_key, V::from_bytes(Cow::Owned(v)))) } @@ -1124,7 +1159,7 @@ where } let root = self.load_node(self.root_addr); - let (min_key, _) = root.get_min(self.memory()); + let (min_key, _) = self.get_min(root.address()); self.remove_helper(root, &min_key) .map(|v| (min_key, V::from_bytes(Cow::Owned(v)))) } @@ -1196,7 +1231,7 @@ where // Recursively delete the predecessor. // TODO(EXC-1034): Do this in a single pass. - let predecessor = left_child.get_max(self.memory()); + let predecessor = self.get_max(left_child.address()); self.remove_helper(left_child, &predecessor.0)?; // Replace the `key` with its predecessor. @@ -1231,7 +1266,7 @@ where // Recursively delete the successor. // TODO(EXC-1034): Do this in a single pass. - let successor = right_child.get_min(self.memory()); + let successor = self.get_min(right_child.address()); self.remove_helper(right_child, &successor.0)?; // Replace the `key` with its successor. diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index 8efd1e9b..6c5bb0f9 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -120,48 +120,8 @@ impl Node { self.node_type } - /// Returns the entry with the max key in the subtree. - pub fn get_max(&self, memory: &M) -> Entry { - match self.node_type { - NodeType::Leaf => { - let last_entry = self.entries.last().expect("A node can never be empty"); - ( - self.get_key(last_entry, memory).clone(), - self.get_value(last_entry, memory).to_vec(), - ) - } - NodeType::Internal => { - let last_child = Self::load( - *self - .children - .last() - .expect("An internal node must have children."), - self.version.page_size(), - memory, - ); - last_child.get_max(memory) - } - } - } - - /// Returns the entry with min key in the subtree. - pub fn get_min(&self, memory: &M) -> Entry { - match self.node_type { - NodeType::Leaf => { - // NOTE: a node can never be empty, so this access is safe. - let entry = self.entry(0, memory); - (entry.0.clone(), entry.1.to_vec()) - } - NodeType::Internal => { - let first_child = Self::load( - // NOTE: an internal node must have children, so this access is safe. - self.children[0], - self.version.page_size(), - memory, - ); - first_child.get_min(memory) - } - } + pub(crate) fn num_entries(&self) -> usize { + self.entries.len() } /// Returns true if the node cannot store anymore entries, false otherwise. @@ -230,6 +190,12 @@ impl Node { .read_uncached(|offset, size| self.load_value_from_memory(offset, size, memory)) } + pub fn get_key_read_value_uncached(&self, idx: usize, memory: &M) -> Entry { + let key = self.get_key(&self.entries[idx], memory).clone(); + let value = self.read_value_uncached(idx, memory); + (key, value) + } + /// Extracts the contents of key (by loading it first if it's not loaded yet). fn extract_key(&self, key: LazyKey, memory: &M) -> K { key.take_or_load(|offset, size| self.load_key_from_memory(offset, size, memory)) From 0e0af37e0e2fce446461b76f85eed83a5b6750cc Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 17:35:03 +0200 Subject: [PATCH 22/42] optimize get min/max keys --- benchmarks/btreemap/canbench_results.yml | 268 +++++++++++------------ src/btreemap.rs | 54 +++-- 2 files changed, 169 insertions(+), 153 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 03398c9c..e359dbc7 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -1073,623 +1073,623 @@ benches: btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4360827755 + instructions: 4317631117 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 890149354 + instructions: 884244392 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 745401836 + instructions: 737609702 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1233685158 + instructions: 1225958024 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3102282618 + instructions: 3088770366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 633123051 + instructions: 591935991 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8635603553 + instructions: 8288387179 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1881614557 + instructions: 1796531644 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 776901033 + instructions: 728542306 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2849188285 + instructions: 2726151991 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 792118825 + instructions: 748781243 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1131974963 + instructions: 1081066153 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 893141021 + instructions: 844299463 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 828413013 + instructions: 785701511 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 925678617 + instructions: 871181722 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 842142487 + instructions: 798476444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 818165148 + instructions: 771338934 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 980062863 + instructions: 930016826 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 851753597 + instructions: 805391509 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 833297777 + instructions: 788214446 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 386689795 + instructions: 363451404 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4748450933 + instructions: 4555482638 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1062306171 + instructions: 1009137814 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 630586450 + instructions: 592741385 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 836014744 + instructions: 796669755 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 699581764 + instructions: 661242508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 715567087 + instructions: 672279564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 701384393 + instructions: 662684742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 814174020 + instructions: 762984085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4092199716 + instructions: 4027421104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1522999847 + instructions: 1484533893 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1066901366 + instructions: 999530283 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2054014428 + instructions: 2012905517 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 890395551 + instructions: 860096483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1678303699 + instructions: 1621643084 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1103730834 + instructions: 1068188529 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 949192095 + instructions: 916945828 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1228145640 + instructions: 1188800312 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 947327110 + instructions: 914394880 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 939125663 + instructions: 904861180 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1379527991 + instructions: 1334647769 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 987860447 + instructions: 954588606 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 946798282 + instructions: 915259785 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 559855285 + instructions: 526458822 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2749827645 + instructions: 2700770270 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1249345476 + instructions: 1215550091 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 881593627 + instructions: 827901988 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 607501209 + instructions: 568304020 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8299832211 + instructions: 7955934066 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1802804951 + instructions: 1727304564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 749969685 + instructions: 702092955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2762442963 + instructions: 2632067949 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 759978435 + instructions: 720606837 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1096491877 + instructions: 1044995455 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 856669055 + instructions: 809949310 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 803967725 + instructions: 757521977 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 888848944 + instructions: 840276931 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 808577312 + instructions: 765912909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 792051074 + instructions: 747608367 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 952725305 + instructions: 904689655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 821588319 + instructions: 779578680 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 805940241 + instructions: 759611226 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 374325531 + instructions: 350030872 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4586942887 + instructions: 4386381579 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 1028147459 + instructions: 977211050 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 625849698 + instructions: 586647938 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 830521500 + instructions: 776715543 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 676536149 + instructions: 637907378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 691808145 + instructions: 648414292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 678248438 + instructions: 639250557 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 793367683 + instructions: 742834877 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4297820080 + instructions: 4233548015 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1529490359 + instructions: 1489847122 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1047963941 + instructions: 979954407 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2094729463 + instructions: 2052587155 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 871015131 + instructions: 843234901 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1652833819 + instructions: 1595883070 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1078845090 + instructions: 1043106077 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 925046487 + instructions: 891675423 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1207335306 + instructions: 1164865946 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 927160433 + instructions: 894664631 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 922358498 + instructions: 889316867 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1363937802 + instructions: 1315745258 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 965167027 + instructions: 931865305 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 924991173 + instructions: 892784671 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 548163087 + instructions: 512210211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2838002233 + instructions: 2787254339 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1236471150 + instructions: 1200495013 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 882403922 + instructions: 826790198 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1766,315 +1766,315 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 591022179 + instructions: 585015305 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7446404264 + instructions: 7377009868 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1606247832 + instructions: 1591128753 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 673147884 + instructions: 665841269 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2448606793 + instructions: 2425689699 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 662245972 + instructions: 654453704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 990687347 + instructions: 986672947 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 754186063 + instructions: 747226431 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 763545809 + instructions: 749301674 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 707908218 + instructions: 700595696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 791650003 + instructions: 784861235 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 719347836 + instructions: 712445734 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 704158173 + instructions: 696691313 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 864432715 + instructions: 858904547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 744691274 + instructions: 737661715 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 704263295 + instructions: 696587410 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 456822296 + instructions: 453176578 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4115740816 + instructions: 4078393534 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 918522524 + instructions: 911588508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 605424905 + instructions: 599746602 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 691640707 + instructions: 683340009 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 572234711 + instructions: 566560912 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 592957300 + instructions: 587251157 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 606015520 + instructions: 589387006 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 577504576 + instructions: 571897924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 764619923 + instructions: 754880627 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4496637364 + instructions: 4482353491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1427114270 + instructions: 1419385921 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 931150104 + instructions: 919413296 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2257560846 + instructions: 2247128783 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 839433367 + instructions: 834448759 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1707456200 + instructions: 1703393507 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1043932464 + instructions: 1037264657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1047382341 + instructions: 1039323176 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 876977119 + instructions: 871514377 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1247052194 + instructions: 1241548210 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 872540455 + instructions: 867712184 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 867395546 + instructions: 862324671 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1412176440 + instructions: 1407640955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 974652285 + instructions: 968640899 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 861747549 + instructions: 856659888 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 667570143 + instructions: 662045769 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3098554539 + instructions: 3083483890 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1192022272 + instructions: 1183664207 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 830399862 + instructions: 822011534 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index e9659818..b47630b9 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -1025,14 +1025,16 @@ where } } - fn get_min_or_max_child(&self, node_addr: Address, is_min: bool) -> Entry { - let node = self.take_or_load_node(node_addr); + fn get_min_or_max( + &self, + node: &Node, + is_min: bool, + extract: fn(&Node, usize, &M) -> R, + ) -> R { match node.node_type() { NodeType::Leaf => { let idx = if is_min { 0 } else { node.num_entries() - 1 }; - let entry = node.get_key_read_value_uncached(idx, self.memory()); - self.return_node(node); - entry + extract(node, idx, self.memory()) } NodeType::Internal => { // An internal node with N entries has N+1 children. @@ -1042,22 +1044,36 @@ where } else { node.child(node.num_entries()) }; - self.return_node(node); - self.get_min_or_max_child(child_addr, is_min) + let child = self.load_node(child_addr); + self.get_min_or_max(&child, is_min, extract) } } } - /// Returns the entry with min key in the subtree. #[inline(always)] - fn get_min(&self, node_addr: Address) -> Entry { - self.get_min_or_max_child(node_addr, true) + fn get_min_key(&self, node: &Node) -> K { + self.get_min_or_max(node, true, |n, i, m| n.key(i, m).clone()) + } + + #[inline(always)] + fn get_max_key(&self, node: &Node) -> K { + self.get_min_or_max(node, false, |n, i, m| n.key(i, m).clone()) } - /// Returns the entry with max key in the subtree. #[inline(always)] - fn get_max(&self, node_addr: Address) -> Entry { - self.get_min_or_max_child(node_addr, false) + fn get_min_entry(&self, node: &Node) -> Entry { + self.get_min_or_max(node, true, |n, i, m| { + let (k, v) = n.get_key_read_value_uncached(i, m); + (k.clone(), v.to_vec()) + }) + } + + #[inline(always)] + fn get_max_entry(&self, node: &Node) -> Entry { + self.get_min_or_max(node, false, |n, i, m| { + let (k, v) = n.get_key_read_value_uncached(i, m); + (k.clone(), v.to_vec()) + }) } /// Returns `true` if the map contains no elements. @@ -1103,7 +1119,7 @@ where return None; } let root = self.take_or_load_node(self.root_addr); - let (k, encoded_v) = self.get_min(root.address()); + let (k, encoded_v) = self.get_min_entry(&root); self.return_node(root); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1115,7 +1131,7 @@ where return None; } let root = self.take_or_load_node(self.root_addr); - let (k, encoded_v) = self.get_max(root.address()); + let (k, encoded_v) = self.get_max_entry(&root); self.return_node(root); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1147,7 +1163,7 @@ where } let root = self.load_node(self.root_addr); - let (max_key, _) = self.get_max(root.address()); + let max_key = self.get_max_key(&root); self.remove_helper(root, &max_key) .map(|v| (max_key, V::from_bytes(Cow::Owned(v)))) } @@ -1159,7 +1175,7 @@ where } let root = self.load_node(self.root_addr); - let (min_key, _) = self.get_min(root.address()); + let min_key = self.get_min_key(&root); self.remove_helper(root, &min_key) .map(|v| (min_key, V::from_bytes(Cow::Owned(v)))) } @@ -1231,7 +1247,7 @@ where // Recursively delete the predecessor. // TODO(EXC-1034): Do this in a single pass. - let predecessor = self.get_max(left_child.address()); + let predecessor = self.get_max_entry(&left_child); self.remove_helper(left_child, &predecessor.0)?; // Replace the `key` with its predecessor. @@ -1266,7 +1282,7 @@ where // Recursively delete the successor. // TODO(EXC-1034): Do this in a single pass. - let successor = self.get_min(right_child.address()); + let successor = self.get_min_entry(&right_child); self.remove_helper(right_child, &successor.0)?; // Replace the `key` with its successor. From 11e3311e01cad51cee0837b812344bb4753b3757 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 18:40:34 +0200 Subject: [PATCH 23/42] mem_size capacity --- benchmarks/btreemap/canbench_results.yml | 16 ++++----- src/mem_size.rs | 44 ++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index e359dbc7..f2ed68a5 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -65,7 +65,7 @@ benches: btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 284204912 + instructions: 284844071 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -149,7 +149,7 @@ benches: btreemap_v2_contains_principal: total: calls: 1 - instructions: 346980315 + instructions: 347077609 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -170,7 +170,7 @@ benches: btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 215186891 + instructions: 215809190 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -240,7 +240,7 @@ benches: btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 331879143 + instructions: 332514419 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -387,7 +387,7 @@ benches: btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 288864185 + instructions: 289503344 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -471,7 +471,7 @@ benches: btreemap_v2_get_principal: total: calls: 1 - instructions: 348851506 + instructions: 348948800 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 219839576 + instructions: 220461875 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -562,7 +562,7 @@ benches: btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 338378081 + instructions: 339013357 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/mem_size.rs b/src/mem_size.rs index a12397a3..06d23dd1 100644 --- a/src/mem_size.rs +++ b/src/mem_size.rs @@ -77,8 +77,14 @@ impl MemSize for Vec { #[inline] fn mem_size(&self) -> usize { let elements_size = match T::ELEMENT_SIZE { - Some(el_size) => self.len() * el_size, - None => self.iter().map(|x| x.mem_size()).sum::(), + // For fixed-size elements, the allocator reserves capacity * element_size bytes. + Some(el_size) => self.capacity() * el_size, + // For variable-size elements, we can only measure initialized elements + // plus the slack from capacity - len (using size_of::() per slack slot). + None => { + self.iter().map(|x| x.mem_size()).sum::() + + (self.capacity() - self.len()) * std::mem::size_of::() + } }; std::mem::size_of::() + elements_size } @@ -171,6 +177,40 @@ mod tests { assert_eq!((1_u32, 2_u64).mem_size(), 4 + 8); } + #[test] + fn test_mem_size_vec_measures_capacity_fixed_size() { + // Vec has ELEMENT_SIZE = Some(4), so capacity is measured directly. + let base = std::mem::size_of::>(); + let mut v = Vec::::with_capacity(10); + // Empty but capacity = 10 → 10 * 4 = 40 bytes of heap. + assert_eq!(v.mem_size(), base + 10 * 4); + + v.push(1); + v.push(2); + // len = 2, capacity = 10 → still 10 * 4 = 40. + assert_eq!(v.len(), 2); + assert_eq!(v.capacity(), 10); + assert_eq!(v.mem_size(), base + 10 * 4); + } + + #[test] + fn test_mem_size_vec_measures_capacity_variable_size() { + // Vec> has ELEMENT_SIZE = None → per-element iteration + slack. + type Blob = Vec; + let base = std::mem::size_of::>(); + let blob_base = std::mem::size_of::(); + + let mut v = Vec::::with_capacity(5); + // Empty, capacity = 5 → 5 slack slots × size_of::(). + assert_eq!(v.mem_size(), base + 5 * blob_base); + + v.push(Blob::from([1, 2, 3])); + // len = 1 (blob_base + 3), slack = 4 × blob_base. + assert_eq!(v.len(), 1); + assert_eq!(v.capacity(), 5); + assert_eq!(v.mem_size(), base + (blob_base + 3) + 4 * blob_base); + } + #[test] fn test_element_size_constants() { assert_eq!(::ELEMENT_SIZE, Some(1)); From cb82ce869e3889d8fed7fb9169beaa7e3967a68b Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 18:53:49 +0200 Subject: [PATCH 24/42] add compare_cache_size_estimates test --- src/btreemap.rs | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/src/btreemap.rs b/src/btreemap.rs index b47630b9..48c6e2eb 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -3936,4 +3936,135 @@ mod test { "cached nodes should still be present" ); } + + /// Temporary test: compare node_cache_size_bytes_approx vs node_cache_memory_used + /// across different key/value types, map sizes, and cache slot counts. + #[test] + fn compare_cache_size_estimates() { + struct Row { + label: &'static str, + num_entries: u64, + cache_slots: usize, + approx: usize, + actual: usize, + } + + impl Row { + fn ratio(&self) -> f64 { + if self.actual == 0 { + f64::NAN + } else { + self.approx as f64 / self.actual as f64 + } + } + fn diff(&self) -> isize { + self.approx as isize - self.actual as isize + } + } + + fn measure( + label: &'static str, + num_entries: u64, + cache_slots: usize, + ) -> Row { + let mem = make_memory(); + let mut map: BTreeMap = BTreeMap::new(mem).with_node_cache(cache_slots); + + for i in 0..num_entries { + map.insert(K::build(i as u32), V::build(i as u32)); + } + // Warm the cache with reads. + for i in 0..num_entries { + let _ = map.get(&K::build(i as u32)); + } + + Row { + label, + num_entries, + cache_slots, + approx: map.node_cache_size_bytes_approx(), + actual: map.node_cache_memory_used(), + } + } + + let entries_counts = [1_000, 10_000, 100_000]; + let cache_slots = [32]; + + let mut rows: Vec = Vec::new(); + + for &n in &entries_counts { + for &slots in &cache_slots { + rows.push(measure::("u32, u32", n, slots)); + rows.push(measure::>("u32, Blob<20>", n, slots)); + rows.push(measure::, u32>("Blob<10>, u32", n, slots)); + rows.push(measure::, Blob<20>>( + "Blob<10>, Blob<20>", + n, + slots, + )); + rows.push(measure::("Vec32, u32", n, slots)); + rows.push(measure::( + "Vec32, Vec32", + n, + slots, + )); + rows.push(measure::( + "Str32, Str32", + n, + slots, + )); + } + } + + // Print the comparison table. + println!(); + println!( + "{:<18} {:>7} {:>6} {:>10} {:>10} {:>10} {:>7}", + "K, V", "entries", "slots", "approx", "actual", "diff", "ratio" + ); + println!("{}", "-".repeat(75)); + for r in &rows { + println!( + "{:<18} {:>7} {:>6} {:>10} {:>10} {:>+10} {:>7.2}", + r.label, + r.num_entries, + r.cache_slots, + r.approx, + r.actual, + r.diff(), + r.ratio(), + ); + } + println!(); + + // Summary: group by label, show min/max ratio. + println!("=== Summary by key/value type ==="); + println!( + "{:<18} {:>10} {:>10} {:>10}", + "K, V", "min ratio", "max ratio", "avg ratio" + ); + println!("{}", "-".repeat(52)); + let labels: Vec<&str> = rows + .iter() + .map(|r| r.label) + .collect::>() + .into_iter() + .collect(); + for label in &labels { + let group: Vec<&Row> = rows.iter().filter(|r| r.label == *label).collect(); + let ratios: Vec = group + .iter() + .filter(|r| r.actual > 0) + .map(|r| r.ratio()) + .collect(); + if ratios.is_empty() { + continue; + } + let min = ratios.iter().cloned().fold(f64::INFINITY, f64::min); + let max = ratios.iter().cloned().fold(f64::NEG_INFINITY, f64::max); + let avg = ratios.iter().sum::() / ratios.len() as f64; + println!("{:<18} {:>10.2} {:>10.2} {:>10.2}", label, min, max, avg); + } + println!(); + } } From 8dc9a718570de78f72485abbb86b9b7fcef47109 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 18:58:26 +0200 Subject: [PATCH 25/42] update test use cases --- src/btreemap.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/btreemap.rs b/src/btreemap.rs index 48c6e2eb..944099c0 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -3996,6 +3996,8 @@ mod test { for &slots in &cache_slots { rows.push(measure::("u32, u32", n, slots)); rows.push(measure::>("u32, Blob<20>", n, slots)); + rows.push(measure::>("u32, Blob<512>", n, slots)); + rows.push(measure::>("u32, Blob<900>", n, slots)); rows.push(measure::, u32>("Blob<10>, u32", n, slots)); rows.push(measure::, Blob<20>>( "Blob<10>, Blob<20>", From b9159fc4bd542fca8e6de5135e2a6c6ae3b50c34 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 19:09:51 +0200 Subject: [PATCH 26/42] remove mem_size --- benchmarks/btreemap/canbench_results.yml | 532 +++++++++++------------ src/btreemap.rs | 186 +------- src/btreemap/allocator.rs | 12 - src/btreemap/node.rs | 90 +--- src/btreemap/node/tests.rs | 67 --- src/lib.rs | 1 - src/mem_size.rs | 222 ---------- src/types.rs | 21 - 8 files changed, 271 insertions(+), 860 deletions(-) delete mode 100644 src/mem_size.rs diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index f2ed68a5..2bbb20fc 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,1036 +2,1036 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142223410 + instructions: 142223444 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 292222655 + instructions: 292251248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 4278628754 + instructions: 4278657425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 821023629 + instructions: 821052288 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 293304935 + instructions: 293333653 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1310750905 + instructions: 1310779571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 327168315 + instructions: 327147005 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 324670011 + instructions: 324648699 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 324658316 + instructions: 324637021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 284844071 + instructions: 245659274 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 317521985 + instructions: 317500664 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 322875526 + instructions: 322854230 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 327108482 + instructions: 327087164 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 320920844 + instructions: 320899527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 320873774 + instructions: 320852457 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 323471269 + instructions: 323449943 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 322847116 + instructions: 322825815 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 244847083 + instructions: 244885342 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 2282426481 + instructions: 2282455141 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 401261395 + instructions: 401240082 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 265694624 + instructions: 265723252 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 347077609 + instructions: 346737080 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 218521322 + instructions: 218655247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 221649308 + instructions: 221776623 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 215809190 + instructions: 162855054 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 218521322 + instructions: 218655247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 373998879 + instructions: 373755909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1851710326 + instructions: 1851466971 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 560016104 + instructions: 559772809 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 432628553 + instructions: 432384968 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 891767429 + instructions: 891524104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 357839547 + instructions: 357596127 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 486199306 + instructions: 485955886 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 413698418 + instructions: 413454913 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 332514419 + instructions: 290399668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 365550716 + instructions: 365307336 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 431853147 + instructions: 431609647 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 355133525 + instructions: 354890140 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 367849891 + instructions: 367606496 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 450857658 + instructions: 450614263 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 401972087 + instructions: 401728737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 368290590 + instructions: 368047115 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 397681169 + instructions: 397489879 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1228236046 + instructions: 1227992746 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 494296708 + instructions: 494053293 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 391313217 + instructions: 391070102 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388598565 + instructions: 388598599 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 296773102 + instructions: 296801695 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 4283662264 + instructions: 4283690935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 826063492 + instructions: 826092151 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 298262654 + instructions: 298291372 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 1315772216 + instructions: 1315800882 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 328868389 + instructions: 328847079 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 335293013 + instructions: 335271701 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 329588039 + instructions: 329566744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 289503344 + instructions: 250318547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 321762279 + instructions: 321740958 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 328462502 + instructions: 328441206 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 331497313 + instructions: 331475995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 324642385 + instructions: 324621068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 328460325 + instructions: 328439008 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 328031923 + instructions: 328010597 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 326879190 + instructions: 326857889 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 249937321 + instructions: 249975580 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 2287465389 + instructions: 2287494049 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 406310665 + instructions: 406289352 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 270815043 + instructions: 270843671 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 348948800 + instructions: 348608271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 222682225 + instructions: 222816150 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 226211096 + instructions: 226338411 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 220461875 + instructions: 167507739 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 222986249 + instructions: 223120174 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 378776989 + instructions: 378534019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1862220928 + instructions: 1861977573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 567820608 + instructions: 567577313 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 438961301 + instructions: 438717716 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 899719393 + instructions: 899476068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 359688233 + instructions: 359444813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 509479077 + instructions: 509235657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 420258093 + instructions: 420014588 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 339013357 + instructions: 296898606 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 370209841 + instructions: 369966461 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 444879292 + instructions: 444635792 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 359952330 + instructions: 359708945 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 372389297 + instructions: 372145902 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 467747632 + instructions: 467504237 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 407162738 + instructions: 406919388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 372870060 + instructions: 372626585 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 403750680 + instructions: 403559390 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1236093571 + instructions: 1235850271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501301597 + instructions: 501058182 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 397484776 + instructions: 397241661 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4387226356 + instructions: 4387226377 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 436612113 + instructions: 436622114 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496153593 + instructions: 5496163594 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1180772136 + instructions: 1180782137 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486203166 + instructions: 486213167 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1788969848 + instructions: 1788979849 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 490401197 + instructions: 490411198 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 703440499 + instructions: 703450500 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 542508806 + instructions: 542518807 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_128_cached_32entry: total: calls: 1 - instructions: 543528304 + instructions: 543345427 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519056566 + instructions: 519066567 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 570630530 + instructions: 570640531 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 528892034 + instructions: 528902035 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509320486 + instructions: 509330487 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610003431 + instructions: 610013432 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 534862274 + instructions: 534872275 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 517534773 + instructions: 517544774 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407306856 + instructions: 407316857 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041155187 + instructions: 3041165188 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661114293 + instructions: 661124294 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 458596392 + instructions: 458606393 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 501972944 + instructions: 501982945 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 406685880 + instructions: 406695881 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 414520720 + instructions: 414530721 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 415558422 + instructions: 415372101 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410314197 + instructions: 410324198 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 592810135 + instructions: 592820136 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2743135192 + instructions: 2743145193 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1011255888 + instructions: 1011265889 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 707643589 + instructions: 707653590 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1400804197 + instructions: 1400814198 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 620491568 + instructions: 620501569 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1180693559 + instructions: 1180703560 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 754728692 + instructions: 754738693 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 755748190 + instructions: 755565313 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 664821918 + instructions: 664831919 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 867840709 + instructions: 867850710 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 660281789 + instructions: 660291790 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 658986205 + instructions: 658996206 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 972260625 + instructions: 972270626 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 690266013 + instructions: 690276014 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 658483985 + instructions: 658493986 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 603180643 + instructions: 603190644 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1857731949 + instructions: 1857741950 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 844922767 + instructions: 844932768 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 664988502 + instructions: 664998503 heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 2350797902 + instructions: 2350826568 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 277847358 + instructions: 277975211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 281756172 + instructions: 281883487 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 360656823 + instructions: 360784676 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1259573285 + instructions: 1259378621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 2357948270 + instructions: 2357976936 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 286351490 + instructions: 286479343 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 287108875 + instructions: 287236190 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 375209609 + instructions: 375337462 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1267689409 + instructions: 1267494745 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1108,154 +1108,154 @@ benches: btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 591935991 + instructions: 591951579 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8288387179 + instructions: 8288407165 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1796531644 + instructions: 1796551464 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 728542306 + instructions: 728560218 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2726151991 + instructions: 2726171909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 748781243 + instructions: 748800319 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1081066153 + instructions: 1081085255 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 844299463 + instructions: 844318563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 785701511 + instructions: 785720657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 871181722 + instructions: 871200894 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 798476444 + instructions: 798495516 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 771338934 + instructions: 771358040 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 930016826 + instructions: 930035952 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 805391509 + instructions: 805410533 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 788214446 + instructions: 788233552 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 363451404 + instructions: 363461754 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4555482638 + instructions: 4555502598 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1009137814 + instructions: 1009157386 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 592741385 + instructions: 592756791 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 796669755 + instructions: 796689425 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 661242508 + instructions: 661262508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 672279564 + instructions: 672299564 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1269,287 +1269,287 @@ benches: btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 762984085 + instructions: 762999655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4027421104 + instructions: 4027441090 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1484533893 + instructions: 1484553711 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 999530283 + instructions: 999548191 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2012905517 + instructions: 2012925433 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 860096483 + instructions: 860115553 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1621643084 + instructions: 1621662176 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1068188529 + instructions: 1068207625 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 916945828 + instructions: 916964970 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1188800312 + instructions: 1188819482 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 914394880 + instructions: 914413948 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 904861180 + instructions: 904880286 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1334647769 + instructions: 1334666891 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 954588606 + instructions: 954607628 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 915259785 + instructions: 915278887 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 526458822 + instructions: 526469144 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2700770270 + instructions: 2700790230 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1215550091 + instructions: 1215569661 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 827901988 + instructions: 827917372 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 568304020 + instructions: 568319608 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 7955934066 + instructions: 7955954052 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1727304564 + instructions: 1727324384 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 702092955 + instructions: 702110867 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2632067949 + instructions: 2632087867 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 720606837 + instructions: 720625913 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1044995455 + instructions: 1045014557 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 809949310 + instructions: 809968410 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 757521977 + instructions: 757541123 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 840276931 + instructions: 840296103 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 765912909 + instructions: 765931981 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 747608367 + instructions: 747627473 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 904689655 + instructions: 904708781 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 779578680 + instructions: 779597704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 759611226 + instructions: 759630332 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 350030872 + instructions: 350041222 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4386381579 + instructions: 4386401539 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 977211050 + instructions: 977230622 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 586647938 + instructions: 586663344 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 776715543 + instructions: 776735213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 637907378 + instructions: 637927378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 648414292 + instructions: 648434292 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1563,196 +1563,196 @@ benches: btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 742834877 + instructions: 742850447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4233548015 + instructions: 4233568001 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1489847122 + instructions: 1489866940 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 979954407 + instructions: 979972315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2052587155 + instructions: 2052607071 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 843234901 + instructions: 843253971 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1595883070 + instructions: 1595902162 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1043106077 + instructions: 1043125173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 891675423 + instructions: 891694565 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1164865946 + instructions: 1164885116 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 894664631 + instructions: 894683699 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 889316867 + instructions: 889335973 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1315745258 + instructions: 1315764380 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 931865305 + instructions: 931884327 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 892784671 + instructions: 892803773 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 512210211 + instructions: 512220533 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2787254339 + instructions: 2787274299 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1200495013 + instructions: 1200514583 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 826790198 + instructions: 826805582 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_0b: total: calls: 1 - instructions: 16962 + instructions: 16964 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2507196 + instructions: 2507198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 18468765 + instructions: 18468767 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_0b: total: calls: 1 - instructions: 16933 + instructions: 16935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 2572994 + instructions: 2572996 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 18469999 + instructions: 18470001 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_0b: total: calls: 1 - instructions: 17300 + instructions: 17302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 20668618 + instructions: 20668620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 398305226 + instructions: 398305228 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1766,168 +1766,168 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 585015305 + instructions: 585035303 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7377009868 + instructions: 7377029868 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1591128753 + instructions: 1591148753 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665841269 + instructions: 665861269 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2425689699 + instructions: 2425709699 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 654453704 + instructions: 654473704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 986672947 + instructions: 986692947 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 747226431 + instructions: 747246431 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 749301674 + instructions: 748929058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 700595696 + instructions: 700615696 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784861235 + instructions: 784881235 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 712445734 + instructions: 712465734 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696691313 + instructions: 696711313 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 858904547 + instructions: 858924547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 737661715 + instructions: 737681715 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 696587410 + instructions: 696607410 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 453176578 + instructions: 453196576 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4078393534 + instructions: 4078413534 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 911588508 + instructions: 911608508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599746602 + instructions: 599766602 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 683340009 + instructions: 683360009 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566560912 + instructions: 566580912 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 587251157 + instructions: 587271157 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 589387006 + instructions: 589002924 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1941,7 +1941,7 @@ benches: btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 754880627 + instructions: 754900625 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1976,7 +1976,7 @@ benches: btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 834448759 + instructions: 834468759 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1997,7 +1997,7 @@ benches: btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1039323176 + instructions: 1038933724 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 944099c0..4164f3de 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -53,7 +53,6 @@ mod iter; mod node; use crate::btreemap::iter::{IterInternal, KeysIter, ValuesIter}; use crate::{ - mem_size::MemSize, storable::Bound as StorableBound, types::{Address, NULL}, Memory, Storable, @@ -97,7 +96,6 @@ const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; pub struct NodeCacheMetrics { hits_counter: u64, misses_counter: u64, - memory_used_gauge: u64, } impl NodeCacheMetrics { @@ -109,7 +107,6 @@ impl NodeCacheMetrics { pub fn clear_counters(&mut self) { self.hits_counter = 0; self.misses_counter = 0; - // memory_used is not a counter but a gauge, so we don't reset it here. } pub fn hits(&self) -> u64 { @@ -142,18 +139,6 @@ impl NodeCacheMetrics { pub(crate) fn observe_miss(&mut self) { self.misses_counter += 1; } - - pub fn memory_used(&self) -> usize { - self.memory_used_gauge as usize - } - - pub(crate) fn add_memory_used(&mut self, bytes: usize) { - self.memory_used_gauge = self.memory_used_gauge.saturating_add(bytes as u64); - } - - pub(crate) fn subtract_memory_used(&mut self, bytes: usize) { - self.memory_used_gauge = self.memory_used_gauge.saturating_sub(bytes as u64); - } } /// A direct-mapped node cache. @@ -197,12 +182,7 @@ impl NodeCache { if self.slots[idx].0 == addr { self.metrics.observe_hit(); self.slots[idx].0 = NULL; - let result = self.slots[idx].1.take(); - if let Some(evicted_node) = &result { - self.metrics - .subtract_memory_used(evicted_node.heap_memory_used()); - } - result + self.slots[idx].1.take() } else { self.metrics.observe_miss(); None @@ -212,11 +192,6 @@ impl NodeCache { fn put(&mut self, addr: Address, node: Node) { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); - if let Some(evicted_node) = &self.slots[idx].1 { - self.metrics - .subtract_memory_used(evicted_node.heap_memory_used()); - } - self.metrics.add_memory_used(node.heap_memory_used()); self.slots[idx] = (addr, Some(node)); } @@ -224,10 +199,6 @@ impl NodeCache { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); if self.slots[idx].0 == addr { - if let Some(evicted_node) = &self.slots[idx].1 { - self.metrics - .subtract_memory_used(evicted_node.heap_memory_used()); - } self.slots[idx] = (NULL, None); } } @@ -245,7 +216,6 @@ impl NodeCache { *slot = (NULL, None); } self.metrics.clear_counters(); - self.metrics.memory_used_gauge = 0; } } @@ -427,23 +397,6 @@ where _phantom: PhantomData<(K, V)>, } -impl MemSize for BTreeMap -where - K: Storable + Ord + Clone, - V: Storable, - M: Memory, -{ - fn mem_size(&self) -> usize { - // Excludes _phantom (zero-size) and the Memory handle - // (reported separately via stable_memory_size). - self.root_addr.mem_size() - + self.version.mem_size() - + self.allocator.mem_size() - + self.length.mem_size() - + self.node_cache_memory_used() - } -} - #[derive(PartialEq, Debug)] /// The packed header size must be <= ALLOCATOR_OFFSET. struct BTreeHeader { @@ -600,10 +553,6 @@ where + std::mem::size_of::<(Address, Option>)>()) } - pub fn node_cache_memory_used(&self) -> usize { - self.cache.borrow().metrics().memory_used() - } - /// Initializes a v1 `BTreeMap`. /// /// This is exposed only in testing. @@ -3936,137 +3885,4 @@ mod test { "cached nodes should still be present" ); } - - /// Temporary test: compare node_cache_size_bytes_approx vs node_cache_memory_used - /// across different key/value types, map sizes, and cache slot counts. - #[test] - fn compare_cache_size_estimates() { - struct Row { - label: &'static str, - num_entries: u64, - cache_slots: usize, - approx: usize, - actual: usize, - } - - impl Row { - fn ratio(&self) -> f64 { - if self.actual == 0 { - f64::NAN - } else { - self.approx as f64 / self.actual as f64 - } - } - fn diff(&self) -> isize { - self.approx as isize - self.actual as isize - } - } - - fn measure( - label: &'static str, - num_entries: u64, - cache_slots: usize, - ) -> Row { - let mem = make_memory(); - let mut map: BTreeMap = BTreeMap::new(mem).with_node_cache(cache_slots); - - for i in 0..num_entries { - map.insert(K::build(i as u32), V::build(i as u32)); - } - // Warm the cache with reads. - for i in 0..num_entries { - let _ = map.get(&K::build(i as u32)); - } - - Row { - label, - num_entries, - cache_slots, - approx: map.node_cache_size_bytes_approx(), - actual: map.node_cache_memory_used(), - } - } - - let entries_counts = [1_000, 10_000, 100_000]; - let cache_slots = [32]; - - let mut rows: Vec = Vec::new(); - - for &n in &entries_counts { - for &slots in &cache_slots { - rows.push(measure::("u32, u32", n, slots)); - rows.push(measure::>("u32, Blob<20>", n, slots)); - rows.push(measure::>("u32, Blob<512>", n, slots)); - rows.push(measure::>("u32, Blob<900>", n, slots)); - rows.push(measure::, u32>("Blob<10>, u32", n, slots)); - rows.push(measure::, Blob<20>>( - "Blob<10>, Blob<20>", - n, - slots, - )); - rows.push(measure::("Vec32, u32", n, slots)); - rows.push(measure::( - "Vec32, Vec32", - n, - slots, - )); - rows.push(measure::( - "Str32, Str32", - n, - slots, - )); - } - } - - // Print the comparison table. - println!(); - println!( - "{:<18} {:>7} {:>6} {:>10} {:>10} {:>10} {:>7}", - "K, V", "entries", "slots", "approx", "actual", "diff", "ratio" - ); - println!("{}", "-".repeat(75)); - for r in &rows { - println!( - "{:<18} {:>7} {:>6} {:>10} {:>10} {:>+10} {:>7.2}", - r.label, - r.num_entries, - r.cache_slots, - r.approx, - r.actual, - r.diff(), - r.ratio(), - ); - } - println!(); - - // Summary: group by label, show min/max ratio. - println!("=== Summary by key/value type ==="); - println!( - "{:<18} {:>10} {:>10} {:>10}", - "K, V", "min ratio", "max ratio", "avg ratio" - ); - println!("{}", "-".repeat(52)); - let labels: Vec<&str> = rows - .iter() - .map(|r| r.label) - .collect::>() - .into_iter() - .collect(); - for label in &labels { - let group: Vec<&Row> = rows.iter().filter(|r| r.label == *label).collect(); - let ratios: Vec = group - .iter() - .filter(|r| r.actual > 0) - .map(|r| r.ratio()) - .collect(); - if ratios.is_empty() { - continue; - } - let min = ratios.iter().cloned().fold(f64::INFINITY, f64::min); - let max = ratios.iter().cloned().fold(f64::NEG_INFINITY, f64::max); - let avg = ratios.iter().sum::() / ratios.len() as f64; - println!("{:<18} {:>10.2} {:>10.2} {:>10.2}", label, min, max, avg); - } - println!(); - } } diff --git a/src/btreemap/allocator.rs b/src/btreemap/allocator.rs index 01e07a93..68544599 100644 --- a/src/btreemap/allocator.rs +++ b/src/btreemap/allocator.rs @@ -1,5 +1,4 @@ use crate::{ - mem_size::MemSize, read_struct, types::{Address, Bytes, NULL}, write_struct, Memory, @@ -46,17 +45,6 @@ pub struct Allocator { memory: M, } -impl MemSize for Allocator { - fn mem_size(&self) -> usize { - // Excludes `memory: M` — it's a handle to the backing store, - // not data owned by the allocator. - self.header_addr.mem_size() - + self.allocation_size.mem_size() - + self.num_allocated_chunks.mem_size() - + self.free_list_head.mem_size() - } -} - #[repr(C, packed)] #[derive(PartialEq, Debug)] struct AllocatorHeader { diff --git a/src/btreemap/node.rs b/src/btreemap/node.rs index 6c5bb0f9..90f417f2 100644 --- a/src/btreemap/node.rs +++ b/src/btreemap/node.rs @@ -1,6 +1,5 @@ use crate::{ btreemap::Allocator, - mem_size::MemSize, read_address_vec, read_struct, read_to_vec, read_u32, read_u64, storable::Storable, types::{Address, Bytes}, @@ -37,12 +36,6 @@ pub enum NodeType { Internal, } -impl MemSize for NodeType { - fn mem_size(&self) -> usize { - core::mem::size_of::() - } -} - pub type Entry = (K, Vec); pub type EntryRef<'a, K> = (&'a K, &'a [u8]); @@ -74,15 +67,6 @@ pub struct Node { } impl Node { - pub fn heap_memory_used(&self) -> usize { - self.address.mem_size() - + self.entries.mem_size() - + self.children.mem_size() - + self.node_type.mem_size() - + self.version.mem_size() - + self.overflows.mem_size() - } - /// Loads a node from memory at the given address. pub fn load(address: Address, page_size: PageSize, memory: &M) -> Self { // Load the header to determine which version the node is, then load the node accordingly. @@ -510,7 +494,7 @@ impl NodeHeader { /// A lazily-loaded object, which can be either an immediate value or a deferred reference. #[derive(Debug)] -enum LazyObject { +enum LazyObject { ByVal(T), ByRef { offset: Bytes, @@ -519,37 +503,7 @@ enum LazyObject { }, } -impl LazyObject { - /// Reports the serialized data size for loaded values, or just the - /// fixed fields for unloaded references. Uses `Storable::to_bytes()` - /// to measure ByVal — avoids requiring `T: MemSize`. - fn mem_size(&self) -> usize { - match self { - LazyObject::ByVal(value) => { - if T::BOUND.is_fixed_size() { - T::BOUND.max_size() as usize - } else { - value.to_bytes().len() - } - } - LazyObject::ByRef { - offset, - size, - loaded, - } => { - offset.mem_size() - + size.mem_size() - + if loaded.get().is_some() { - *size as usize - } else { - 0 - } - } - } - } -} - -impl LazyObject { +impl LazyObject { #[inline(always)] pub fn by_value(value: T) -> Self { LazyObject::ByVal(value) @@ -594,12 +548,6 @@ type Blob = Vec; #[derive(Debug)] struct LazyValue(LazyObject); -impl MemSize for LazyValue { - fn mem_size(&self) -> usize { - self.0.mem_size() - } -} - impl LazyValue { #[inline(always)] pub fn by_value(value: Blob) -> Self { @@ -641,15 +589,9 @@ impl LazyValue { } #[derive(Debug)] -struct LazyKey(LazyObject); - -impl MemSize for LazyKey { - fn mem_size(&self) -> usize { - self.0.mem_size() - } -} +struct LazyKey(LazyObject); -impl LazyKey { +impl LazyKey { #[inline(always)] pub fn by_value(value: K) -> Self { Self(LazyObject::by_value(value)) @@ -671,15 +613,6 @@ impl LazyKey { } } -impl MemSize for Version { - fn mem_size(&self) -> usize { - match self { - Version::V1(page_size) => page_size.mem_size(), - Version::V2(page_size) => page_size.mem_size(), - } - } -} - /// Stores version-specific data. #[derive(Debug, PartialEq, Copy, Clone, Eq)] pub enum Version { @@ -711,15 +644,6 @@ pub enum PageSize { Value(u32), } -impl MemSize for PageSize { - fn mem_size(&self) -> usize { - match self { - Self::Value(page_size) => page_size.mem_size(), - Self::Derived(derived) => derived.mem_size(), - } - } -} - impl PageSize { pub fn get(&self) -> u32 { match self { @@ -742,9 +666,3 @@ impl DerivedPageSize { v1::size_v1(self.max_key_size, self.max_value_size).get() as u32 } } - -impl MemSize for DerivedPageSize { - fn mem_size(&self) -> usize { - self.max_key_size.mem_size() + self.max_value_size.mem_size() - } -} diff --git a/src/btreemap/node/tests.rs b/src/btreemap/node/tests.rs index 622dac1e..ff1158ca 100644 --- a/src/btreemap/node/tests.rs +++ b/src/btreemap/node/tests.rs @@ -309,70 +309,3 @@ fn can_call_node_value_multiple_times_on_same_index() { let value2 = node.value(0, &mem); assert_eq!(value1, value2); } - -mod mem_size_tests { - use super::*; - use crate::mem_size::MemSize; - - #[test] - fn lazy_value_by_value() { - // ByVal with a 5-byte blob: reports the serialized length. - let val = LazyValue::by_value(vec![1, 2, 3, 4, 5]); - assert_eq!(val.mem_size(), 5); - } - - #[test] - fn lazy_value_by_ref_not_loaded() { - // ByRef before loading: offset (8) + size (4) = 12, no data. - let val = LazyValue::by_ref(Bytes::new(100), 42); - assert_eq!(val.mem_size(), 8 + 4); - } - - #[test] - fn lazy_value_by_ref_loaded() { - // ByRef after loading: offset (8) + size (4) + data (42) = 54. - let val = LazyValue::by_ref(Bytes::new(100), 42); - val.get_or_load(|_, size| vec![0u8; size as usize]); - assert_eq!(val.mem_size(), 8 + 4 + 42); - } - - #[test] - fn lazy_key_u32_by_value() { - // u32 serializes to 4 bytes. - let key = LazyKey::::by_value(42); - assert_eq!(key.mem_size(), 4); - } - - #[test] - fn lazy_key_u32_by_ref_not_loaded() { - let key = LazyKey::::by_ref(Bytes::new(100), 4); - assert_eq!(key.mem_size(), 8 + 4); - } - - #[test] - fn lazy_key_u32_by_ref_loaded() { - let key = LazyKey::::by_ref(Bytes::new(100), 4); - key.get_or_load(|_, _| 42u32); - assert_eq!(key.mem_size(), 8 + 4 + 4); - } - - #[test] - fn lazy_key_vec_by_value() { - // Vec key with 10 bytes of data. - let key = LazyKey::>::by_value(vec![0u8; 10]); - assert_eq!(key.mem_size(), 10); - } - - #[test] - fn lazy_key_vec_by_ref_not_loaded() { - let key = LazyKey::>::by_ref(Bytes::new(100), 10); - assert_eq!(key.mem_size(), 8 + 4); - } - - #[test] - fn lazy_key_vec_by_ref_loaded() { - let key = LazyKey::>::by_ref(Bytes::new(100), 10); - key.get_or_load(|_, size| vec![0u8; size as usize]); - assert_eq!(key.mem_size(), 8 + 4 + 10); - } -} diff --git a/src/lib.rs b/src/lib.rs index 8a76a4e4..ce433676 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,6 @@ pub mod file_mem; #[cfg(target_arch = "wasm32")] mod ic0_memory; // Memory API for canisters. pub mod log; -mod mem_size; pub mod memory_manager; pub mod min_heap; pub mod reader; diff --git a/src/mem_size.rs b/src/mem_size.rs deleted file mode 100644 index 06d23dd1..00000000 --- a/src/mem_size.rs +++ /dev/null @@ -1,222 +0,0 @@ -/// Estimates the in-process memory footprint of a value in bytes, -/// covering both inline (stack) and heap-allocated data. -/// -/// Reports the logical data size, not the physical layout. Alignment -/// padding and allocator overhead are intentionally excluded — the -/// goal is to measure how much memory the data itself occupies. -/// -/// ## Performance -/// -/// Primitives, strings, and fixed-size containers are always O(1). -/// -/// Vectors of types with a known `ELEMENT_SIZE` are also O(1), -/// using simple multiplication instead of traversal. -/// -/// Types with a variable or unknown element size fall back to -/// per-element iteration, which is O(n). Implement `ELEMENT_SIZE` -/// for your fixed-size types to stay on the fast path. -pub trait MemSize { - /// Fixed per-element size, if known at compile time. - /// When `Some`, `Vec::mem_size()` uses `len * ELEMENT_SIZE` (O(1)) - /// instead of iterating (O(n)). Defaults to `None`. - const ELEMENT_SIZE: Option = None; - - /// Returns the estimated memory footprint of this value in bytes. - fn mem_size(&self) -> usize; -} - -impl MemSize for () { - #[inline] - fn mem_size(&self) -> usize { - 0 - } -} - -impl MemSize for u8 { - const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); - - #[inline] - fn mem_size(&self) -> usize { - std::mem::size_of::() - } -} - -impl MemSize for [u8] { - #[inline] - fn mem_size(&self) -> usize { - std::mem::size_of_val(self) - } -} - -impl MemSize for u32 { - const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); - - #[inline] - fn mem_size(&self) -> usize { - std::mem::size_of::() - } -} - -impl MemSize for u64 { - const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); - - #[inline] - fn mem_size(&self) -> usize { - std::mem::size_of::() - } -} - -impl MemSize for &str { - #[inline] - fn mem_size(&self) -> usize { - self.as_bytes().mem_size() - } -} - -impl MemSize for Vec { - #[inline] - fn mem_size(&self) -> usize { - let elements_size = match T::ELEMENT_SIZE { - // For fixed-size elements, the allocator reserves capacity * element_size bytes. - Some(el_size) => self.capacity() * el_size, - // For variable-size elements, we can only measure initialized elements - // plus the slack from capacity - len (using size_of::() per slack slot). - None => { - self.iter().map(|x| x.mem_size()).sum::() - + (self.capacity() - self.len()) * std::mem::size_of::() - } - }; - std::mem::size_of::() + elements_size - } -} - -impl MemSize for (A, B) { - #[inline] - fn mem_size(&self) -> usize { - self.0.mem_size() + self.1.mem_size() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_mem_size_unit() { - assert_eq!(().mem_size(), 0); - } - - #[test] - fn test_mem_size_u8() { - assert_eq!(0_u8.mem_size(), 1); - assert_eq!(42_u8.mem_size(), 1); - } - - #[test] - fn test_mem_size_u8_slice() { - let a: [u8; 0] = []; - assert_eq!(a.mem_size(), 0); - assert_eq!([1_u8].mem_size(), 1); - assert_eq!([1_u8, 2_u8].mem_size(), 2); - } - - #[test] - fn test_mem_size_u32() { - assert_eq!(0_u32.mem_size(), 4); - assert_eq!(42_u32.mem_size(), 4); - } - - #[test] - fn test_mem_size_u64() { - assert_eq!(0_u64.mem_size(), 8); - assert_eq!(42_u64.mem_size(), 8); - } - - #[test] - fn test_mem_size_u8_vec() { - let base = std::mem::size_of::>(); - assert_eq!(Vec::::from([]).mem_size(), base); - assert_eq!(Vec::::from([1]).mem_size(), base + 1); - assert_eq!(Vec::::from([1, 2]).mem_size(), base + 2); - } - - #[test] - fn test_mem_size_str() { - assert_eq!("a".mem_size(), 1); - assert_eq!("ab".mem_size(), 2); - } - - #[test] - fn test_mem_size_vec_with_element_size() { - // Vec uses the ELEMENT_SIZE fast path (Some(4)). - let base = std::mem::size_of::>(); - assert_eq!(Vec::::new().mem_size(), base); - assert_eq!(vec![1_u32].mem_size(), base + 4); - assert_eq!(vec![1_u32, 2, 3].mem_size(), base + 12); - } - - #[test] - fn test_mem_size_vec_without_element_size() { - type Blob = Vec; - // Vec has ELEMENT_SIZE = None, falls back to per-element iteration. - let base = std::mem::size_of::>(); - let blob_base = std::mem::size_of::(); - assert_eq!(Vec::::new().mem_size(), base); - // Each Blob reports size_of::() + content_len. - assert_eq!(vec![Blob::from([1, 2])].mem_size(), base + blob_base + 2); - assert_eq!( - vec![Blob::from([1]), Blob::from([2, 3])].mem_size(), - base + 2 * blob_base + 3 - ); - } - - #[test] - fn test_mem_size_tuple() { - // Measures logical data size, not physical layout. - // (u32, u64) = 4 + 8 = 12 bytes (padding excluded). - assert_eq!((1_u32, 2_u64).mem_size(), 4 + 8); - } - - #[test] - fn test_mem_size_vec_measures_capacity_fixed_size() { - // Vec has ELEMENT_SIZE = Some(4), so capacity is measured directly. - let base = std::mem::size_of::>(); - let mut v = Vec::::with_capacity(10); - // Empty but capacity = 10 → 10 * 4 = 40 bytes of heap. - assert_eq!(v.mem_size(), base + 10 * 4); - - v.push(1); - v.push(2); - // len = 2, capacity = 10 → still 10 * 4 = 40. - assert_eq!(v.len(), 2); - assert_eq!(v.capacity(), 10); - assert_eq!(v.mem_size(), base + 10 * 4); - } - - #[test] - fn test_mem_size_vec_measures_capacity_variable_size() { - // Vec> has ELEMENT_SIZE = None → per-element iteration + slack. - type Blob = Vec; - let base = std::mem::size_of::>(); - let blob_base = std::mem::size_of::(); - - let mut v = Vec::::with_capacity(5); - // Empty, capacity = 5 → 5 slack slots × size_of::(). - assert_eq!(v.mem_size(), base + 5 * blob_base); - - v.push(Blob::from([1, 2, 3])); - // len = 1 (blob_base + 3), slack = 4 × blob_base. - assert_eq!(v.len(), 1); - assert_eq!(v.capacity(), 5); - assert_eq!(v.mem_size(), base + (blob_base + 3) + 4 * blob_base); - } - - #[test] - fn test_element_size_constants() { - assert_eq!(::ELEMENT_SIZE, Some(1)); - assert_eq!(::ELEMENT_SIZE, Some(4)); - assert_eq!(::ELEMENT_SIZE, Some(8)); - // Vec has no fixed element size. - assert_eq!( as MemSize>::ELEMENT_SIZE, None); - } -} diff --git a/src/types.rs b/src/types.rs index 3a3aacc9..0c9bbf7f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,3 @@ -use crate::mem_size::MemSize; use core::ops::{Add, AddAssign, Div, Mul, Rem, Sub, SubAssign}; pub const NULL: Address = Address(0); @@ -54,16 +53,6 @@ impl AddAssign for Address { } } -impl MemSize for Address { - const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); - - #[inline] - fn mem_size(&self) -> usize { - let val = self.0; - val.mem_size() - } -} - #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Ord, Eq)] pub struct Bytes(u64); @@ -151,16 +140,6 @@ impl SubAssign for Bytes { } } -impl MemSize for Bytes { - const ELEMENT_SIZE: Option = Some(std::mem::size_of::()); - - #[inline] - fn mem_size(&self) -> usize { - let val = self.0; - val.mem_size() - } -} - impl Bytes { pub const fn new(val: u64) -> Self { Self(val) From cb7594d1dbc08ad5b4ee87106afc77e34e1ab71b Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 21:17:30 +0200 Subject: [PATCH 27/42] prefer low depth nodes to cache over high depth --- benchmarks/btreemap/canbench_results.yml | 204 +++++++++++------------ src/btreemap.rs | 86 +++++++--- 2 files changed, 165 insertions(+), 125 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 2bbb20fc..fb1e2a85 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,644 +2,644 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142223444 + instructions: 142223662 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 292251248 + instructions: 292685771 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 4278657425 + instructions: 4279092806 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 821052288 + instructions: 821487537 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 293333653 + instructions: 293769551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1310779571 + instructions: 1311214897 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 327147005 + instructions: 327582551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 324648699 + instructions: 325084223 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 324637021 + instructions: 325072732 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 245659274 + instructions: 203251272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 317500664 + instructions: 317936089 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 322854230 + instructions: 323289930 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 327087164 + instructions: 327522622 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 320899527 + instructions: 321334996 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 320852457 + instructions: 321287926 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 323449943 + instructions: 323885313 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 322825815 + instructions: 323261460 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 244885342 + instructions: 245206191 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 2282455141 + instructions: 2282890401 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 401240082 + instructions: 401675595 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 265723252 + instructions: 266158160 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 346737080 + instructions: 347172197 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 218655247 + instructions: 219090518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 221776623 + instructions: 222211872 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 162855054 + instructions: 137474388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 218655247 + instructions: 219090518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 373755909 + instructions: 374190443 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1851466971 + instructions: 1851902352 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 559772809 + instructions: 560208058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 432384968 + instructions: 432820855 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 891524104 + instructions: 891959419 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 357596127 + instructions: 358031651 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 485955886 + instructions: 486391410 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 413454913 + instructions: 413890624 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 290399668 + instructions: 252552012 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 365307336 + instructions: 365742772 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 431609647 + instructions: 432045347 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 354890140 + instructions: 355325587 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 367606496 + instructions: 368041965 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 450614263 + instructions: 451049732 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 401728737 + instructions: 402164107 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 368047115 + instructions: 368482760 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 397489879 + instructions: 397810717 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1227992746 + instructions: 1228428006 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 494053293 + instructions: 494488806 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 391070102 + instructions: 391504955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388598599 + instructions: 388598817 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 296801695 + instructions: 297236218 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 4283690935 + instructions: 4284126316 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 826092151 + instructions: 826527400 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 298291372 + instructions: 298727270 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 1315800882 + instructions: 1316236208 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 328847079 + instructions: 329282625 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 335271701 + instructions: 335707225 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 329566744 + instructions: 330002455 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 250318547 + instructions: 207848708 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 321740958 + instructions: 322176383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 328441206 + instructions: 328876906 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 331475995 + instructions: 331911453 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 324621068 + instructions: 325056537 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 328439008 + instructions: 328874477 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 328010597 + instructions: 328445967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 326857889 + instructions: 327293534 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 249975580 + instructions: 250296429 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 2287494049 + instructions: 2287929309 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 406289352 + instructions: 406724865 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 270843671 + instructions: 271278579 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 348608271 + instructions: 349043388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 222816150 + instructions: 223251421 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 226338411 + instructions: 226773660 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 167507739 + instructions: 142137067 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 223120174 + instructions: 223555445 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 378534019 + instructions: 378968553 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1861977573 + instructions: 1862412954 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 567577313 + instructions: 568012562 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 438717716 + instructions: 439153603 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 899476068 + instructions: 899911383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 359444813 + instructions: 359880337 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 509235657 + instructions: 509671181 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 420014588 + instructions: 420450299 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 296898606 + instructions: 259076731 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 369966461 + instructions: 370401897 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 444635792 + instructions: 445071492 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 359708945 + instructions: 360144392 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 372145902 + instructions: 372581371 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 467504237 + instructions: 467939706 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 406919388 + instructions: 407354758 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 372626585 + instructions: 373062230 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 403559390 + instructions: 403880228 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1235850271 + instructions: 1236285531 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501058182 + instructions: 501493695 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 397241661 + instructions: 397676514 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -968,70 +968,70 @@ benches: btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 2350826568 + instructions: 2351261894 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 277975211 + instructions: 278410240 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 281883487 + instructions: 282318736 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 360784676 + instructions: 361219705 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1259378621 + instructions: 1259813947 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 2357976936 + instructions: 2358412262 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 286479343 + instructions: 286914372 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 287236190 + instructions: 287671439 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 375337462 + instructions: 375772491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1267494745 + instructions: 1267930071 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 4164f3de..cac3a8d1 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -141,15 +141,38 @@ impl NodeCacheMetrics { } } +/// A single slot in the direct-mapped node cache. +struct CacheSlot { + /// The stable-memory address of the cached node. + address: Address, + /// The cached node, or `None` if the slot is empty. + node: Option>, + /// Distance from the tree root (root = 0). Used to resolve + /// collisions: shallower nodes are kept over deeper ones. + depth: u8, +} + +impl CacheSlot { + fn empty() -> Self { + Self { + address: NULL, + node: None, + depth: 0, + } + } +} + /// A direct-mapped node cache. /// /// Each slot is indexed by `(node_address / page_size) % num_slots`. /// Collision = eviction (no LRU tracking needed). /// /// Upper tree levels (root, depth-1) naturally stay cached because their -/// addresses are stable and map to distinct slots. +/// addresses are stable and map to distinct slots. The depth-aware +/// eviction policy further guarantees that a deeper node can never +/// displace a shallower one from a shared slot. struct NodeCache { - slots: Vec<(Address, Option>)>, + slots: Vec>, page_size: u32, metrics: NodeCacheMetrics, } @@ -158,7 +181,7 @@ impl NodeCache { fn new(page_size: u32, num_slots: usize) -> Self { let mut slots = Vec::with_capacity(num_slots); for _ in 0..num_slots { - slots.push((NULL, None)); + slots.push(CacheSlot::empty()); } Self { slots, @@ -179,27 +202,40 @@ impl NodeCache { fn take(&mut self, addr: Address) -> Option> { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); - if self.slots[idx].0 == addr { + let slot = &mut self.slots[idx]; + if slot.address == addr { self.metrics.observe_hit(); - self.slots[idx].0 = NULL; - self.slots[idx].1.take() + slot.address = NULL; + slot.node.take() } else { self.metrics.observe_miss(); None } } - fn put(&mut self, addr: Address, node: Node) { + fn put(&mut self, addr: Address, node: Node, depth: u8) { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); - self.slots[idx] = (addr, Some(node)); + let slot = &mut self.slots[idx]; + // Only evict an existing cached node if the new node is at the + // same depth or closer to the root (lower depth value). + // This keeps upper-level nodes cached even when a deeper node + // maps to the same slot. + if slot.node.is_none() || depth <= slot.depth { + *slot = CacheSlot { + address: addr, + node: Some(node), + depth, + }; + } } fn invalidate(&mut self, addr: Address) { debug_assert!(self.is_enabled()); let idx = self.slot_index(addr); - if self.slots[idx].0 == addr { - self.slots[idx] = (NULL, None); + let slot = &mut self.slots[idx]; + if slot.address == addr { + *slot = CacheSlot::empty(); } } @@ -213,7 +249,7 @@ impl NodeCache { fn clear(&mut self) { for slot in &mut self.slots { - *slot = (NULL, None); + *slot = CacheSlot::empty(); } self.metrics.clear_counters(); } @@ -550,7 +586,7 @@ where pub fn node_cache_size_bytes_approx(&self) -> usize { self.cache_num_slots * (self.version.page_size().get() as usize - + std::mem::size_of::<(Address, Option>)>()) + + std::mem::size_of::>()) } /// Initializes a v1 `BTreeMap`. @@ -934,7 +970,7 @@ where if self.root_addr == NULL { return None; } - self.traverse(self.root_addr, key, |node, idx| { + self.traverse(self.root_addr, 0, key, |node, idx| { node.read_value_uncached(idx, self.memory()) }) .map(Cow::Owned) @@ -943,13 +979,14 @@ where /// Returns true if the key exists. pub fn contains_key(&self, key: &K) -> bool { - self.root_addr != NULL && self.traverse(self.root_addr, key, |_, _| ()).is_some() + self.root_addr != NULL && self.traverse(self.root_addr, 0, key, |_, _| ()).is_some() } /// Recursively traverses from `node_addr`, invoking `f` if `key` is found. Stops at a leaf if not. /// /// Uses the node cache: nodes are taken out before use and returned after. - fn traverse(&self, node_addr: Address, key: &K, f: F) -> Option + /// `depth` is the distance from the root (root = 0). + fn traverse(&self, node_addr: Address, depth: u8, key: &K, f: F) -> Option where F: Fn(&Node, usize) -> R, { @@ -957,18 +994,18 @@ where match node.search(key, self.memory()) { Ok(idx) => { let result = f(&node, idx); // Key found: apply `f`. - self.return_node(node); + self.return_node(node, depth); Some(result) } Err(idx) => match node.node_type() { NodeType::Leaf => { - self.return_node(node); + self.return_node(node, depth); None // At a leaf: key not present. } NodeType::Internal => { let child_addr = node.child(idx); - self.return_node(node); - self.traverse(child_addr, key, f) // Continue search in child. + self.return_node(node, depth); + self.traverse(child_addr, depth.saturating_add(1), key, f) } }, } @@ -1069,7 +1106,7 @@ where } let root = self.take_or_load_node(self.root_addr); let (k, encoded_v) = self.get_min_entry(&root); - self.return_node(root); + self.return_node(root, 0); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1081,7 +1118,7 @@ where } let root = self.take_or_load_node(self.root_addr); let (k, encoded_v) = self.get_max_entry(&root); - self.return_node(root); + self.return_node(root, 0); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -1665,10 +1702,13 @@ where } /// Returns a node to the cache after use on a read path. + /// + /// `depth` is the distance from the root (root = 0). The cache uses + /// this to prefer keeping shallower nodes on slot collisions. #[inline(always)] - fn return_node(&self, node: Node) { + fn return_node(&self, node: Node, depth: u8) { if self.cache_num_slots > 0 { - self.cache.borrow_mut().put(node.address(), node); + self.cache.borrow_mut().put(node.address(), node, depth); } } From 31eee53b22bb50ca20ae31a8135daf84042be8d7 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Sun, 29 Mar 2026 21:19:58 +0200 Subject: [PATCH 28/42] fmt --- src/btreemap.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index cac3a8d1..c3fb0125 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -585,8 +585,7 @@ where /// For exact heap profiling, use platform-specific tools. pub fn node_cache_size_bytes_approx(&self) -> usize { self.cache_num_slots - * (self.version.page_size().get() as usize - + std::mem::size_of::>()) + * (self.version.page_size().get() as usize + std::mem::size_of::>()) } /// Initializes a v1 `BTreeMap`. From 58ae4b3a5fe5ae4c18c5ab5705ae984aa68c2270 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 08:22:34 +0200 Subject: [PATCH 29/42] mv node_cache.rs --- src/btreemap.rs | 168 +----------------------------------- src/btreemap/node_cache.rs | 172 +++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 164 deletions(-) create mode 100644 src/btreemap/node_cache.rs diff --git a/src/btreemap.rs b/src/btreemap.rs index c3fb0125..9b675ca6 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -51,6 +51,7 @@ mod allocator; mod iter; mod node; +mod node_cache; use crate::btreemap::iter::{IterInternal, KeysIter, ValuesIter}; use crate::{ storable::Bound as StorableBound, @@ -60,6 +61,8 @@ use crate::{ use allocator::Allocator; pub use iter::Iter; use node::{DerivedPageSize, Entry, Node, NodeType, PageSize, Version}; +use node_cache::NodeCache; +pub use node_cache::NodeCacheMetrics; use std::borrow::Cow; use std::cell::RefCell; use std::marker::PhantomData; @@ -91,169 +94,6 @@ const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; /// See [`BTreeMap::with_node_cache`] for guidance on choosing a size. const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; -/// Node-cache performance metrics. -#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] -pub struct NodeCacheMetrics { - hits_counter: u64, - misses_counter: u64, -} - -impl NodeCacheMetrics { - pub fn new() -> Self { - Self::default() - } - - /// Resets all counters to zero. - pub fn clear_counters(&mut self) { - self.hits_counter = 0; - self.misses_counter = 0; - } - - pub fn hits(&self) -> u64 { - self.hits_counter - } - - pub fn misses(&self) -> u64 { - self.misses_counter - } - - pub fn total(&self) -> u64 { - self.hits_counter + self.misses_counter - } - - /// Returns the hit ratio as a value between 0.0 and 1.0. - /// Returns 0.0 if no lookups have been performed. - pub fn hit_ratio(&self) -> f64 { - let total = self.total(); - if total == 0 { - 0.0 - } else { - self.hits_counter as f64 / total as f64 - } - } - - pub(crate) fn observe_hit(&mut self) { - self.hits_counter += 1; - } - - pub(crate) fn observe_miss(&mut self) { - self.misses_counter += 1; - } -} - -/// A single slot in the direct-mapped node cache. -struct CacheSlot { - /// The stable-memory address of the cached node. - address: Address, - /// The cached node, or `None` if the slot is empty. - node: Option>, - /// Distance from the tree root (root = 0). Used to resolve - /// collisions: shallower nodes are kept over deeper ones. - depth: u8, -} - -impl CacheSlot { - fn empty() -> Self { - Self { - address: NULL, - node: None, - depth: 0, - } - } -} - -/// A direct-mapped node cache. -/// -/// Each slot is indexed by `(node_address / page_size) % num_slots`. -/// Collision = eviction (no LRU tracking needed). -/// -/// Upper tree levels (root, depth-1) naturally stay cached because their -/// addresses are stable and map to distinct slots. The depth-aware -/// eviction policy further guarantees that a deeper node can never -/// displace a shallower one from a shared slot. -struct NodeCache { - slots: Vec>, - page_size: u32, - metrics: NodeCacheMetrics, -} - -impl NodeCache { - fn new(page_size: u32, num_slots: usize) -> Self { - let mut slots = Vec::with_capacity(num_slots); - for _ in 0..num_slots { - slots.push(CacheSlot::empty()); - } - Self { - slots, - page_size, - metrics: NodeCacheMetrics::new(), - } - } - - fn is_enabled(&self) -> bool { - !self.slots.is_empty() - } - - fn slot_index(&self, addr: Address) -> usize { - debug_assert!(self.is_enabled()); - (addr.get() / self.page_size as u64) as usize % self.slots.len() - } - - fn take(&mut self, addr: Address) -> Option> { - debug_assert!(self.is_enabled()); - let idx = self.slot_index(addr); - let slot = &mut self.slots[idx]; - if slot.address == addr { - self.metrics.observe_hit(); - slot.address = NULL; - slot.node.take() - } else { - self.metrics.observe_miss(); - None - } - } - - fn put(&mut self, addr: Address, node: Node, depth: u8) { - debug_assert!(self.is_enabled()); - let idx = self.slot_index(addr); - let slot = &mut self.slots[idx]; - // Only evict an existing cached node if the new node is at the - // same depth or closer to the root (lower depth value). - // This keeps upper-level nodes cached even when a deeper node - // maps to the same slot. - if slot.node.is_none() || depth <= slot.depth { - *slot = CacheSlot { - address: addr, - node: Some(node), - depth, - }; - } - } - - fn invalidate(&mut self, addr: Address) { - debug_assert!(self.is_enabled()); - let idx = self.slot_index(addr); - let slot = &mut self.slots[idx]; - if slot.address == addr { - *slot = CacheSlot::empty(); - } - } - - fn metrics(&self) -> NodeCacheMetrics { - self.metrics - } - - fn clear_metrics(&mut self) { - self.metrics.clear_counters(); - } - - fn clear(&mut self) { - for slot in &mut self.slots { - *slot = CacheSlot::empty(); - } - self.metrics.clear_counters(); - } -} /// A B-Tree map implementation that stores its data into a designated memory. /// @@ -585,7 +425,7 @@ where /// For exact heap profiling, use platform-specific tools. pub fn node_cache_size_bytes_approx(&self) -> usize { self.cache_num_slots - * (self.version.page_size().get() as usize + std::mem::size_of::>()) + * (self.version.page_size().get() as usize + NodeCache::::slot_size()) } /// Initializes a v1 `BTreeMap`. diff --git a/src/btreemap/node_cache.rs b/src/btreemap/node_cache.rs new file mode 100644 index 00000000..c0fe4341 --- /dev/null +++ b/src/btreemap/node_cache.rs @@ -0,0 +1,172 @@ +use crate::types::{Address, NULL}; +use crate::Storable; + +use super::node::Node; + +/// Node-cache performance metrics. +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub struct NodeCacheMetrics { + hits_counter: u64, + misses_counter: u64, +} + +impl NodeCacheMetrics { + pub fn new() -> Self { + Self::default() + } + + /// Resets all counters to zero. + pub fn clear_counters(&mut self) { + self.hits_counter = 0; + self.misses_counter = 0; + } + + pub fn hits(&self) -> u64 { + self.hits_counter + } + + pub fn misses(&self) -> u64 { + self.misses_counter + } + + pub fn total(&self) -> u64 { + self.hits_counter + self.misses_counter + } + + /// Returns the hit ratio as a value between 0.0 and 1.0. + /// Returns 0.0 if no lookups have been performed. + pub fn hit_ratio(&self) -> f64 { + let total = self.total(); + if total == 0 { + 0.0 + } else { + self.hits_counter as f64 / total as f64 + } + } + + fn observe_hit(&mut self) { + self.hits_counter += 1; + } + + fn observe_miss(&mut self) { + self.misses_counter += 1; + } +} + +/// A single slot in the direct-mapped node cache. +struct CacheSlot { + /// The stable-memory address of the cached node. + address: Address, + /// The cached node, or `None` if the slot is empty. + node: Option>, + /// Distance from the tree root (root = 0). Used to resolve + /// collisions: shallower nodes are kept over deeper ones. + depth: u8, +} + +impl CacheSlot { + fn empty() -> Self { + Self { + address: NULL, + node: None, + depth: 0, + } + } +} + +/// A direct-mapped node cache. +/// +/// Each slot is indexed by `(node_address / page_size) % num_slots`. +/// Collision = eviction (no LRU tracking needed). +/// +/// Upper tree levels (root, depth-1) naturally stay cached because their +/// addresses are stable and map to distinct slots. The depth-aware +/// eviction policy further guarantees that a deeper node can never +/// displace a shallower one from a shared slot. +pub(super) struct NodeCache { + slots: Vec>, + page_size: u32, + metrics: NodeCacheMetrics, +} + +impl NodeCache { + pub(super) fn new(page_size: u32, num_slots: usize) -> Self { + let mut slots = Vec::with_capacity(num_slots); + for _ in 0..num_slots { + slots.push(CacheSlot::empty()); + } + Self { + slots, + page_size, + metrics: NodeCacheMetrics::new(), + } + } + + pub(super) fn is_enabled(&self) -> bool { + !self.slots.is_empty() + } + + fn slot_index(&self, addr: Address) -> usize { + debug_assert!(self.is_enabled()); + (addr.get() / self.page_size as u64) as usize % self.slots.len() + } + + pub(super) fn take(&mut self, addr: Address) -> Option> { + debug_assert!(self.is_enabled()); + let idx = self.slot_index(addr); + let slot = &mut self.slots[idx]; + if slot.address == addr { + self.metrics.observe_hit(); + slot.address = NULL; + slot.node.take() + } else { + self.metrics.observe_miss(); + None + } + } + + pub(super) fn put(&mut self, addr: Address, node: Node, depth: u8) { + debug_assert!(self.is_enabled()); + let idx = self.slot_index(addr); + let slot = &mut self.slots[idx]; + // Only evict an existing cached node if the new node is at the + // same depth or closer to the root (lower depth value). + // This keeps upper-level nodes cached even when a deeper node + // maps to the same slot. + if slot.node.is_none() || depth <= slot.depth { + *slot = CacheSlot { + address: addr, + node: Some(node), + depth, + }; + } + } + + pub(super) fn invalidate(&mut self, addr: Address) { + debug_assert!(self.is_enabled()); + let idx = self.slot_index(addr); + let slot = &mut self.slots[idx]; + if slot.address == addr { + *slot = CacheSlot::empty(); + } + } + + pub(super) fn metrics(&self) -> NodeCacheMetrics { + self.metrics + } + + pub(super) fn clear_metrics(&mut self) { + self.metrics.clear_counters(); + } + + pub(super) fn clear(&mut self) { + for slot in &mut self.slots { + *slot = CacheSlot::empty(); + } + self.metrics.clear_counters(); + } + + pub(super) fn slot_size() -> usize { + std::mem::size_of::>() + } +} From a0c3f92a0c0019e9775564de1e394c035d3a66a5 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 08:36:06 +0200 Subject: [PATCH 30/42] node_cache_size --- src/btreemap.rs | 6 +++++- src/btreemap/node_cache.rs | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 9b675ca6..bb03cb47 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -94,7 +94,6 @@ const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; /// See [`BTreeMap::with_node_cache`] for guidance on choosing a size. const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; - /// A B-Tree map implementation that stores its data into a designated memory. /// /// # Memory Implementations @@ -372,6 +371,11 @@ where *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); } + /// Returns the number of slots in the node cache. + pub fn node_cache_size(&self) -> usize { + self.cache.borrow().num_slots() + } + /// Evicts all cached nodes and resets metrics, keeping the /// current cache capacity. pub fn node_cache_clear(&mut self) { diff --git a/src/btreemap/node_cache.rs b/src/btreemap/node_cache.rs index c0fe4341..a1e0db9f 100644 --- a/src/btreemap/node_cache.rs +++ b/src/btreemap/node_cache.rs @@ -106,6 +106,21 @@ impl NodeCache { !self.slots.is_empty() } + pub(super) fn num_slots(&self) -> usize { + self.slots.len() + } + + pub(super) fn clear(&mut self) { + for slot in &mut self.slots { + *slot = CacheSlot::empty(); + } + self.metrics.clear_counters(); + } + + pub(super) fn slot_size() -> usize { + std::mem::size_of::>() + } + fn slot_index(&self, addr: Address) -> usize { debug_assert!(self.is_enabled()); (addr.get() / self.page_size as u64) as usize % self.slots.len() @@ -158,15 +173,4 @@ impl NodeCache { pub(super) fn clear_metrics(&mut self) { self.metrics.clear_counters(); } - - pub(super) fn clear(&mut self) { - for slot in &mut self.slots { - *slot = CacheSlot::empty(); - } - self.metrics.clear_counters(); - } - - pub(super) fn slot_size() -> usize { - std::mem::size_of::>() - } } From 0a63c0358834601b883dff34a00a85836ad991f3 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 08:50:32 +0200 Subject: [PATCH 31/42] update doc comments --- src/btreemap.rs | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index bb03cb47..084e2d2d 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -313,21 +313,17 @@ where /// /// The cache is a direct-mapped cache that keeps frequently accessed /// B-tree nodes in heap memory to avoid repeated stable-memory reads. - /// Each slot can hold one deserialized node; collisions evict the - /// previous occupant. + /// Each slot can hold one deserialized node; on collision, shallower + /// nodes (closer to the root) are kept over deeper ones. /// /// Pass `0` to disable the cache (the default). /// - /// A good starting point is **32** — the smallest value that fits the - /// top 2 levels of the B-tree (root + its ~11 children) with no - /// collisions, giving 2 cache hits per operation regardless of tree - /// size. - /// - /// # Note on cache size - /// - /// Any value is accepted, but future cache implementations (e.g. - /// set-associative) may require power-of-two sizes for efficient - /// indexing. Prefer powers of two for forward compatibility. + /// The top 2 levels of the tree contain 13 nodes (1 root + up to + /// 12 children). **16** slots is the smallest power of two that + /// covers them, but a direct-mapped cache is sensitive to address + /// collisions, so **32** is a safer default that leaves headroom + /// and typically gives 2 cache hits per operation regardless of + /// tree size. Prefer powers of two for efficient slot indexing. /// /// # Examples /// @@ -371,7 +367,9 @@ where *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); } - /// Returns the number of slots in the node cache. + /// Returns the current number of slots in the node cache. + /// + /// Returns `0` when the cache is disabled. pub fn node_cache_size(&self) -> usize { self.cache.borrow().num_slots() } @@ -408,25 +406,11 @@ where self.cache.borrow().metrics() } - /// Returns an estimate of the cache's heap usage in bytes. - /// - /// The estimate is `num_slots * (page_size + per_slot_overhead)`. - /// Actual usage depends on key size and access patterns: - /// - /// - **Small keys** (≤ 16 bytes, e.g. `u64`): the estimate is roughly - /// **2×** actual usage, because cached nodes only hold compact keys - /// and child pointers — values are not cached. - /// - **Large keys** (> 16 bytes, e.g. 100-byte `String`): keys are - /// lazily loaded into an `OnceCell` during search and remain - /// materialized in the cache, so actual usage can **exceed** this - /// estimate. - /// - /// For example, with 32 slots and the default 1024-byte page size: - /// ~35 KB estimated vs ~17 KB actual (`u64` keys) or ~50 KB actual - /// (100-byte `String` keys). + /// Returns a rough estimate of the cache's heap usage in bytes. /// - /// Use this as a rough order-of-magnitude guide, not a precise budget. - /// For exact heap profiling, use platform-specific tools. + /// Actual usage depends on key size and how many slots are + /// occupied. Treat this as an order-of-magnitude guide, not a + /// precise budget. pub fn node_cache_size_bytes_approx(&self) -> usize { self.cache_num_slots * (self.version.page_size().get() as usize + NodeCache::::slot_size()) From 37115d7f398ac0150b61c7ee1936e64542d60da8 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 13:37:02 +0200 Subject: [PATCH 32/42] update benchmarks/nns canbench --- benchmarks/nns/canbench_results.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/benchmarks/nns/canbench_results.yml b/benchmarks/nns/canbench_results.yml index 4186b23d..95d38b97 100644 --- a/benchmarks/nns/canbench_results.yml +++ b/benchmarks/nns/canbench_results.yml @@ -2,42 +2,42 @@ benches: vote_cascading_heap_centralized_10k: total: calls: 1 - instructions: 77758460 + instructions: 77755739 heap_increase: 16 stable_memory_increase: 0 scopes: {} vote_cascading_heap_centralized_1k: total: calls: 1 - instructions: 7815132 + instructions: 7816288 heap_increase: 1 stable_memory_increase: 0 scopes: {} vote_cascading_heap_chain_10k_15: total: calls: 1 - instructions: 1272207053 + instructions: 1272077976 heap_increase: 10 stable_memory_increase: 0 scopes: {} vote_cascading_heap_chain_10k_5: total: calls: 1 - instructions: 239648964 + instructions: 239410927 heap_increase: 10 stable_memory_increase: 0 scopes: {} vote_cascading_heap_chain_1k_15: total: calls: 1 - instructions: 124352570 + instructions: 124847103 heap_increase: 1 stable_memory_increase: 0 scopes: {} vote_cascading_heap_chain_1k_5: total: calls: 1 - instructions: 23867558 + instructions: 23958834 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -58,56 +58,56 @@ benches: vote_cascading_stable_centralized_10k: total: calls: 1 - instructions: 1375501036 + instructions: 1372396240 heap_increase: 10 stable_memory_increase: 0 scopes: {} vote_cascading_stable_centralized_1k: total: calls: 1 - instructions: 99996435 + instructions: 99761831 heap_increase: 1 stable_memory_increase: 0 scopes: {} vote_cascading_stable_chain_10k_15: total: calls: 1 - instructions: 9819218496 + instructions: 9854978344 heap_increase: 5 stable_memory_increase: 0 scopes: {} vote_cascading_stable_chain_10k_5: total: calls: 1 - instructions: 3007431336 + instructions: 2924577184 heap_increase: 5 stable_memory_increase: 0 scopes: {} vote_cascading_stable_chain_1k_15: total: calls: 1 - instructions: 867330736 + instructions: 866392564 heap_increase: 0 stable_memory_increase: 0 scopes: {} vote_cascading_stable_chain_1k_5: total: calls: 1 - instructions: 253041123 + instructions: 251866705 heap_increase: 0 stable_memory_increase: 0 scopes: {} vote_cascading_stable_single_vote_10k: total: calls: 1 - instructions: 91466 + instructions: 91198 heap_increase: 0 stable_memory_increase: 0 scopes: {} vote_cascading_stable_single_vote_1k: total: calls: 1 - instructions: 66840 + instructions: 66620 heap_increase: 0 stable_memory_increase: 0 scopes: {} From 3ce0439b793c768d47de91515a46ee6c9a902585 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 14:34:33 +0200 Subject: [PATCH 33/42] update get_min_or_max to main --- benchmarks/btreemap/canbench_results.yml | 530 +++++++++++------------ src/btreemap.rs | 77 ++-- 2 files changed, 307 insertions(+), 300 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index fb1e2a85..ada92d4e 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -65,7 +65,7 @@ benches: btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 203251272 + instructions: 203592179 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -149,7 +149,7 @@ benches: btreemap_v2_contains_principal: total: calls: 1 - instructions: 347172197 + instructions: 347269491 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -170,7 +170,7 @@ benches: btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 137474388 + instructions: 137815001 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -184,140 +184,140 @@ benches: btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 374190443 + instructions: 374287631 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1851902352 + instructions: 1851999694 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 560208058 + instructions: 560305376 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 432820855 + instructions: 432918289 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 891959419 + instructions: 892056749 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 358031651 + instructions: 358129019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 486391410 + instructions: 486488778 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 413890624 + instructions: 413988026 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 252552012 + instructions: 252990321 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 365742772 + instructions: 365840124 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 432045347 + instructions: 432142747 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 355325587 + instructions: 355422941 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 368041965 + instructions: 368139323 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 451049732 + instructions: 451147090 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 402164107 + instructions: 402261447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 368482760 + instructions: 368580150 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 397810717 + instructions: 397887233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1228428006 + instructions: 1228525326 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 494488806 + instructions: 494586172 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 391504955 + instructions: 391602201 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -387,7 +387,7 @@ benches: btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 207848708 + instructions: 208189615 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -471,7 +471,7 @@ benches: btreemap_v2_get_principal: total: calls: 1 - instructions: 349043388 + instructions: 349140682 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -492,7 +492,7 @@ benches: btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 142137067 + instructions: 142477680 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -506,462 +506,462 @@ benches: btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 378968553 + instructions: 379065741 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1862412954 + instructions: 1862510296 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 568012562 + instructions: 568109880 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 439153603 + instructions: 439251037 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 899911383 + instructions: 900008713 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 359880337 + instructions: 359977705 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 509671181 + instructions: 509768549 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 420450299 + instructions: 420547701 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 259076731 + instructions: 259515040 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 370401897 + instructions: 370499249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 445071492 + instructions: 445168892 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 360144392 + instructions: 360241746 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 372581371 + instructions: 372678729 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 467939706 + instructions: 468037064 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 407354758 + instructions: 407452098 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 373062230 + instructions: 373159620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 403880228 + instructions: 403956744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1236285531 + instructions: 1236382851 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501493695 + instructions: 501591061 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 397676514 + instructions: 397773760 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4387226377 + instructions: 4384921488 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 436622114 + instructions: 438013615 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496163594 + instructions: 5497633998 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1180782137 + instructions: 1182253513 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486213167 + instructions: 487641566 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1788979849 + instructions: 1790452326 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 490411198 + instructions: 491862937 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 703450500 + instructions: 704903558 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 542518807 + instructions: 543967485 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_128_cached_32entry: total: calls: 1 - instructions: 543345427 + instructions: 544890544 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519066567 + instructions: 520527974 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 570640531 + instructions: 572096501 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 528902035 + instructions: 530359314 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509330487 + instructions: 510785023 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610013432 + instructions: 611466951 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 534872275 + instructions: 536327253 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 517544774 + instructions: 518992393 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407316857 + instructions: 408602027 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041165188 + instructions: 3042639099 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661124294 + instructions: 662589979 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 458606393 + instructions: 460001276 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 501982945 + instructions: 503458405 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 406695881 + instructions: 407853554 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 414530721 + instructions: 415703035 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 415372101 + instructions: 416642576 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410324198 + instructions: 411478774 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 592820136 + instructions: 594212048 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2743145193 + instructions: 2746552289 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1011265889 + instructions: 1013804135 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 707653590 + instructions: 709306396 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1400814198 + instructions: 1403921397 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 620501569 + instructions: 621952680 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1180703560 + instructions: 1183022816 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 754738693 + instructions: 756520567 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 755565313 + instructions: 757443626 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 664831919 + instructions: 666292168 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 867850710 + instructions: 869965962 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 660291790 + instructions: 661749069 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 658996206 + instructions: 660450353 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 972270626 + instructions: 974532291 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 690276014 + instructions: 691780746 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 658493986 + instructions: 659941521 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 603190644 + instructions: 604598973 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1857741950 + instructions: 1861082228 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 844932768 + instructions: 846966268 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 664998503 + instructions: 666595334 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -982,21 +982,21 @@ benches: btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 282318736 + instructions: 282344189 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 361219705 + instructions: 361879738 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1259813947 + instructions: 1261964478 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1017,1190 +1017,1190 @@ benches: btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 287671439 + instructions: 287697135 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 375772491 + instructions: 376469616 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1267930071 + instructions: 1270110599 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3127812849 + instructions: 3127799936 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: calls: 1 - instructions: 607431275 + instructions: 607417615 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 520690492 + instructions: 520715214 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 834359311 + instructions: 836175195 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1963337173 + instructions: 1967930771 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4317631117 + instructions: 4317598870 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 884244392 + instructions: 884193673 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 737609702 + instructions: 737685085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1225958024 + instructions: 1228677631 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3088770366 + instructions: 3095699391 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 591951579 + instructions: 597407834 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8288407165 + instructions: 8297130413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1796551464 + instructions: 1804174644 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 728560218 + instructions: 734373790 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2726171909 + instructions: 2733671418 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 748800319 + instructions: 755426307 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1081085255 + instructions: 1087779628 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 844318563 + instructions: 851025972 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 785720657 + instructions: 792507344 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 871200894 + instructions: 877934925 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 798495516 + instructions: 805237415 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 771358040 + instructions: 777985138 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 930035952 + instructions: 936593625 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 805410533 + instructions: 812160643 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 788233552 + instructions: 794968994 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 363461754 + instructions: 366793405 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4555502598 + instructions: 4563714722 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1009157386 + instructions: 1016001127 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 592756791 + instructions: 598023005 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 796689425 + instructions: 803842908 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 661262508 + instructions: 667951594 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 672299564 + instructions: 678756426 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 662684742 + instructions: 669776492 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 762999655 + instructions: 768548179 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4027441090 + instructions: 4037625469 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1484553711 + instructions: 1486581054 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 999548191 + instructions: 1008641914 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2012925433 + instructions: 2012806732 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 860115553 + instructions: 865141519 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1621662176 + instructions: 1624317758 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1068207625 + instructions: 1070767441 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 916964970 + instructions: 922336173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1188819482 + instructions: 1189710810 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 914413948 + instructions: 919729513 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 904880286 + instructions: 909800162 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1334666891 + instructions: 1335567632 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 954607628 + instructions: 959198992 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 915278887 + instructions: 920105441 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 526469144 + instructions: 530553234 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2700790230 + instructions: 2703717413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1215569661 + instructions: 1215697638 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 827917372 + instructions: 834452013 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 568319608 + instructions: 573837448 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 7955954052 + instructions: 7964752527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1727324384 + instructions: 1734895760 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 702110867 + instructions: 708285315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2632087867 + instructions: 2639581869 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 720625913 + instructions: 727373647 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1045014557 + instructions: 1051707191 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 809968410 + instructions: 816792272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 757541123 + instructions: 764268797 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 840296103 + instructions: 846964497 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 765931981 + instructions: 772852955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 747627473 + instructions: 754346451 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 904708781 + instructions: 911398355 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 779597704 + instructions: 786379887 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 759630332 + instructions: 766396610 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 350041222 + instructions: 353304333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4386401539 + instructions: 4394650914 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 977230622 + instructions: 984080248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 586663344 + instructions: 591925970 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 776735213 + instructions: 783854042 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 637927378 + instructions: 644628943 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 648434292 + instructions: 655010676 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 639250557 + instructions: 646333840 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 742850447 + instructions: 748590467 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4233568001 + instructions: 4243993292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1489866940 + instructions: 1491919431 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 979972315 + instructions: 989231059 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2052607071 + instructions: 2051638271 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 843253971 + instructions: 848299967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1595902162 + instructions: 1598837509 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1043125173 + instructions: 1045611619 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 891694565 + instructions: 897397193 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1164885116 + instructions: 1167205999 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 894683699 + instructions: 900067321 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 889335973 + instructions: 894470822 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1315764380 + instructions: 1317557850 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 931884327 + instructions: 936115330 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 892803773 + instructions: 898030249 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 512220533 + instructions: 516225783 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2787274299 + instructions: 2790593587 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1200514583 + instructions: 1202480982 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 826805582 + instructions: 833399145 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_0b: total: calls: 1 - instructions: 16964 + instructions: 16941 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2507198 + instructions: 2513961 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 18468767 + instructions: 18468868 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_0b: total: calls: 1 - instructions: 16935 + instructions: 16918 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 2572996 + instructions: 2579764 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 18470001 + instructions: 18470107 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_0b: total: calls: 1 - instructions: 17302 + instructions: 17285 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 20668620 + instructions: 20675388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 398305228 + instructions: 398305334 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4709565637 + instructions: 4706246639 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 585035303 + instructions: 587249436 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7377029868 + instructions: 7379677223 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1591148753 + instructions: 1593766789 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665861269 + instructions: 668316925 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2425709699 + instructions: 2428338891 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 654473704 + instructions: 657048362 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 986692947 + instructions: 989209750 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 747246431 + instructions: 749758654 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 748929058 + instructions: 751633797 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 700615696 + instructions: 703131798 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784881235 + instructions: 787381650 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 712465734 + instructions: 714991639 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696711313 + instructions: 699267329 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 858924547 + instructions: 861468008 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 737681715 + instructions: 740272350 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 696607410 + instructions: 699113934 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 453196576 + instructions: 454669415 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4078413534 + instructions: 4081038460 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 911608508 + instructions: 914122756 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599766602 + instructions: 601959578 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 683360009 + instructions: 686167092 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566580912 + instructions: 568622160 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 587271157 + instructions: 589384584 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 589002924 + instructions: 591314354 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 571897924 + instructions: 573931402 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 754900625 + instructions: 757263117 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4482353491 + instructions: 4519359970 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1419385921 + instructions: 1423798637 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 919413296 + instructions: 922681409 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2247128783 + instructions: 2252586984 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 834468759 + instructions: 837138335 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1703393507 + instructions: 1707330211 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1037264657 + instructions: 1041036567 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1038933724 + instructions: 1042894602 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 871514377 + instructions: 874151516 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1241548210 + instructions: 1245239956 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 867712184 + instructions: 870368797 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 862324671 + instructions: 865012757 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1407640955 + instructions: 1411605266 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 968640899 + instructions: 971295657 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 856659888 + instructions: 859319329 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 662045769 + instructions: 663805383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3083483890 + instructions: 3092904397 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1183664207 + instructions: 1187158615 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 822011534 + instructions: 824559084 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_1k_0b: total: calls: 1 - instructions: 975992 + instructions: 982822 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_1k_10kib: total: calls: 1 - instructions: 2491763 + instructions: 2498593 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_20_10mib: total: calls: 1 - instructions: 18467176 + instructions: 18467315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_1k_0b: total: calls: 1 - instructions: 978166 + instructions: 980996 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_1k_10kib: total: calls: 1 - instructions: 2475597 + instructions: 2478427 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_iter_rev_20_10mib: total: calls: 1 - instructions: 18467168 + instructions: 18467227 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_1k_0b: total: calls: 1 - instructions: 982657 + instructions: 980678 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_1k_10kib: total: calls: 1 - instructions: 2498428 + instructions: 2496449 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_20_10mib: total: calls: 1 - instructions: 18467320 + instructions: 18467281 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_1k_0b: total: calls: 1 - instructions: 984223 + instructions: 982244 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_1k_10kib: total: calls: 1 - instructions: 2481654 + instructions: 2479675 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_keys_rev_20_10mib: total: calls: 1 - instructions: 18467298 + instructions: 18467259 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_1k_0b: total: calls: 1 - instructions: 1230992 + instructions: 1237822 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_1k_10kib: total: calls: 1 - instructions: 56740279 + instructions: 56747109 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_20_10mib: total: calls: 1 - instructions: 1103710894 + instructions: 1103711033 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_1k_0b: total: calls: 1 - instructions: 1231498 + instructions: 1234328 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_1k_10kib: total: calls: 1 - instructions: 56683107 + instructions: 56685937 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_scan_values_rev_20_10mib: total: calls: 1 - instructions: 1103710405 + instructions: 1103710464 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 084e2d2d..c76b02ac 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -838,43 +838,50 @@ where } } - fn get_min_or_max( - &self, - node: &Node, - is_min: bool, - extract: fn(&Node, usize, &M) -> R, - ) -> R { - match node.node_type() { - NodeType::Leaf => { - let idx = if is_min { 0 } else { node.num_entries() - 1 }; - extract(node, idx, self.memory()) - } - NodeType::Internal => { - // An internal node with N entries has N+1 children. - // Min is child(0), max is child(N) — the rightmost child. - let child_addr = if is_min { - node.child(0) - } else { - node.child(node.num_entries()) - }; - let child = self.load_node(child_addr); - self.get_min_or_max(&child, is_min, extract) + /// Traverses to the min or max leaf and extracts a result using the provided closure. + fn get_min_or_max(&self, node: &Node, is_min: bool, extract: F) -> R + where + F: Fn(&Node, usize, &M) -> R, + { + let mut current; + let mut current_ref = node; + loop { + match current_ref.node_type() { + NodeType::Leaf => { + let idx = if is_min { + 0 + } else { + // Last entry index in a 0-based array of entries. + current_ref.num_entries() - 1 + }; + return extract(current_ref, idx, self.memory()); + } + NodeType::Internal => { + let child_addr = if is_min { + current_ref.child(0) + } else { + // Last child index in a 0-based array of children. + current_ref.child(current_ref.children_len() - 1) + }; + current = self.load_node(child_addr); + current_ref = ¤t; + } } } } #[inline(always)] - fn get_min_key(&self, node: &Node) -> K { + fn first_key_inner(&self, node: &Node) -> K { self.get_min_or_max(node, true, |n, i, m| n.key(i, m).clone()) } #[inline(always)] - fn get_max_key(&self, node: &Node) -> K { + fn last_key_inner(&self, node: &Node) -> K { self.get_min_or_max(node, false, |n, i, m| n.key(i, m).clone()) } #[inline(always)] - fn get_min_entry(&self, node: &Node) -> Entry { + fn first_entry_inner(&self, node: &Node) -> Entry { self.get_min_or_max(node, true, |n, i, m| { let (k, v) = n.get_key_read_value_uncached(i, m); (k.clone(), v.to_vec()) @@ -882,7 +889,7 @@ where } #[inline(always)] - fn get_max_entry(&self, node: &Node) -> Entry { + fn last_entry_inner(&self, node: &Node) -> Entry { self.get_min_or_max(node, false, |n, i, m| { let (k, v) = n.get_key_read_value_uncached(i, m); (k.clone(), v.to_vec()) @@ -932,7 +939,7 @@ where return None; } let root = self.take_or_load_node(self.root_addr); - let (k, encoded_v) = self.get_min_entry(&root); + let (k, encoded_v) = self.first_entry_inner(&root); self.return_node(root, 0); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -944,7 +951,7 @@ where return None; } let root = self.take_or_load_node(self.root_addr); - let (k, encoded_v) = self.get_max_entry(&root); + let (k, encoded_v) = self.last_entry_inner(&root); self.return_node(root, 0); Some((k, V::from_bytes(Cow::Owned(encoded_v)))) } @@ -976,9 +983,9 @@ where } let root = self.load_node(self.root_addr); - let max_key = self.get_max_key(&root); - self.remove_helper(root, &max_key) - .map(|v| (max_key, V::from_bytes(Cow::Owned(v)))) + let last_key = self.last_key_inner(&root); + self.remove_helper(root, &last_key) + .map(|v| (last_key, V::from_bytes(Cow::Owned(v)))) } /// Removes and returns the first element in the map. The key of this element is the minimum key that was in the map @@ -988,9 +995,9 @@ where } let root = self.load_node(self.root_addr); - let min_key = self.get_min_key(&root); - self.remove_helper(root, &min_key) - .map(|v| (min_key, V::from_bytes(Cow::Owned(v)))) + let first_key = self.first_key_inner(&root); + self.remove_helper(root, &first_key) + .map(|v| (first_key, V::from_bytes(Cow::Owned(v)))) } /// A helper method for recursively removing a key from the B-tree. @@ -1060,7 +1067,7 @@ where // Recursively delete the predecessor. // TODO(EXC-1034): Do this in a single pass. - let predecessor = self.get_max_entry(&left_child); + let predecessor = self.last_entry_inner(&left_child); self.remove_helper(left_child, &predecessor.0)?; // Replace the `key` with its predecessor. @@ -1095,7 +1102,7 @@ where // Recursively delete the successor. // TODO(EXC-1034): Do this in a single pass. - let successor = self.get_min_entry(&right_child); + let successor = self.first_entry_inner(&right_child); self.remove_helper(right_child, &successor.0)?; // Replace the `key` with its successor. From 08a3a094473ee5ecd0a2e715a2df4422b4aeb88c Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 14:48:39 +0200 Subject: [PATCH 34/42] find_first_or_last --- src/btreemap.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 2e11f199..6b67c4b5 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -839,7 +839,7 @@ where } /// Traverses to the min or max leaf and extracts a result using the provided closure. - fn get_min_or_max(&self, node: &Node, is_min: bool, extract: F) -> R + fn find_first_or_last(&self, node: &Node, is_first: bool, extract: F) -> R where F: Fn(&Node, usize, &M) -> R, { @@ -848,7 +848,7 @@ where loop { match current_ref.node_type() { NodeType::Leaf => { - let idx = if is_min { + let idx = if is_first { 0 } else { // Last entry index in a 0-based array of entries. @@ -857,7 +857,7 @@ where return extract(current_ref, idx, self.memory()); } NodeType::Internal => { - let child_addr = if is_min { + let child_addr = if is_first { current_ref.child(0) } else { // Last child index in a 0-based array of children. @@ -872,17 +872,17 @@ where #[inline(always)] fn first_key_inner(&self, node: &Node) -> K { - self.get_min_or_max(node, true, |n, i, m| n.key(i, m).clone()) + self.find_first_or_last(node, true, |n, i, m| n.key(i, m).clone()) } #[inline(always)] fn last_key_inner(&self, node: &Node) -> K { - self.get_min_or_max(node, false, |n, i, m| n.key(i, m).clone()) + self.find_first_or_last(node, false, |n, i, m| n.key(i, m).clone()) } #[inline(always)] fn first_entry_inner(&self, node: &Node) -> Entry { - self.get_min_or_max(node, true, |n, i, m| { + self.find_first_or_last(node, true, |n, i, m| { let (k, v) = n.get_key_read_value_uncached(i, m); (k.clone(), v.to_vec()) }) @@ -890,7 +890,7 @@ where #[inline(always)] fn last_entry_inner(&self, node: &Node) -> Entry { - self.get_min_or_max(node, false, |n, i, m| { + self.find_first_or_last(node, false, |n, i, m| { let (k, v) = n.get_key_read_value_uncached(i, m); (k.clone(), v.to_vec()) }) From e574e5403ff95f75adbe8129564c4ca7aa8c50c2 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 14:54:53 +0200 Subject: [PATCH 35/42] iterative is faster --- benchmarks/btreemap/canbench_results.yml | 268 +++++++++++------------ src/btreemap.rs | 42 ++-- 2 files changed, 153 insertions(+), 157 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index ada92d4e..79874b15 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -1073,623 +1073,623 @@ benches: btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4317598870 + instructions: 4317603201 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 884193673 + instructions: 884202200 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 737685085 + instructions: 737680047 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1228677631 + instructions: 1228684684 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3095699391 + instructions: 3095557794 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 597407834 + instructions: 593151778 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8297130413 + instructions: 8289931461 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1804174644 + instructions: 1798035387 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 734373790 + instructions: 729883433 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2733671418 + instructions: 2727673538 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 755426307 + instructions: 750234578 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1087779628 + instructions: 1082518229 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 851025972 + instructions: 845766194 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 792507344 + instructions: 787131086 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 877934925 + instructions: 872641498 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 805237415 + instructions: 799911424 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 777985138 + instructions: 772789546 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 936593625 + instructions: 931467231 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 812160643 + instructions: 806831703 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 794968994 + instructions: 789687508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 366793405 + instructions: 364223885 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4563714722 + instructions: 4557008594 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1016001127 + instructions: 1010631422 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 598023005 + instructions: 593898995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 803842908 + instructions: 798181315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 667951594 + instructions: 662277719 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 678756426 + instructions: 673371059 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 669776492 + instructions: 663689713 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 768548179 + instructions: 764168545 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4037625469 + instructions: 4031773812 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1486581054 + instructions: 1487553384 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1008641914 + instructions: 1001156485 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2012806732 + instructions: 2016843442 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 865141519 + instructions: 861581949 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1624317758 + instructions: 1624294822 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1070767441 + instructions: 1070122370 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 922336173 + instructions: 918411121 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1189710810 + instructions: 1191203694 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 919729513 + instructions: 915864080 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 909800162 + instructions: 906345552 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1335567632 + instructions: 1337280001 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 959198992 + instructions: 956144123 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 920105441 + instructions: 916766413 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 530553234 + instructions: 527361999 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2703717413 + instructions: 2705015050 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1215697638 + instructions: 1217831961 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 834452013 + instructions: 829277512 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 573837448 + instructions: 569623519 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 7964752527 + instructions: 7957597870 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1734895760 + instructions: 1728932388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 708285315 + instructions: 703546806 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2639581869 + instructions: 2633716719 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 727373647 + instructions: 722172820 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1051707191 + instructions: 1046564660 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 816792272 + instructions: 811535872 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 764268797 + instructions: 759073667 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 846964497 + instructions: 841854565 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 772852955 + instructions: 767461859 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 754346451 + instructions: 749177543 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 911398355 + instructions: 906253053 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 786379887 + instructions: 781135454 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 766396610 + instructions: 761203689 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 353304333 + instructions: 350864076 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4394650914 + instructions: 4388031433 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 984080248 + instructions: 978825702 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 591925970 + instructions: 587891854 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 783854042 + instructions: 778339872 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 644628943 + instructions: 639068670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 655010676 + instructions: 649632076 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 646333840 + instructions: 640380562 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 748590467 + instructions: 744120707 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4243993292 + instructions: 4238025504 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1491919431 + instructions: 1492994969 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 989231059 + instructions: 981696068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2051638271 + instructions: 2056649860 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 848299967 + instructions: 844832777 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1598837509 + instructions: 1598651576 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1045611619 + instructions: 1045161615 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 897397193 + instructions: 893262673 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1167205999 + instructions: 1167386767 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 900067321 + instructions: 896247825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 894470822 + instructions: 890919707 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1317557850 + instructions: 1318489508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 936115330 + instructions: 933538337 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 898030249 + instructions: 894410661 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 516225783 + instructions: 513170016 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2790593587 + instructions: 2791623340 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1202480982 + instructions: 1202894758 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 833399145 + instructions: 828251932 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1766,315 +1766,315 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 587249436 + instructions: 587251616 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7379677223 + instructions: 7379680308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1593766789 + instructions: 1593738752 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 668316925 + instructions: 668323594 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2428338891 + instructions: 2428309926 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 657048362 + instructions: 657029910 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 989209750 + instructions: 989211169 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 749758654 + instructions: 749757483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 751633797 + instructions: 751632626 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 703131798 + instructions: 703114147 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 787381650 + instructions: 787386039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 714991639 + instructions: 714976581 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 699267329 + instructions: 699252756 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 861468008 + instructions: 861472485 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 740272350 + instructions: 740261257 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 699113934 + instructions: 699099037 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 454669415 + instructions: 454672988 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4081038460 + instructions: 4081065607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 914122756 + instructions: 914107656 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 601959578 + instructions: 601972556 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 686167092 + instructions: 686014954 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 568622160 + instructions: 568617637 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 589384584 + instructions: 589379244 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 591314354 + instructions: 591309014 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 573931402 + instructions: 573928113 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 757263117 + instructions: 757143465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4519359970 + instructions: 4488236921 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1423798637 + instructions: 1423661233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 922681409 + instructions: 922162761 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2252586984 + instructions: 2252460248 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 837138335 + instructions: 837014045 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1707330211 + instructions: 1707202897 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1041036567 + instructions: 1040212631 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1042894602 + instructions: 1042070666 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 874151516 + instructions: 874024012 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1245239956 + instructions: 1245115709 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 870368797 + instructions: 870235353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 865012757 + instructions: 864878305 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1411605266 + instructions: 1411480354 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 971295657 + instructions: 971301383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 859319329 + instructions: 859183754 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 663805383 + instructions: 663695061 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3092904397 + instructions: 3089274312 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1187158615 + instructions: 1186989901 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 824559084 + instructions: 824432596 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 6b67c4b5..b41d0baf 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -843,29 +843,25 @@ where where F: Fn(&Node, usize, &M) -> R, { - let mut current; - let mut current_ref = node; - loop { - match current_ref.node_type() { - NodeType::Leaf => { - let idx = if is_first { - 0 - } else { - // Last entry index in a 0-based array of entries. - current_ref.num_entries() - 1 - }; - return extract(current_ref, idx, self.memory()); - } - NodeType::Internal => { - let child_addr = if is_first { - current_ref.child(0) - } else { - // Last child index in a 0-based array of children. - current_ref.child(current_ref.children_len() - 1) - }; - current = self.load_node(child_addr); - current_ref = ¤t; - } + match node.node_type() { + NodeType::Leaf => { + let idx = if is_first { + 0 + } else { + // Last entry index in a 0-based array of entries. + node.num_entries() - 1 + }; + extract(node, idx, self.memory()) + } + NodeType::Internal => { + let child_addr = if is_first { + node.child(0) + } else { + // Last child index in a 0-based array of children. + node.child(node.children_len() - 1) + }; + let child = self.load_node(child_addr); + self.find_first_or_last(&child, is_first, extract) } } } From 04b0469fca64a75a6a3a241b4d025f2caabf02e6 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 15:19:20 +0200 Subject: [PATCH 36/42] add benchmarks for first/last_key_value --- benchmarks/btreemap/canbench_results.yml | 460 +++++++++++++++-------- benchmarks/btreemap/src/main.rs | 74 ++++ src/btreemap.rs | 20 +- 3 files changed, 379 insertions(+), 175 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 79874b15..7747c4c3 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -321,6 +321,69 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_first_key_value_blob_256_128: + total: + calls: 1 + instructions: 734830605 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_blob_32_0: + total: + calls: 1 + instructions: 288040308 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_blob_32_1024: + total: + calls: 1 + instructions: 451310650 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_blob_32_128: + total: + calls: 1 + instructions: 277820518 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_blob_8_128: + total: + calls: 1 + instructions: 298460561 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_principal: + total: + calls: 1 + instructions: 369050381 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_u64_u64: + total: + calls: 1 + instructions: 230100393 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_vec_32_128: + total: + calls: 1 + instructions: 237800563 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_first_key_value_vec_32_vec128: + total: + calls: 1 + instructions: 237800563 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 @@ -646,14 +709,14 @@ benches: btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4384921488 + instructions: 4389919149 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 438013615 + instructions: 437998979 heap_increase: 0 stable_memory_increase: 4 scopes: {} @@ -674,7 +737,7 @@ benches: btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 487641566 + instructions: 487641557 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -688,7 +751,7 @@ benches: btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 491862937 + instructions: 491862059 heap_increase: 0 stable_memory_increase: 8 scopes: {} @@ -716,14 +779,14 @@ benches: btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 520527974 + instructions: 520527944 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 572096501 + instructions: 572096483 heap_increase: 0 stable_memory_increase: 49 scopes: {} @@ -737,14 +800,14 @@ benches: btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 510785023 + instructions: 510784611 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 611466951 + instructions: 611466933 heap_increase: 0 stable_memory_increase: 91 scopes: {} @@ -765,7 +828,7 @@ benches: btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 408602027 + instructions: 408602017 heap_increase: 0 stable_memory_increase: 13 scopes: {} @@ -786,35 +849,35 @@ benches: btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 460001276 + instructions: 460001267 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 503458405 + instructions: 503444425 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 407853554 + instructions: 407850609 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 415703035 + instructions: 415684319 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 416642576 + instructions: 416623860 heap_increase: 0 stable_memory_increase: 6 scopes: {} @@ -835,28 +898,28 @@ benches: btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2746552289 + instructions: 2744342963 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1013804135 + instructions: 1012517653 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 709306396 + instructions: 709035399 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1403921397 + instructions: 1401990782 heap_increase: 0 stable_memory_increase: 71 scopes: {} @@ -870,21 +933,21 @@ benches: btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1183022816 + instructions: 1182073702 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 756520567 + instructions: 756119602 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 757443626 + instructions: 757042661 heap_increase: 0 stable_memory_increase: 33 scopes: {} @@ -898,7 +961,7 @@ benches: btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 869965962 + instructions: 869184356 heap_increase: 0 stable_memory_increase: 54 scopes: {} @@ -919,14 +982,14 @@ benches: btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 974532291 + instructions: 973596882 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 691780746 + instructions: 691725130 heap_increase: 0 stable_memory_increase: 24 scopes: {} @@ -940,31 +1003,94 @@ benches: btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604598973 + instructions: 604436459 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1861082228 + instructions: 1858895187 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846966268 + instructions: 846295989 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 666595334 + instructions: 666351716 heap_increase: 0 stable_memory_increase: 23 scopes: {} + btreemap_v2_last_key_value_blob_256_128: + total: + calls: 1 + instructions: 706560395 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_blob_32_0: + total: + calls: 1 + instructions: 219850308 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_blob_32_1024: + total: + calls: 1 + instructions: 394180650 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_blob_32_128: + total: + calls: 1 + instructions: 278760506 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_blob_8_128: + total: + calls: 1 + instructions: 321680393 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_principal: + total: + calls: 1 + instructions: 215580393 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_u64_u64: + total: + calls: 1 + instructions: 239770393 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_vec_32_128: + total: + calls: 1 + instructions: 228280383 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_last_key_value_vec_32_vec128: + total: + calls: 1 + instructions: 228280383 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 @@ -1038,7 +1164,7 @@ benches: btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3127799936 + instructions: 3127799623 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1052,644 +1178,644 @@ benches: btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 520715214 + instructions: 520696498 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 836175195 + instructions: 835225431 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1967930771 + instructions: 1965714407 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4317603201 + instructions: 4318264089 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 884202200 + instructions: 884221878 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 737680047 + instructions: 737633885 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1228684684 + instructions: 1227061267 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3095557794 + instructions: 3091615290 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 593151778 + instructions: 594314220 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8289931461 + instructions: 8422908716 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1798035387 + instructions: 1818364668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 729883433 + instructions: 731551596 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2727673538 + instructions: 2765148548 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 750234578 + instructions: 752621403 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1082518229 + instructions: 1084930626 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 845766194 + instructions: 848198497 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 787131086 + instructions: 789569161 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 872641498 + instructions: 875028267 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 799911424 + instructions: 802327346 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 772789546 + instructions: 775160145 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 931467231 + instructions: 933830979 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 806831703 + instructions: 809226089 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 789687508 + instructions: 792100447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 364223885 + instructions: 364805185 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4557008594 + instructions: 4626110365 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1010631422 + instructions: 1022593048 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 593898995 + instructions: 595061976 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 798181315 + instructions: 800318786 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 662277719 + instructions: 663296357 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 673371059 + instructions: 674304358 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 663689713 + instructions: 664718195 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 764168545 + instructions: 765377892 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4031773812 + instructions: 4030036967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1487553384 + instructions: 1487348737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1001156485 + instructions: 1002230175 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2016843442 + instructions: 2015632945 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 861581949 + instructions: 863071058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1624294822 + instructions: 1624432709 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1070122370 + instructions: 1071142486 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 918411121 + instructions: 919930241 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1191203694 + instructions: 1191614673 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 915864080 + instructions: 917369504 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 906345552 + instructions: 907823819 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1337280001 + instructions: 1337413144 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 956144123 + instructions: 957552492 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 916766413 + instructions: 918270058 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 527361999 + instructions: 527959240 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2705015050 + instructions: 2703367257 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1217831961 + instructions: 1218518813 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 829277512 + instructions: 830201491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 569623519 + instructions: 570757555 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 7957597870 + instructions: 8093183703 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1728932388 + instructions: 1749240011 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 703546806 + instructions: 705190915 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2633716719 + instructions: 2670521862 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 722172820 + instructions: 724619261 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1046564660 + instructions: 1048954849 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 811535872 + instructions: 813954982 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 759073667 + instructions: 761461989 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 841854565 + instructions: 844224348 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 767461859 + instructions: 769863719 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 749177543 + instructions: 751584493 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 906253053 + instructions: 908628107 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 781135454 + instructions: 783533000 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 761203689 + instructions: 763609790 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 350864076 + instructions: 351439292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4388031433 + instructions: 4456609510 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 978825702 + instructions: 990635309 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 587891854 + instructions: 589091401 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 778339872 + instructions: 780531856 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 639068670 + instructions: 640078677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 649632076 + instructions: 650557256 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 640380562 + instructions: 641401604 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 744120707 + instructions: 745303447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4238025504 + instructions: 4236313308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1492994969 + instructions: 1492783940 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 981696068 + instructions: 982747493 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2056649860 + instructions: 2055412449 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 844832777 + instructions: 846358881 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1598651576 + instructions: 1598776777 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1045161615 + instructions: 1046171015 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 893262673 + instructions: 894751119 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1167386767 + instructions: 1167787357 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 896247825 + instructions: 897744527 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 890919707 + instructions: 892420612 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1318489508 + instructions: 1318631304 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 933538337 + instructions: 934947355 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 894410661 + instructions: 895910092 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 513170016 + instructions: 513762891 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2791623340 + instructions: 2789962967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1202894758 + instructions: 1203565250 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 828251932 + instructions: 829212998 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1759,322 +1885,322 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4706246639 + instructions: 4711741009 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 587251616 + instructions: 587219554 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7379680308 + instructions: 7380945702 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1593738752 + instructions: 1593945964 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 668323594 + instructions: 668346721 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2428309926 + instructions: 2428665438 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 657029910 + instructions: 657054660 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 989211169 + instructions: 989236869 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 749757483 + instructions: 749783761 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 751632626 + instructions: 752511933 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 703114147 + instructions: 703141681 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 787386039 + instructions: 787413760 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 714976581 + instructions: 715003607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 699252756 + instructions: 699278245 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 861472485 + instructions: 861498997 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 740261257 + instructions: 740289607 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 699099037 + instructions: 699125050 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 454672988 + instructions: 454682836 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4081065607 + instructions: 4081738108 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 914107656 + instructions: 914236119 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 601972556 + instructions: 601987691 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 686014954 + instructions: 686011662 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 568617637 + instructions: 568628695 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 589379244 + instructions: 589333082 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 591309014 + instructions: 593963739 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 573928113 + instructions: 573947282 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 757143465 + instructions: 757158552 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4488236921 + instructions: 4484339250 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1423661233 + instructions: 1421624432 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 922162761 + instructions: 921855821 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2252460248 + instructions: 2249185934 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 837014045 + instructions: 837031955 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1707202897 + instructions: 1705626988 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1040212631 + instructions: 1039694098 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1042070666 + instructions: 1041049532 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 874024012 + instructions: 874042905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1245115709 + instructions: 1243862175 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 870235353 + instructions: 870253828 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 864878305 + instructions: 864896239 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1411480354 + instructions: 1409920538 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 971301383 + instructions: 971239576 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 859183754 + instructions: 859201513 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 663695061 + instructions: 663572357 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3089274312 + instructions: 3085455727 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1186989901 + instructions: 1186047737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 824432596 + instructions: 824201684 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index 9efabbca..9159d628 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -530,6 +530,42 @@ macro_rules! bench_traversal_tests { }; } +// First key value +bench_tests! { + // key size variation (fixed Blob128 value) + btreemap_v2_first_key_value_blob_8_128, first_key_value_helper_v2, Blob8, Blob128; + btreemap_v2_first_key_value_blob_32_128, first_key_value_helper_v2, Blob32, Blob128; + btreemap_v2_first_key_value_blob_256_128, first_key_value_helper_v2, Blob256, Blob128; + btreemap_v2_first_key_value_vec_32_128, first_key_value_helper_v2, UnboundedVecN32, UnboundedVecN128; + + // value size variation (fixed Blob32 key) + btreemap_v2_first_key_value_blob_32_0, first_key_value_helper_v2, Blob32, Empty; + btreemap_v2_first_key_value_blob_32_1024, first_key_value_helper_v2, Blob32, Blob1024; + btreemap_v2_first_key_value_vec_32_vec128, first_key_value_helper_v2, UnboundedVecN32, UnboundedVecN128; + + // common types + btreemap_v2_first_key_value_u64_u64, first_key_value_helper_v2, u64, u64; + btreemap_v2_first_key_value_principal, first_key_value_helper_v2, Principal, Empty; +} + +// Last key value +bench_tests! { + // key size variation (fixed Blob128 value) + btreemap_v2_last_key_value_blob_8_128, last_key_value_helper_v2, Blob8, Blob128; + btreemap_v2_last_key_value_blob_32_128, last_key_value_helper_v2, Blob32, Blob128; + btreemap_v2_last_key_value_blob_256_128, last_key_value_helper_v2, Blob256, Blob128; + btreemap_v2_last_key_value_vec_32_128, last_key_value_helper_v2, UnboundedVecN32, UnboundedVecN128; + + // value size variation (fixed Blob32 key) + btreemap_v2_last_key_value_blob_32_0, last_key_value_helper_v2, Blob32, Empty; + btreemap_v2_last_key_value_blob_32_1024, last_key_value_helper_v2, Blob32, Blob1024; + btreemap_v2_last_key_value_vec_32_vec128, last_key_value_helper_v2, UnboundedVecN32, UnboundedVecN128; + + // common types + btreemap_v2_last_key_value_u64_u64, last_key_value_helper_v2, u64, u64; + btreemap_v2_last_key_value_principal, last_key_value_helper_v2, Principal, Empty; +} + // First bench_tests! { // blob K x 128 @@ -648,6 +684,44 @@ bench_tests! { btreemap_v2_pop_last_principal, pop_last_helper_v2, Principal, Empty; } +fn first_key_value_helper_v2() -> BenchResult { + first_or_last_key_value_helper_v2::(Position::First) +} + +fn last_key_value_helper_v2() -> BenchResult { + first_or_last_key_value_helper_v2::(Position::Last) +} + +fn first_or_last_key_value_helper_v2(position: Position) -> BenchResult { + let btree = BTreeMap::new(DefaultMemoryImpl::default()); + first_or_last_key_value_helper::(btree, position) +} + +fn first_or_last_key_value_helper( + mut btree: BTreeMap, + position: Position, +) -> BenchResult { + let count = 10_000; + let mut rng = Rng::from_seed(0); + let items = generate_random_kv::(count, &mut rng); + for (k, v) in items { + btree.insert(k, v); + } + + bench_fn(|| { + for _ in 0..count { + match position { + Position::First => { + btree.first_key_value(); + } + Position::Last => { + btree.last_key_value(); + } + }; + } + }) +} + fn pop_first_helper_v2() -> BenchResult { pop_helper_v2::(Position::First) } diff --git a/src/btreemap.rs b/src/btreemap.rs index b41d0baf..7bdbd689 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -806,6 +806,7 @@ where /// Returns true if the key exists. pub fn contains_key(&self, key: &K) -> bool { + // An empty closure returns Some(()) if the key is found. self.root_addr != NULL && self.traverse(self.root_addr, 0, key, |_, _| ()).is_some() } @@ -838,8 +839,8 @@ where } } - /// Traverses to the min or max leaf and extracts a result using the provided closure. - fn find_first_or_last(&self, node: &Node, is_first: bool, extract: F) -> R + /// A helper function to find either the first or last entry in the tree, depending on the `is_first` flag. + fn find_first_or_last(&self, node: &Node, is_first: bool, depth: u8, extract: F) -> R where F: Fn(&Node, usize, &M) -> R, { @@ -860,25 +861,28 @@ where // Last child index in a 0-based array of children. node.child(node.children_len() - 1) }; - let child = self.load_node(child_addr); - self.find_first_or_last(&child, is_first, extract) + let child = self.take_or_load_node(child_addr); + let new_depth = depth.saturating_add(1); + let result = self.find_first_or_last(&child, is_first, new_depth, extract); + self.return_node(child, new_depth); + result } } } #[inline(always)] fn first_key_inner(&self, node: &Node) -> K { - self.find_first_or_last(node, true, |n, i, m| n.key(i, m).clone()) + self.find_first_or_last(node, true, 0, |n, i, m| n.key(i, m).clone()) } #[inline(always)] fn last_key_inner(&self, node: &Node) -> K { - self.find_first_or_last(node, false, |n, i, m| n.key(i, m).clone()) + self.find_first_or_last(node, false, 0, |n, i, m| n.key(i, m).clone()) } #[inline(always)] fn first_entry_inner(&self, node: &Node) -> Entry { - self.find_first_or_last(node, true, |n, i, m| { + self.find_first_or_last(node, true, 0, |n, i, m| { let (k, v) = n.get_key_read_value_uncached(i, m); (k.clone(), v.to_vec()) }) @@ -886,7 +890,7 @@ where #[inline(always)] fn last_entry_inner(&self, node: &Node) -> Entry { - self.find_first_or_last(node, false, |n, i, m| { + self.find_first_or_last(node, false, 0, |n, i, m| { let (k, v) = n.get_key_read_value_uncached(i, m); (k.clone(), v.to_vec()) }) From ab38fb1fbb0f43c1a74403b3443bffbebd52a624 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 15:41:38 +0200 Subject: [PATCH 37/42] remove extra clonning --- benchmarks/btreemap/canbench_results.yml | 136 +++++++++++------------ src/btreemap.rs | 8 +- 2 files changed, 70 insertions(+), 74 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 7747c4c3..27a7ec8c 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -324,63 +324,63 @@ benches: btreemap_v2_first_key_value_blob_256_128: total: calls: 1 - instructions: 734830605 + instructions: 696560395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_0: total: calls: 1 - instructions: 288040308 + instructions: 286450308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_1024: total: calls: 1 - instructions: 451310650 + instructions: 411120605 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_128: total: calls: 1 - instructions: 277820518 + instructions: 267790518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_8_128: total: calls: 1 - instructions: 298460561 + instructions: 288930561 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_principal: total: calls: 1 - instructions: 369050381 + instructions: 367680381 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_u64_u64: total: calls: 1 - instructions: 230100393 + instructions: 225220393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_vec_32_128: total: calls: 1 - instructions: 237800563 + instructions: 220710488 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_vec_32_vec128: total: calls: 1 - instructions: 237800563 + instructions: 220710488 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1031,63 +1031,63 @@ benches: btreemap_v2_last_key_value_blob_256_128: total: calls: 1 - instructions: 706560395 + instructions: 678910395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_0: total: calls: 1 - instructions: 219850308 + instructions: 218260308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_1024: total: calls: 1 - instructions: 394180650 + instructions: 372530605 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_128: total: calls: 1 - instructions: 278760506 + instructions: 259790251 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_8_128: total: calls: 1 - instructions: 321680393 + instructions: 316780336 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_principal: total: calls: 1 - instructions: 215580393 + instructions: 214210393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_u64_u64: total: calls: 1 - instructions: 239770393 + instructions: 234890393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_vec_32_128: total: calls: 1 - instructions: 228280383 + instructions: 212850353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_vec_32_vec128: total: calls: 1 - instructions: 228280383 + instructions: 212850353 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1199,35 +1199,35 @@ benches: btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4318264089 + instructions: 4310637668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 884221878 + instructions: 881541070 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 737633885 + instructions: 737072163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1227061267 + instructions: 1222325400 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3091615290 + instructions: 3085941539 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1892,315 +1892,315 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 587219554 + instructions: 586491562 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7380945702 + instructions: 7366966085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1593945964 + instructions: 1591103378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 668346721 + instructions: 667203409 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2428665438 + instructions: 2424073742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 657054660 + instructions: 656823951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 989236869 + instructions: 984845060 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 749783761 + instructions: 748533037 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 752511933 + instructions: 751281404 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 703141681 + instructions: 702424855 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 787413760 + instructions: 785587505 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 715003607 + instructions: 714204226 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 699278245 + instructions: 698714136 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 861498997 + instructions: 858755621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 740289607 + instructions: 739330042 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 699125050 + instructions: 698473677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 454682836 + instructions: 454029581 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4081738108 + instructions: 4074091720 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 914236119 + instructions: 912079035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 601987691 + instructions: 601047924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 686011662 + instructions: 685803970 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 568628695 + instructions: 568074290 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 589333082 + instructions: 588737461 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 593963739 + instructions: 593186627 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 573947282 + instructions: 573326526 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 757158552 + instructions: 757083966 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4484339250 + instructions: 4507222490 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1421624432 + instructions: 1418898658 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 921855821 + instructions: 921961126 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2249185934 + instructions: 2245143515 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 837031955 + instructions: 835914939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1705626988 + instructions: 1698100163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1039694098 + instructions: 1037931131 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1041049532 + instructions: 1038789215 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 874042905 + instructions: 872651408 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1243862175 + instructions: 1240155821 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 870253828 + instructions: 868832411 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 864896239 + instructions: 863537631 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1409920538 + instructions: 1404798720 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 971239576 + instructions: 970144302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 859201513 + instructions: 857834613 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 663572357 + instructions: 662322339 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3085455727 + instructions: 3080244795 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1186047737 + instructions: 1184683241 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 824201684 + instructions: 822418003 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap.rs b/src/btreemap.rs index 7bdbd689..8d9dca67 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -882,17 +882,13 @@ where #[inline(always)] fn first_entry_inner(&self, node: &Node) -> Entry { - self.find_first_or_last(node, true, 0, |n, i, m| { - let (k, v) = n.get_key_read_value_uncached(i, m); - (k.clone(), v.to_vec()) - }) + self.find_first_or_last(node, true, 0, |n, i, m| n.get_key_read_value_uncached(i, m)) } #[inline(always)] fn last_entry_inner(&self, node: &Node) -> Entry { self.find_first_or_last(node, false, 0, |n, i, m| { - let (k, v) = n.get_key_read_value_uncached(i, m); - (k.clone(), v.to_vec()) + n.get_key_read_value_uncached(i, m) }) } From 766eaf0d152c7e86eb899630a766e842ac17e90b Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 30 Mar 2026 15:50:58 +0200 Subject: [PATCH 38/42] distinguish cold vs collision misses --- benchmarks/btreemap/canbench_results.yml | 500 +++++++++++------------ src/btreemap/node_cache.rs | 52 ++- 2 files changed, 290 insertions(+), 262 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 27a7ec8c..89e48668 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -44,77 +44,77 @@ benches: btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 327582551 + instructions: 327632547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 325084223 + instructions: 325134219 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 325072732 + instructions: 325122728 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 203592179 + instructions: 204023063 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 317936089 + instructions: 317986085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 323289930 + instructions: 323339926 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 327522622 + instructions: 327572618 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 321334996 + instructions: 321384992 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 321287926 + instructions: 321337922 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 323885313 + instructions: 323935309 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 323261460 + instructions: 323311456 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -135,7 +135,7 @@ benches: btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 401675595 + instructions: 401725591 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -149,7 +149,7 @@ benches: btreemap_v2_contains_principal: total: calls: 1 - instructions: 347269491 + instructions: 347318138 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -170,7 +170,7 @@ benches: btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 137815001 + instructions: 138195415 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -184,203 +184,203 @@ benches: btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 374287631 + instructions: 374336225 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1851999694 + instructions: 1852048365 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 560305376 + instructions: 560354035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 432918289 + instructions: 432967006 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 892056749 + instructions: 892105414 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 358129019 + instructions: 358177703 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 486488778 + instructions: 486537462 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 413988026 + instructions: 414036727 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 252990321 + instructions: 253427506 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 365840124 + instructions: 365888800 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 432142747 + instructions: 432191447 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 355422941 + instructions: 355471618 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 368139323 + instructions: 368188002 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 451147090 + instructions: 451195769 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 402261447 + instructions: 402310117 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 368580150 + instructions: 368628845 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 397887233 + instructions: 397925491 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1228525326 + instructions: 1228573986 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 494586172 + instructions: 494634855 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 391602201 + instructions: 391650824 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_256_128: total: calls: 1 - instructions: 696560395 + instructions: 696540395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_0: total: calls: 1 - instructions: 286450308 + instructions: 286430308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_1024: total: calls: 1 - instructions: 411120605 + instructions: 411100605 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_128: total: calls: 1 - instructions: 267790518 + instructions: 267770518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_8_128: total: calls: 1 - instructions: 288930561 + instructions: 288910561 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_principal: total: calls: 1 - instructions: 367680381 + instructions: 367660381 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_u64_u64: total: calls: 1 - instructions: 225220393 + instructions: 225200393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_vec_32_128: total: calls: 1 - instructions: 220710488 + instructions: 220690488 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_vec_32_vec128: total: calls: 1 - instructions: 220710488 + instructions: 220690488 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -429,77 +429,77 @@ benches: btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 329282625 + instructions: 329332621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 335707225 + instructions: 335757221 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 330002455 + instructions: 330052451 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 208189615 + instructions: 208620499 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 322176383 + instructions: 322226379 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 328876906 + instructions: 328926902 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 331911453 + instructions: 331961449 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 325056537 + instructions: 325106533 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 328874477 + instructions: 328924473 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 328445967 + instructions: 328495963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 327293534 + instructions: 327343530 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -520,7 +520,7 @@ benches: btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 406724865 + instructions: 406774861 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -534,7 +534,7 @@ benches: btreemap_v2_get_principal: total: calls: 1 - instructions: 349140682 + instructions: 349189329 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -555,7 +555,7 @@ benches: btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 142477680 + instructions: 142858094 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -569,525 +569,525 @@ benches: btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 379065741 + instructions: 379114335 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1862510296 + instructions: 1862558967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 568109880 + instructions: 568158539 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 439251037 + instructions: 439299754 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 900008713 + instructions: 900057378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 359977705 + instructions: 360026389 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 509768549 + instructions: 509817233 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 420547701 + instructions: 420596402 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 259515040 + instructions: 259952225 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 370499249 + instructions: 370547925 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 445168892 + instructions: 445217592 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 360241746 + instructions: 360290423 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 372678729 + instructions: 372727408 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 468037064 + instructions: 468085743 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 407452098 + instructions: 407500768 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 373159620 + instructions: 373208315 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 403956744 + instructions: 403995002 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1236382851 + instructions: 1236431511 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501591061 + instructions: 501639744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 397773760 + instructions: 397822383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4389919149 + instructions: 4389919128 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 437998979 + instructions: 437988978 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5497633998 + instructions: 5497623997 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1182253513 + instructions: 1182243512 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 487641557 + instructions: 487631556 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1790452326 + instructions: 1790442325 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 491862059 + instructions: 491852058 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 704903558 + instructions: 704893557 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 543967485 + instructions: 543957484 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_128_cached_32entry: total: calls: 1 - instructions: 544890544 + instructions: 544880543 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 520527944 + instructions: 520517943 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 572096483 + instructions: 572086482 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 530359314 + instructions: 530349313 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 510784611 + instructions: 510774610 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 611466933 + instructions: 611456932 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 536327253 + instructions: 536317252 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 518992393 + instructions: 518982392 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 408602017 + instructions: 408592016 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3042639099 + instructions: 3042629098 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 662589979 + instructions: 662579978 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 460001267 + instructions: 459991266 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 503444425 + instructions: 503434424 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 407850609 + instructions: 407840608 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 415684319 + instructions: 415674318 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 416623860 + instructions: 416613859 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 411478774 + instructions: 411468773 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 594212048 + instructions: 594202047 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2744342963 + instructions: 2744332962 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1012517653 + instructions: 1012507652 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 709035399 + instructions: 709025398 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1401990782 + instructions: 1401980781 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 621952680 + instructions: 621942679 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1182073702 + instructions: 1182063701 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 756119602 + instructions: 756109601 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 757042661 + instructions: 757032660 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 666292168 + instructions: 666282167 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 869184356 + instructions: 869174355 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 661749069 + instructions: 661739068 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 660450353 + instructions: 660440352 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 973596882 + instructions: 973586881 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 691725130 + instructions: 691715129 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 659941521 + instructions: 659931520 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604436459 + instructions: 604426458 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1858895187 + instructions: 1858885186 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846295989 + instructions: 846285988 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 666351716 + instructions: 666341715 heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_last_key_value_blob_256_128: total: calls: 1 - instructions: 678910395 + instructions: 678890395 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_0: total: calls: 1 - instructions: 218260308 + instructions: 218240308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_1024: total: calls: 1 - instructions: 372530605 + instructions: 372510605 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_128: total: calls: 1 - instructions: 259790251 + instructions: 259770251 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_8_128: total: calls: 1 - instructions: 316780336 + instructions: 316760336 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_principal: total: calls: 1 - instructions: 214210393 + instructions: 214190393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_u64_u64: total: calls: 1 - instructions: 234890393 + instructions: 234870393 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_vec_32_128: total: calls: 1 - instructions: 212850353 + instructions: 212830353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_vec_32_vec128: total: calls: 1 - instructions: 212850353 + instructions: 212830353 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1234,154 +1234,154 @@ benches: btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 594314220 + instructions: 594298632 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8422908716 + instructions: 8422888730 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1818364668 + instructions: 1818344848 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 731551596 + instructions: 731533684 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2765148548 + instructions: 2765128630 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 752621403 + instructions: 752602327 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1084930626 + instructions: 1084911524 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 848198497 + instructions: 848179397 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 789569161 + instructions: 789550015 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 875028267 + instructions: 875009095 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 802327346 + instructions: 802308274 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 775160145 + instructions: 775141039 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 933830979 + instructions: 933811853 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 809226089 + instructions: 809207065 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 792100447 + instructions: 792081341 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 364805185 + instructions: 364794835 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4626110365 + instructions: 4626090405 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1022593048 + instructions: 1022573476 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 595061976 + instructions: 595046570 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 800318786 + instructions: 800299116 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 663296357 + instructions: 663276357 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 674304358 + instructions: 674284358 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1395,287 +1395,287 @@ benches: btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 765377892 + instructions: 765362322 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4030036967 + instructions: 4030016981 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1487348737 + instructions: 1487328919 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1002230175 + instructions: 1002212267 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2015632945 + instructions: 2015613029 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 863071058 + instructions: 863051988 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1624432709 + instructions: 1624413617 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1071142486 + instructions: 1071123390 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 919930241 + instructions: 919911099 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1191614673 + instructions: 1191595503 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 917369504 + instructions: 917350436 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 907823819 + instructions: 907804713 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1337413144 + instructions: 1337394022 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 957552492 + instructions: 957533470 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 918270058 + instructions: 918250956 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 527959240 + instructions: 527948918 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2703367257 + instructions: 2703347297 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1218518813 + instructions: 1218499243 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 830201491 + instructions: 830186107 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 570757555 + instructions: 570741967 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8093183703 + instructions: 8093163717 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1749240011 + instructions: 1749220191 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 705190915 + instructions: 705173003 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2670521862 + instructions: 2670501944 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 724619261 + instructions: 724600185 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1048954849 + instructions: 1048935747 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 813954982 + instructions: 813935882 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 761461989 + instructions: 761442843 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 844224348 + instructions: 844205176 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 769863719 + instructions: 769844647 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 751584493 + instructions: 751565387 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 908628107 + instructions: 908608981 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 783533000 + instructions: 783513976 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 763609790 + instructions: 763590684 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 351439292 + instructions: 351428942 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4456609510 + instructions: 4456589550 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 990635309 + instructions: 990615737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 589091401 + instructions: 589075995 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 780531856 + instructions: 780512186 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 640078677 + instructions: 640058677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 650557256 + instructions: 650537256 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1689,196 +1689,196 @@ benches: btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 745303447 + instructions: 745287877 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4236313308 + instructions: 4236293322 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1492783940 + instructions: 1492764122 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 982747493 + instructions: 982729585 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2055412449 + instructions: 2055392533 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 846358881 + instructions: 846339811 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1598776777 + instructions: 1598757685 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1046171015 + instructions: 1046151919 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 894751119 + instructions: 894731977 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1167787357 + instructions: 1167768187 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 897744527 + instructions: 897725459 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 892420612 + instructions: 892401506 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1318631304 + instructions: 1318612182 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 934947355 + instructions: 934928333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 895910092 + instructions: 895890990 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 513762891 + instructions: 513752569 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2789962967 + instructions: 2789943007 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1203565250 + instructions: 1203545680 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 829212998 + instructions: 829197614 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_0b: total: calls: 1 - instructions: 16941 + instructions: 16939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_1k_10kib: total: calls: 1 - instructions: 2513961 + instructions: 2513959 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_count_20_10mib: total: calls: 1 - instructions: 18468868 + instructions: 18468866 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_0b: total: calls: 1 - instructions: 16918 + instructions: 16916 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_1k_10kib: total: calls: 1 - instructions: 2579764 + instructions: 2579762 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_key_sum_20_10mib: total: calls: 1 - instructions: 18470107 + instructions: 18470105 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_0b: total: calls: 1 - instructions: 17285 + instructions: 17283 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_1k_10kib: total: calls: 1 - instructions: 20675388 + instructions: 20675386 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_range_value_sum_20_10mib: total: calls: 1 - instructions: 398305334 + instructions: 398305332 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1892,168 +1892,168 @@ benches: btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 586491562 + instructions: 586471564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7366966085 + instructions: 7366946085 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1591103378 + instructions: 1591083378 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 667203409 + instructions: 667183409 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2424073742 + instructions: 2424053742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 656823951 + instructions: 656803951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 984845060 + instructions: 984825060 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 748533037 + instructions: 748513037 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 751281404 + instructions: 751264983 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 702424855 + instructions: 702404855 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 785587505 + instructions: 785567505 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 714204226 + instructions: 714184226 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 698714136 + instructions: 698694136 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 858755621 + instructions: 858735621 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 739330042 + instructions: 739310042 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 698473677 + instructions: 698453677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 454029581 + instructions: 454009583 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4074091720 + instructions: 4074071720 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 912079035 + instructions: 912059035 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 601047924 + instructions: 601027924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 685803970 + instructions: 685783970 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 568074290 + instructions: 568054290 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 588737461 + instructions: 588717461 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 593186627 + instructions: 593170427 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -2067,7 +2067,7 @@ benches: btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 757083966 + instructions: 757063968 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -2102,7 +2102,7 @@ benches: btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 835914939 + instructions: 835894939 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -2123,7 +2123,7 @@ benches: btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1038789215 + instructions: 1038792690 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/src/btreemap/node_cache.rs b/src/btreemap/node_cache.rs index a1e0db9f..fa231740 100644 --- a/src/btreemap/node_cache.rs +++ b/src/btreemap/node_cache.rs @@ -6,8 +6,14 @@ use super::node::Node; /// Node-cache performance metrics. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub struct NodeCacheMetrics { - hits_counter: u64, - misses_counter: u64, + /// Successful cache lookups. + hit_counter: u64, + + /// Misses where the target slot was empty. + cold_miss_counter: u64, + + /// Misses where the slot was occupied by a different node. + collision_miss_counter: u64, } impl NodeCacheMetrics { @@ -17,20 +23,34 @@ impl NodeCacheMetrics { /// Resets all counters to zero. pub fn clear_counters(&mut self) { - self.hits_counter = 0; - self.misses_counter = 0; + self.hit_counter = 0; + self.cold_miss_counter = 0; + self.collision_miss_counter = 0; } + /// Returns the number of successful cache lookups. pub fn hits(&self) -> u64 { - self.hits_counter + self.hit_counter + } + + /// Returns the number of cache misses where the target slot was empty. + pub fn cold_misses(&self) -> u64 { + self.cold_miss_counter } + /// Returns the number of cache misses where the slot was occupied by a different node. + pub fn collision_misses(&self) -> u64 { + self.collision_miss_counter + } + + /// Returns the total number of cache misses. pub fn misses(&self) -> u64 { - self.misses_counter + self.cold_miss_counter + self.collision_miss_counter } + /// Returns the total number of cache lookups (hits + misses). pub fn total(&self) -> u64 { - self.hits_counter + self.misses_counter + self.hit_counter + self.cold_miss_counter + self.collision_miss_counter } /// Returns the hit ratio as a value between 0.0 and 1.0. @@ -40,16 +60,20 @@ impl NodeCacheMetrics { if total == 0 { 0.0 } else { - self.hits_counter as f64 / total as f64 + self.hit_counter as f64 / total as f64 } } fn observe_hit(&mut self) { - self.hits_counter += 1; + self.hit_counter += 1; + } + + fn observe_cold_miss(&mut self) { + self.cold_miss_counter += 1; } - fn observe_miss(&mut self) { - self.misses_counter += 1; + fn observe_collision_miss(&mut self) { + self.collision_miss_counter += 1; } } @@ -135,7 +159,11 @@ impl NodeCache { slot.address = NULL; slot.node.take() } else { - self.metrics.observe_miss(); + if slot.node.is_none() { + self.metrics.observe_cold_miss(); + } else { + self.metrics.observe_collision_miss(); + } None } } From 13b5c8e9424101a800c015bcc8689360e4e6550d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Mon, 30 Mar 2026 16:29:32 +0200 Subject: [PATCH 39/42] Address review feedback: default cache=16, remove cache_num_slots, guard NULL - Change DEFAULT_NODE_CACHE_NUM_SLOTS from 0 to 16 (covers top 2 tree levels) - Remove redundant cache_num_slots field from BTreeMap; NodeCache methods now self-guard via is_enabled() and callers no longer need checks - Add NULL address guard in NodeCache::take to prevent false cache hits --- src/btreemap.rs | 55 ++++++++++++++------------------------ src/btreemap/node_cache.rs | 12 ++++++--- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 8d9dca67..2863c275 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -87,12 +87,14 @@ const PAGE_SIZE_VALUE_MARKER: u32 = u32::MAX; /// Default number of slots in the direct-mapped node cache. /// -/// The cache is disabled by default (0 slots) to avoid unexpected heap -/// usage. Users can opt in via [`BTreeMap::with_node_cache`] or -/// [`BTreeMap::node_cache_resize`]. +/// 16 slots cover the top two tree levels (1 root + up to 12 children = +/// 13 nodes) while keeping heap usage modest. The depth-aware eviction +/// policy ensures these upper-level nodes stay cached even under +/// collisions from deeper traversals. /// -/// See [`BTreeMap::with_node_cache`] for guidance on choosing a size. -const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 0; +/// Users can adjust via [`BTreeMap::with_node_cache`] or +/// [`BTreeMap::node_cache_resize`], including setting to 0 to disable. +const DEFAULT_NODE_CACHE_NUM_SLOTS: usize = 16; /// A B-Tree map implementation that stores its data into a designated memory. /// @@ -261,10 +263,6 @@ where // The number of elements in the map. length: u64, - // Number of slots in the direct-mapped node cache. - // Stored so we can recreate the cache with the same configuration on clear(). - cache_num_slots: usize, - // Direct-mapped node cache to avoid re-loading hot nodes from stable memory. cache: RefCell>, @@ -363,7 +361,6 @@ where /// } /// ``` pub fn node_cache_resize(&mut self, num_slots: usize) { - self.cache_num_slots = num_slots; *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); } @@ -412,7 +409,7 @@ where /// occupied. Treat this as an order-of-magnitude guide, not a /// precise budget. pub fn node_cache_size_bytes_approx(&self) -> usize { - self.cache_num_slots + self.cache.borrow().num_slots() * (self.version.page_size().get() as usize + NodeCache::::slot_size()) } @@ -485,7 +482,6 @@ where ), version: Version::V2(page_size), length: 0, - cache_num_slots: DEFAULT_NODE_CACHE_NUM_SLOTS, cache: RefCell::new(NodeCache::new( page_size.get(), DEFAULT_NODE_CACHE_NUM_SLOTS, @@ -519,7 +515,6 @@ where ), version, length: 0, - cache_num_slots: DEFAULT_NODE_CACHE_NUM_SLOTS, cache: RefCell::new(NodeCache::new( version.page_size().get(), DEFAULT_NODE_CACHE_NUM_SLOTS, @@ -573,7 +568,6 @@ where allocator: Allocator::load(memory, allocator_addr), version, length: header.length, - cache_num_slots: DEFAULT_NODE_CACHE_NUM_SLOTS, cache: RefCell::new(NodeCache::new( version.page_size().get(), DEFAULT_NODE_CACHE_NUM_SLOTS, @@ -923,8 +917,9 @@ where self.root_addr = NULL; self.length = 0; self.allocator.clear(); + let num_slots = self.cache.get_mut().num_slots(); *self.cache.get_mut() = - NodeCache::new(self.version.page_size().get(), self.cache_num_slots); + NodeCache::new(self.version.page_size().get(), num_slots); self.save_header(); } @@ -1489,13 +1484,11 @@ where fn merge(&mut self, source: Node, mut into: Node, median: Entry) -> Node { let source_addr = source.address(); into.merge(source, median, &mut self.allocator); - if self.cache_num_slots > 0 { - // Node::merge saves `into` and deallocates `source` directly through - // the allocator, so we must invalidate both cache slots here. - let cache = self.cache.get_mut(); - cache.invalidate(into.address()); - cache.invalidate(source_addr); - } + // Node::merge saves `into` and deallocates `source` directly through + // the allocator, so we must invalidate both cache slots here. + let cache = self.cache.get_mut(); + cache.invalidate(into.address()); + cache.invalidate(source_addr); into } @@ -1512,9 +1505,7 @@ where fn deallocate_node(&mut self, node: Node) { let addr = node.address(); node.deallocate(self.allocator_mut()); - if self.cache_num_slots > 0 { - self.cache.get_mut().invalidate(addr); - } + self.cache.get_mut().invalidate(addr); } /// Takes a node from the cache, or loads it from memory if not cached. @@ -1523,10 +1514,8 @@ where /// done to put the node back into the cache. #[inline(always)] fn take_or_load_node(&self, address: Address) -> Node { - if self.cache_num_slots > 0 { - if let Some(node) = self.cache.borrow_mut().take(address) { - return node; - } + if let Some(node) = self.cache.borrow_mut().take(address) { + return node; } Node::load(address, self.version.page_size(), self.memory()) } @@ -1537,9 +1526,7 @@ where /// this to prefer keeping shallower nodes on slot collisions. #[inline(always)] fn return_node(&self, node: Node, depth: u8) { - if self.cache_num_slots > 0 { - self.cache.borrow_mut().put(node.address(), node, depth); - } + self.cache.borrow_mut().put(node.address(), node, depth); } /// Loads a node from memory, bypassing the cache. @@ -1552,9 +1539,7 @@ where #[inline] fn save_node(&mut self, node: &mut Node) { node.save(self.allocator_mut()); - if self.cache_num_slots > 0 { - self.cache.get_mut().invalidate(node.address()); - } + self.cache.get_mut().invalidate(node.address()); } /// Replaces the value at `idx` in the node, saves the node, and returns the old value. diff --git a/src/btreemap/node_cache.rs b/src/btreemap/node_cache.rs index fa231740..54878f38 100644 --- a/src/btreemap/node_cache.rs +++ b/src/btreemap/node_cache.rs @@ -151,7 +151,9 @@ impl NodeCache { } pub(super) fn take(&mut self, addr: Address) -> Option> { - debug_assert!(self.is_enabled()); + if !self.is_enabled() || addr == NULL { + return None; + } let idx = self.slot_index(addr); let slot = &mut self.slots[idx]; if slot.address == addr { @@ -169,7 +171,9 @@ impl NodeCache { } pub(super) fn put(&mut self, addr: Address, node: Node, depth: u8) { - debug_assert!(self.is_enabled()); + if !self.is_enabled() { + return; + } let idx = self.slot_index(addr); let slot = &mut self.slots[idx]; // Only evict an existing cached node if the new node is at the @@ -186,7 +190,9 @@ impl NodeCache { } pub(super) fn invalidate(&mut self, addr: Address) { - debug_assert!(self.is_enabled()); + if !self.is_enabled() { + return; + } let idx = self.slot_index(addr); let slot = &mut self.slots[idx]; if slot.address == addr { From 4eeb6e42e72f51f8904ace6e342b42bc87ab8da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Mon, 30 Mar 2026 16:36:33 +0200 Subject: [PATCH 40/42] fmt --- src/btreemap.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/btreemap.rs b/src/btreemap.rs index 2863c275..cd721f7e 100644 --- a/src/btreemap.rs +++ b/src/btreemap.rs @@ -918,8 +918,7 @@ where self.length = 0; self.allocator.clear(); let num_slots = self.cache.get_mut().num_slots(); - *self.cache.get_mut() = - NodeCache::new(self.version.page_size().get(), num_slots); + *self.cache.get_mut() = NodeCache::new(self.version.page_size().get(), num_slots); self.save_header(); } From c0a31e68576da7f1da675a30bf3aad494b22db9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Mon, 30 Mar 2026 16:55:21 +0200 Subject: [PATCH 41/42] update results --- benchmarks/io_chunks/canbench_results.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarks/io_chunks/canbench_results.yml b/benchmarks/io_chunks/canbench_results.yml index 335016b8..291fa9ef 100644 --- a/benchmarks/io_chunks/canbench_results.yml +++ b/benchmarks/io_chunks/canbench_results.yml @@ -2,21 +2,21 @@ benches: read_chunks_btreemap_1: total: calls: 1 - instructions: 148723478 + instructions: 148723445 heap_increase: 1601 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1k: total: calls: 1 - instructions: 508817794 + instructions: 221249476 heap_increase: 0 stable_memory_increase: 0 scopes: {} read_chunks_btreemap_1m: total: calls: 1 - instructions: 39710943416 + instructions: 27602178570 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -65,21 +65,21 @@ benches: write_chunks_btreemap_1: total: calls: 1 - instructions: 357205402 + instructions: 357205465 heap_increase: 13 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1k: total: calls: 1 - instructions: 4187131611 + instructions: 4187223807 heap_increase: 2 stable_memory_increase: 1536 scopes: {} write_chunks_btreemap_1m: total: calls: 1 - instructions: 83679286075 + instructions: 83761099339 heap_increase: 0 stable_memory_increase: 3072 scopes: {} From 36ea72dc6fd7fc4f997e308640cd782c9b1f261f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Mon, 30 Mar 2026 16:58:38 +0200 Subject: [PATCH 42/42] Update more results --- benchmarks/btreemap/canbench_results.yml | 612 +++++++++++------------ benchmarks/btreeset/canbench_results.yml | 60 +-- 2 files changed, 336 insertions(+), 336 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 89e48668..9e874a32 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -2,1820 +2,1820 @@ benches: btreemap_v2_contains_10mib_values: total: calls: 1 - instructions: 142223662 + instructions: 18487316 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob8_u64: total: calls: 1 - instructions: 292685771 + instructions: 190866446 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_1024_128: total: calls: 1 - instructions: 4279092806 + instructions: 2745826594 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_128_128: total: calls: 1 - instructions: 821487537 + instructions: 521890139 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_16_128: total: calls: 1 - instructions: 293769551 + instructions: 204999508 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_256_128: total: calls: 1 - instructions: 1311214897 + instructions: 837636513 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_0: total: calls: 1 - instructions: 327632547 + instructions: 260389017 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 - instructions: 325134219 + instructions: 259568366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128: total: calls: 1 - instructions: 325122728 + instructions: 220766479 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_128_cached_32entry: total: calls: 1 - instructions: 204023063 + instructions: 203445023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_16: total: calls: 1 - instructions: 317986085 + instructions: 223359605 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_256: total: calls: 1 - instructions: 323339926 + instructions: 227154559 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_32: total: calls: 1 - instructions: 327572618 + instructions: 216646298 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_4: total: calls: 1 - instructions: 321384992 + instructions: 213046747 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_512: total: calls: 1 - instructions: 321337922 + instructions: 237371213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_64: total: calls: 1 - instructions: 323935309 + instructions: 217749133 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_32_8: total: calls: 1 - instructions: 323311456 + instructions: 222082827 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_4_128: total: calls: 1 - instructions: 245206191 + instructions: 162546599 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_512_128: total: calls: 1 - instructions: 2282890401 + instructions: 1387676926 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_64_128: total: calls: 1 - instructions: 401725591 + instructions: 312151825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_blob_8_128: total: calls: 1 - instructions: 266158160 + instructions: 183077569 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_principal: total: calls: 1 - instructions: 347318138 + instructions: 218885203 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 - instructions: 219090518 + instructions: 174163949 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64: total: calls: 1 - instructions: 222211872 + instructions: 150146241 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_u64_cached_32entry: total: calls: 1 - instructions: 138195415 + instructions: 137781724 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_u64_vec8: total: calls: 1 - instructions: 219090518 + instructions: 149576864 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec8_u64: total: calls: 1 - instructions: 374336225 + instructions: 250281500 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_1024_128: total: calls: 1 - instructions: 1852048365 + instructions: 1229629567 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_128_128: total: calls: 1 - instructions: 560354035 + instructions: 434047319 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_16_128: total: calls: 1 - instructions: 432967006 + instructions: 308921267 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_256_128: total: calls: 1 - instructions: 892105414 + instructions: 591763504 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_0: total: calls: 1 - instructions: 358177703 + instructions: 246316312 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 - instructions: 486537462 + instructions: 385105811 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128: total: calls: 1 - instructions: 414036727 + instructions: 275225218 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_128_cached_32entry: total: calls: 1 - instructions: 253427506 + instructions: 253190470 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_16: total: calls: 1 - instructions: 365888800 + instructions: 282727791 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_256: total: calls: 1 - instructions: 432191447 + instructions: 292090511 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_32: total: calls: 1 - instructions: 355471618 + instructions: 234685816 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_4: total: calls: 1 - instructions: 368188002 + instructions: 250559234 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_512: total: calls: 1 - instructions: 451195769 + instructions: 296343263 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_64: total: calls: 1 - instructions: 402310117 + instructions: 251900104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_32_8: total: calls: 1 - instructions: 368628845 + instructions: 241514541 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_4_128: total: calls: 1 - instructions: 397925491 + instructions: 199029083 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_512_128: total: calls: 1 - instructions: 1228573986 + instructions: 947878167 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_64_128: total: calls: 1 - instructions: 494634855 + instructions: 360352960 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_contains_vec_8_128: total: calls: 1 - instructions: 391650824 + instructions: 271100369 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_256_128: total: calls: 1 - instructions: 696540395 + instructions: 357274620 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_0: total: calls: 1 - instructions: 286430308 + instructions: 105199202 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_1024: total: calls: 1 - instructions: 411100605 + instructions: 259775303 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_32_128: total: calls: 1 - instructions: 267770518 + instructions: 110895781 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_blob_8_128: total: calls: 1 - instructions: 288910561 + instructions: 60451976 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_principal: total: calls: 1 - instructions: 367660381 + instructions: 36272978 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_u64_u64: total: calls: 1 - instructions: 225200393 + instructions: 89584255 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_vec_32_128: total: calls: 1 - instructions: 220690488 + instructions: 43405825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_first_key_value_vec_32_vec128: total: calls: 1 - instructions: 220690488 + instructions: 43405825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_10mib_values: total: calls: 1 - instructions: 388598817 + instructions: 264857573 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob8_u64: total: calls: 1 - instructions: 297236218 + instructions: 195543476 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_1024_128: total: calls: 1 - instructions: 4284126316 + instructions: 2751056037 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_128_128: total: calls: 1 - instructions: 826527400 + instructions: 527215932 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_16_128: total: calls: 1 - instructions: 298727270 + instructions: 209162931 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_256_128: total: calls: 1 - instructions: 1316236208 + instructions: 842757523 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_0: total: calls: 1 - instructions: 329332621 + instructions: 262099047 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 - instructions: 335757221 + instructions: 270483547 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128: total: calls: 1 - instructions: 330052451 + instructions: 226789019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_128_cached_32entry: total: calls: 1 - instructions: 208620499 + instructions: 208214692 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_16: total: calls: 1 - instructions: 322226379 + instructions: 227714787 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_256: total: calls: 1 - instructions: 328926902 + instructions: 231105517 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_32: total: calls: 1 - instructions: 331961449 + instructions: 221148008 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_4: total: calls: 1 - instructions: 325106533 + instructions: 216721043 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_512: total: calls: 1 - instructions: 328924473 + instructions: 245550022 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_64: total: calls: 1 - instructions: 328495963 + instructions: 222604292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_32_8: total: calls: 1 - instructions: 327343530 + instructions: 226309755 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_4_128: total: calls: 1 - instructions: 250296429 + instructions: 167469456 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_512_128: total: calls: 1 - instructions: 2287929309 + instructions: 1392648068 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_64_128: total: calls: 1 - instructions: 406774861 + instructions: 317208122 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_blob_8_128: total: calls: 1 - instructions: 271278579 + instructions: 188373567 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_principal: total: calls: 1 - instructions: 349189329 + instructions: 220745930 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 - instructions: 223251421 + instructions: 178433733 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64: total: calls: 1 - instructions: 226773660 + instructions: 154859979 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_u64_cached_32entry: total: calls: 1 - instructions: 142858094 + instructions: 142473442 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_u64_vec8: total: calls: 1 - instructions: 223555445 + instructions: 154183289 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec8_u64: total: calls: 1 - instructions: 379114335 + instructions: 254966114 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_1024_128: total: calls: 1 - instructions: 1862558967 + instructions: 1232977815 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_128_128: total: calls: 1 - instructions: 568158539 + instructions: 442162059 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_16_128: total: calls: 1 - instructions: 439299754 + instructions: 314796155 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_256_128: total: calls: 1 - instructions: 900057378 + instructions: 599702682 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_0: total: calls: 1 - instructions: 360026389 + instructions: 248154998 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 - instructions: 509817233 + instructions: 408277407 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128: total: calls: 1 - instructions: 420596402 + instructions: 281606366 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_128_cached_32entry: total: calls: 1 - instructions: 259952225 + instructions: 259427446 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_16: total: calls: 1 - instructions: 370547925 + instructions: 287385411 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_256: total: calls: 1 - instructions: 445217592 + instructions: 305273472 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_32: total: calls: 1 - instructions: 360290423 + instructions: 239508446 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_4: total: calls: 1 - instructions: 372727408 + instructions: 255096697 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_512: total: calls: 1 - instructions: 468085743 + instructions: 313471965 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_64: total: calls: 1 - instructions: 407500768 + instructions: 257185963 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_32_8: total: calls: 1 - instructions: 373208315 + instructions: 246126428 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_4_128: total: calls: 1 - instructions: 403995002 + instructions: 206362584 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_512_128: total: calls: 1 - instructions: 1236431511 + instructions: 956146473 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_64_128: total: calls: 1 - instructions: 501639744 + instructions: 365470697 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_get_vec_8_128: total: calls: 1 - instructions: 397822383 + instructions: 277255371 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4389919128 + instructions: 4388594466 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 437988978 + instructions: 437518117 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5497623997 + instructions: 5497155337 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1182243512 + instructions: 1181773320 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 487631556 + instructions: 487161376 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1790442325 + instructions: 1789972362 heap_increase: 0 stable_memory_increase: 67 scopes: {} btreemap_v2_insert_blob_32_0: total: calls: 1 - instructions: 491852058 + instructions: 491382348 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 704893557 + instructions: 704424311 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 543957484 + instructions: 543489222 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_128_cached_32entry: total: calls: 1 - instructions: 544880543 + instructions: 547250959 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 520517943 + instructions: 520045244 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 572086482 + instructions: 571615430 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 530349313 + instructions: 529878058 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 510774610 + instructions: 510305152 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 611456932 + instructions: 610988635 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 536317252 + instructions: 535845644 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 518982392 + instructions: 518514257 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 408592016 + instructions: 408095693 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3042629098 + instructions: 3042158781 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 662579978 + instructions: 662108927 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 459991266 + instructions: 459499652 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_principal: total: calls: 1 - instructions: 503434424 + instructions: 502955163 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 407840608 + instructions: 407657131 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 415674318 + instructions: 415493019 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_u64_cached_32entry: total: calls: 1 - instructions: 416613859 + instructions: 418924062 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 411468773 + instructions: 411284692 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 594202047 + instructions: 593697044 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2744332962 + instructions: 2744207295 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1012507652 + instructions: 1012252802 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 709025398 + instructions: 708593539 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1401980781 + instructions: 1401822357 heap_increase: 0 stable_memory_increase: 71 scopes: {} btreemap_v2_insert_vec_32_0: total: calls: 1 - instructions: 621942679 + instructions: 621454653 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1182063701 + instructions: 1181733986 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 756109601 + instructions: 755701316 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_128_cached_32entry: total: calls: 1 - instructions: 757032660 + instructions: 761542120 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 666282167 + instructions: 665792239 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 869174355 + instructions: 868829647 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 661739068 + instructions: 661249696 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 660440352 + instructions: 659952868 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 973586881 + instructions: 973265238 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 691715129 + instructions: 691239859 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 659931520 + instructions: 659445704 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604426458 + instructions: 603957592 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1858885186 + instructions: 1858766935 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846285988 + instructions: 845917944 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 666341715 + instructions: 665880865 heap_increase: 0 stable_memory_increase: 23 scopes: {} btreemap_v2_last_key_value_blob_256_128: total: calls: 1 - instructions: 678890395 + instructions: 155462735 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_0: total: calls: 1 - instructions: 218240308 + instructions: 37288637 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_1024: total: calls: 1 - instructions: 372510605 + instructions: 173699450 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_32_128: total: calls: 1 - instructions: 259770251 + instructions: 127044145 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_blob_8_128: total: calls: 1 - instructions: 316760336 + instructions: 57605814 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_principal: total: calls: 1 - instructions: 214190393 + instructions: 36808140 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_u64_u64: total: calls: 1 - instructions: 234870393 + instructions: 85935483 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_vec_32_128: total: calls: 1 - instructions: 212830353 + instructions: 77963163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_last_key_value_vec_32_vec128: total: calls: 1 - instructions: 212830353 + instructions: 77963163 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_blob512_u64: total: calls: 1 - instructions: 2351261894 + instructions: 1436981353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_blob512: total: calls: 1 - instructions: 278410240 + instructions: 187512951 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_u64: total: calls: 1 - instructions: 282344189 + instructions: 182794655 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_u64_vec512: total: calls: 1 - instructions: 361879738 + instructions: 227186976 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_contains_vec512_u64: total: calls: 1 - instructions: 1261964478 + instructions: 845240448 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_blob512_u64: total: calls: 1 - instructions: 2358412262 + instructions: 1442261937 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_blob512: total: calls: 1 - instructions: 286914372 + instructions: 196845917 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_u64: total: calls: 1 - instructions: 287697135 + instructions: 188253716 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_u64_vec512: total: calls: 1 - instructions: 376469616 + instructions: 242581254 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_get_vec512_u64: total: calls: 1 - instructions: 1270110599 + instructions: 852614860 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3127799623 + instructions: 3128595310 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: calls: 1 - instructions: 607417615 + instructions: 608184530 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 520696498 + instructions: 521422074 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 835225431 + instructions: 834542320 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1965714407 + instructions: 1965050153 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4310637668 + instructions: 4317284973 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 881541070 + instructions: 884299784 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 737072163 + instructions: 740576927 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1222325400 + instructions: 1223834839 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3085941539 + instructions: 3089920213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 594298632 + instructions: 526524907 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8422888730 + instructions: 7855696168 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1818344848 + instructions: 1681114794 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 731533684 + instructions: 650597207 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2765128630 + instructions: 2563783166 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_0: total: calls: 1 - instructions: 752602327 + instructions: 676545192 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1084911524 + instructions: 1012972252 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 848179397 + instructions: 766601761 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 789550015 + instructions: 717491826 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 875009095 + instructions: 804961009 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 802308274 + instructions: 726190961 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 775141039 + instructions: 704083608 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 933811853 + instructions: 866578104 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 809207065 + instructions: 733252539 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 792081341 + instructions: 717803472 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 364794835 + instructions: 330993070 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4626090405 + instructions: 4305463142 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1022573476 + instructions: 947838457 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 595046570 + instructions: 532804690 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 800299116 + instructions: 708330041 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 663276357 + instructions: 597232800 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 674284358 + instructions: 607615226 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 664718195 + instructions: 595770563 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 765362322 + instructions: 668791756 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4030016981 + instructions: 3902142510 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1487328919 + instructions: 1393314919 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1002212267 + instructions: 891006858 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2015613029 + instructions: 1897808921 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_0: total: calls: 1 - instructions: 863051988 + instructions: 815371704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1624413617 + instructions: 1530981619 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1071123390 + instructions: 1006825200 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 919911099 + instructions: 866752971 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1191595503 + instructions: 1122199250 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 917350436 + instructions: 871748240 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 907804713 + instructions: 856089097 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1337394022 + instructions: 1256461093 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 957533470 + instructions: 906576935 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 918250956 + instructions: 864608874 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 527948918 + instructions: 474105837 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2703347297 + instructions: 2590959832 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1218499243 + instructions: 1143063407 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 830186107 + instructions: 738309667 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 570741967 + instructions: 503220839 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8093163717 + instructions: 7525880697 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1749220191 + instructions: 1605196486 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 705173003 + instructions: 626571949 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2670501944 + instructions: 2471409876 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_0: total: calls: 1 - instructions: 724600185 + instructions: 647253224 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1048935747 + instructions: 979578335 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 813935882 + instructions: 735320362 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 761442843 + instructions: 685268608 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 844205176 + instructions: 770998776 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 769844647 + instructions: 694158905 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 751565387 + instructions: 679147363 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 908608981 + instructions: 837269516 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 783513976 + instructions: 706269768 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 763590684 + instructions: 689550991 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 351428942 + instructions: 320548373 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4456589550 + instructions: 4149734890 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 990615737 + instructions: 914595427 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 589075995 + instructions: 522835198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 780512186 + instructions: 693951783 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 640058677 + instructions: 570346728 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 650537256 + instructions: 587932854 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 641401604 + instructions: 572784739 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 745287877 + instructions: 652714501 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4236293322 + instructions: 4110855988 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1492764122 + instructions: 1400965759 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 982729585 + instructions: 870964686 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2055392533 + instructions: 1939572333 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_0: total: calls: 1 - instructions: 846339811 + instructions: 796509253 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1598757685 + instructions: 1504191865 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1046151919 + instructions: 981373278 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 894731977 + instructions: 844711803 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1167768187 + instructions: 1094746788 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 897725459 + instructions: 846271228 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 892401506 + instructions: 840787748 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1318612182 + instructions: 1237983370 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 934928333 + instructions: 884400431 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 895890990 + instructions: 845101668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 513752569 + instructions: 463359572 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2789943007 + instructions: 2671605052 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1203545680 + instructions: 1126523022 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 829197614 + instructions: 733789281 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1885,322 +1885,322 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4711741009 + instructions: 4711120592 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 586471564 + instructions: 587288184 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7366946085 + instructions: 7373845361 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1591083378 + instructions: 1591020713 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 667183409 + instructions: 667644572 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2424053742 + instructions: 2424532891 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_0: total: calls: 1 - instructions: 656803951 + instructions: 656956704 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 984825060 + instructions: 985516198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 748513037 + instructions: 748466705 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128_cached_32entry: total: calls: 1 - instructions: 751264983 + instructions: 752240571 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 702404855 + instructions: 703360548 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 785567505 + instructions: 785781670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 714184226 + instructions: 714524111 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 698694136 + instructions: 700130513 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 858735621 + instructions: 859816314 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 739310042 + instructions: 739877243 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 698453677 + instructions: 699356802 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 454009583 + instructions: 454094474 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4074071720 + instructions: 4076921021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 912059035 + instructions: 912206065 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 601027924 + instructions: 601518872 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_principal: total: calls: 1 - instructions: 685783970 + instructions: 687168107 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 568054290 + instructions: 568800596 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 588717461 + instructions: 590519353 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64_cached_32entry: total: calls: 1 - instructions: 593170427 + instructions: 595457021 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 573326526 + instructions: 573925409 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 757063968 + instructions: 758675645 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4507222490 + instructions: 4479892836 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1418898658 + instructions: 1435761135 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 921961126 + instructions: 919017272 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2245143515 + instructions: 2245144869 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_0: total: calls: 1 - instructions: 835894939 + instructions: 836666300 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1698100163 + instructions: 1697016641 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1037931131 + instructions: 1037334019 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128_cached_32entry: total: calls: 1 - instructions: 1038792690 + instructions: 1036552032 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 872651408 + instructions: 871817785 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1240155821 + instructions: 1253983029 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 868832411 + instructions: 868969235 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 863537631 + instructions: 865658619 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1404798720 + instructions: 1405294406 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 970144302 + instructions: 969472805 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 857834613 + instructions: 858373919 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 662322339 + instructions: 660501564 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3080244795 + instructions: 3083490674 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1184683241 + instructions: 1183705186 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 822418003 + instructions: 821909237 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreeset/canbench_results.yml b/benchmarks/btreeset/canbench_results.yml index 04feea00..7031b5e1 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: 7266034104 + instructions: 7266956788 heap_increase: 1 stable_memory_increase: 256 scopes: {} btreeset_insert_blob_128: total: calls: 1 - instructions: 1636909134 + instructions: 1637831818 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_16: total: calls: 1 - instructions: 715806058 + instructions: 716728742 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_256: total: calls: 1 - instructions: 2445366853 + instructions: 2446289537 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_32: total: calls: 1 - instructions: 814860442 + instructions: 815783126 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_512: total: calls: 1 - instructions: 4049981168 + instructions: 4050903852 heap_increase: 0 stable_memory_increase: 128 scopes: {} btreeset_insert_blob_64: total: calls: 1 - instructions: 980610993 + instructions: 981533677 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_blob_8: total: calls: 1 - instructions: 694185093 + instructions: 695107777 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u32: total: calls: 1 - instructions: 540306595 + instructions: 541229279 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_insert_u64: total: calls: 1 - instructions: 561639674 + instructions: 562562358 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -422,140 +422,140 @@ benches: btreeset_range_blob_1024: total: calls: 1 - instructions: 259870198 + instructions: 259870196 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_128: total: calls: 1 - instructions: 45508441 + instructions: 45508439 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_16: total: calls: 1 - instructions: 9508607 + instructions: 9508605 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_256: total: calls: 1 - instructions: 76456413 + instructions: 76456411 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_32: total: calls: 1 - instructions: 13294159 + instructions: 13294157 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_512: total: calls: 1 - instructions: 137589175 + instructions: 137589173 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_64: total: calls: 1 - instructions: 24443490 + instructions: 24443488 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_blob_8: total: calls: 1 - instructions: 9144618 + instructions: 9144616 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_u32: total: calls: 1 - instructions: 6480294 + instructions: 6480292 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_range_u64: total: calls: 1 - instructions: 6624381 + instructions: 6624379 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_1024: total: calls: 1 - instructions: 7722770224 + instructions: 7723769472 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_128: total: calls: 1 - instructions: 1666436532 + instructions: 1667435780 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_16: total: calls: 1 - instructions: 705482522 + instructions: 706481770 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_256: total: calls: 1 - instructions: 2534147784 + instructions: 2535147032 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_32: total: calls: 1 - instructions: 802119271 + instructions: 803118519 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_512: total: calls: 1 - instructions: 4261483999 + instructions: 4262483247 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_64: total: calls: 1 - instructions: 987153140 + instructions: 988152388 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_blob_8: total: calls: 1 - instructions: 683603297 + instructions: 684602545 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u32: total: calls: 1 - instructions: 528185054 + instructions: 529154304 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreeset_remove_u64: total: calls: 1 - instructions: 553090759 + instructions: 554060009 heap_increase: 0 stable_memory_increase: 0 scopes: {}