Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8a8c9c3
perf: add direct-mapped node cache to BTreeMap
sasa-tomic Mar 18, 2026
06a4ef3
Merge branch 'main' into perf/direct-mapped-node-cache
sasa-tomic Mar 19, 2026
3ba9552
Merge branch 'main' into perf/direct-mapped-node-cache
sasa-tomic Mar 20, 2026
c3a1072
Update canbench results and add uncached reads
sasa-tomic Mar 20, 2026
1ab43e9
Update io-chunks perf
sasa-tomic Mar 20, 2026
cc81894
Make NodeCache size configurable at construction size, and track and …
sasa-tomic Mar 25, 2026
ec14e6d
fmt
sasa-tomic Mar 25, 2026
53c2c37
update results and reviews
sasa-tomic Mar 26, 2026
a4f64b4
Address reviews
sasa-tomic Mar 27, 2026
3313af0
optimize disabled cache case
sasa-tomic Mar 27, 2026
1100a19
rename and extend cache metrics
sasa-tomic Mar 27, 2026
9516ea9
Added an approximate node cache size in bytes
sasa-tomic Mar 27, 2026
a5ac1fc
Add cache tests and fix clippy
sasa-tomic Mar 27, 2026
d0dffc4
add mem_size
maksymar Mar 29, 2026
6515edf
add impl MemSize for Node
maksymar Mar 29, 2026
6fd83b3
add node_cache_memory_used
maksymar Mar 29, 2026
d32047f
subtract evicted on put
maksymar Mar 29, 2026
4a954b2
canbench persist
maksymar Mar 29, 2026
975bddb
update ByVal
maksymar Mar 29, 2026
7f69bdd
cleanup
maksymar Mar 29, 2026
259f35d
fix computing slot_index twice in put
maksymar Mar 29, 2026
b78ee0c
reduce nesting in traverse
maksymar Mar 29, 2026
ec1286f
use cache for first/last entries
maksymar Mar 29, 2026
0e0af37
optimize get min/max keys
maksymar Mar 29, 2026
11e3311
mem_size capacity
maksymar Mar 29, 2026
cb82ce8
add compare_cache_size_estimates test
maksymar Mar 29, 2026
8dc9a71
update test use cases
maksymar Mar 29, 2026
b9159fc
remove mem_size
maksymar Mar 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
654 changes: 369 additions & 285 deletions benchmarks/btreemap/canbench_results.yml

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions benchmarks/btreemap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K: TestKey, V: TestValue>() -> BenchResult {
let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32);
insert_helper::<K, V>(btree)
}

fn get_helper_v2_cached_32entry<K: TestKey, V: TestValue>() -> BenchResult {
let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32);
get_helper::<K, V>(btree)
}

fn remove_helper_v2_cached_32entry<K: TestKey, V: TestValue>() -> BenchResult {
let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32);
remove_helper::<K, V>(btree)
}

fn contains_helper_v2_cached_32entry<K: TestKey, V: TestValue>() -> BenchResult {
let btree = BTreeMap::new(DefaultMemoryImpl::default()).with_node_cache(32);
contains_helper::<K, V>(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() {}
60 changes: 30 additions & 30 deletions benchmarks/btreeset/canbench_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,70 @@ benches:
btreeset_insert_blob_1024:
total:
calls: 1
instructions: 7265892372
instructions: 7266034104
heap_increase: 1
stable_memory_increase: 256
scopes: {}
btreeset_insert_blob_128:
total:
calls: 1
instructions: 1636767402
instructions: 1636909134
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_blob_16:
total:
calls: 1
instructions: 715664326
instructions: 715806058
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_blob_256:
total:
calls: 1
instructions: 2445225121
instructions: 2445366853
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_blob_32:
total:
calls: 1
instructions: 814718710
instructions: 814860442
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_blob_512:
total:
calls: 1
instructions: 4049839436
instructions: 4049981168
heap_increase: 0
stable_memory_increase: 128
scopes: {}
btreeset_insert_blob_64:
total:
calls: 1
instructions: 980469261
instructions: 980610993
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_blob_8:
total:
calls: 1
instructions: 694043361
instructions: 694185093
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_u32:
total:
calls: 1
instructions: 540164863
instructions: 540306595
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_insert_u64:
total:
calls: 1
instructions: 561497942
instructions: 561639674
heap_increase: 0
stable_memory_increase: 0
scopes: {}
Expand Down Expand Up @@ -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: 7722770224
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_128:
total:
calls: 1
instructions: 1666415454
instructions: 1666436532
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_16:
total:
calls: 1
instructions: 705483928
instructions: 705482522
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_256:
total:
calls: 1
instructions: 2534126706
instructions: 2534147784
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_32:
total:
calls: 1
instructions: 802114863
instructions: 802119271
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_512:
total:
calls: 1
instructions: 4261462921
instructions: 4261483999
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_64:
total:
calls: 1
instructions: 987128732
instructions: 987153140
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_blob_8:
total:
calls: 1
instructions: 683601373
instructions: 683603297
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_u32:
total:
calls: 1
instructions: 528154844
instructions: 528185054
heap_increase: 0
stable_memory_increase: 0
scopes: {}
btreeset_remove_u64:
total:
calls: 1
instructions: 553060549
instructions: 553090759
heap_increase: 0
stable_memory_increase: 0
scopes: {}
Expand Down
18 changes: 9 additions & 9 deletions benchmarks/io_chunks/canbench_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ benches:
read_chunks_btreemap_1:
total:
calls: 1
instructions: 148723585
instructions: 148723478
heap_increase: 1601
stable_memory_increase: 0
scopes: {}
read_chunks_btreemap_1k:
total:
calls: 1
instructions: 498228206
instructions: 508817794
heap_increase: 0
stable_memory_increase: 0
scopes: {}
read_chunks_btreemap_1m:
total:
calls: 1
instructions: 40940569325
instructions: 39710943416
heap_increase: 0
stable_memory_increase: 0
scopes: {}
Expand Down Expand Up @@ -65,21 +65,21 @@ benches:
write_chunks_btreemap_1:
total:
calls: 1
instructions: 360207245
instructions: 357205402
heap_increase: 13
stable_memory_increase: 1536
scopes: {}
write_chunks_btreemap_1k:
total:
calls: 1
instructions: 4194582593
instructions: 4187131611
heap_increase: 2
stable_memory_increase: 1536
scopes: {}
write_chunks_btreemap_1m:
total:
calls: 1
instructions: 83673829307
instructions: 83679286075
heap_increase: 0
stable_memory_increase: 3072
scopes: {}
Expand Down Expand Up @@ -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: {}
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/nns/src/nns_vote_cascading/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn set_up_worst_case<NS: NeuronStore>(
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::<Vec<_>>();
neuron_store.set_followees(
Expand Down
Loading
Loading