Skip to content

perf: lazy sibling loading in BTreeMap::remove#430

Draft
maksymar wants to merge 2 commits intomainfrom
maksym/lazy-sibling
Draft

perf: lazy sibling loading in BTreeMap::remove#430
maksymar wants to merge 2 commits intomainfrom
maksym/lazy-sibling

Conversation

@maksymar
Copy link
Copy Markdown
Contributor

@maksymar maksymar commented Apr 3, 2026

This PR implements lazy sibling loading in BTreeMap::remove to avoid redundant node reads.

In remove Case 3 (child at minimum), both left and right siblings were always loaded from stable memory even though only one may be needed. This change loads the left sibling first and skips loading the right sibling entirely when the left can donate an entry. Saves one node load in ~50% of rebalancing cases.

@maksymar maksymar changed the title perf: lazy simbling loading in remove for BTreeMap perf: lazy simbling loading in BTreeMap::remove Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

canbench 🏋 (dir: ./benchmarks/btreeset) 8de9da0 2026-04-03 08:24:19 UTC

./benchmarks/btreeset/canbench_results.yml is up to date
📦 canbench_results_btreeset.csv available in artifacts

---------------------------------------------------

Summary:
  instructions:
    status:   No significant changes 👍
    counts:   [total 100 | regressed 0 | improved 0 | new 0 | unchanged 100]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min -104.55K]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min -0.02%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 100 | regressed 0 | improved 0 | new 0 | unchanged 100]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 100 | regressed 0 | improved 0 | new 0 | unchanged 100]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------
CSV results saved to canbench_results.csv

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

canbench 🏋 (dir: ./benchmarks/memory_manager) 8de9da0 2026-04-03 08:23:56 UTC

./benchmarks/memory_manager/canbench_results.yml is up to date
📦 canbench_results_memory-manager.csv available in artifacts

---------------------------------------------------

Summary:
  instructions:
    status:   No significant changes 👍
    counts:   [total 3 | regressed 0 | improved 0 | new 0 | unchanged 3]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 3 | regressed 0 | improved 0 | new 0 | unchanged 3]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 3 | regressed 0 | improved 0 | new 0 | unchanged 3]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------
CSV results saved to canbench_results.csv

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

canbench 🏋 (dir: ./benchmarks/btreemap) 8de9da0 2026-04-03 08:25:32 UTC

./benchmarks/btreemap/canbench_results.yml is up to date
📦 canbench_results_btreemap.csv available in artifacts

---------------------------------------------------

Summary:
  instructions:
    status:   Improvements detected 🟢
    counts:   [total 252 | regressed 0 | improved 14 | new 0 | unchanged 238]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min -153.26M]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min -2.43%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 252 | regressed 0 | improved 0 | new 0 | unchanged 252]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 252 | regressed 0 | improved 0 | new 0 | unchanged 252]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------

Only significant changes:
| status | name                                    | calls |     ins |  ins Δ% | HI |  HI Δ% | SMI |  SMI Δ% |
|--------|-----------------------------------------|-------|---------|---------|----|--------|-----|---------|
|   -    | btreemap_v2_mem_manager_remove_u64_u64  |       | 721.09M |  -2.01% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_u64_vec8             |       | 561.22M |  -2.02% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_u64_blob8            |       | 555.94M |  -2.05% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_blob8_u64            |       | 573.17M |  -2.09% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_principal            |       | 668.11M |  -2.10% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_blob_8_128           |       | 586.96M |  -2.14% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_vec_4_128            |       | 646.55M |  -2.15% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_vec_8_128            |       | 801.76M |  -2.20% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_blob_32_0            |       | 640.15M |  -2.20% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_blob_16_128          |       | 650.35M |  -2.21% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_100k_u64_u64         |       |   6.78B |  -2.21% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_100k_u64_u64_nocache |       |   6.77B |  -2.21% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_vec_16_128           |       | 897.24M |  -2.23% |  0 |  0.00% |   0 |   0.00% |
|   -    | btreemap_v2_remove_vec8_u64             |       | 736.20M |  -2.43% |  0 |  0.00% |   0 |   0.00% |

ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change

---------------------------------------------------
CSV results saved to canbench_results.csv

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

canbench 🏋 (dir: ./benchmarks/io_chunks) 8de9da0 2026-04-03 08:24:49 UTC

./benchmarks/io_chunks/canbench_results.yml is up to date
📦 canbench_results_io_chunks.csv available in artifacts

---------------------------------------------------

Summary:
  instructions:
    status:   No significant changes 👍
    counts:   [total 18 | regressed 0 | improved 0 | new 0 | unchanged 18]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 18 | regressed 0 | improved 0 | new 0 | unchanged 18]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 18 | regressed 0 | improved 0 | new 0 | unchanged 18]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------
CSV results saved to canbench_results.csv

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

canbench 🏋 (dir: ./benchmarks/nns) 8de9da0 2026-04-03 08:24:14 UTC

./benchmarks/nns/canbench_results.yml is up to date
📦 canbench_results_nns.csv available in artifacts

---------------------------------------------------

Summary:
  instructions:
    status:   No significant changes 👍
    counts:   [total 16 | regressed 0 | improved 0 | new 0 | unchanged 16]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 16 | regressed 0 | improved 0 | new 0 | unchanged 16]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 16 | regressed 0 | improved 0 | new 0 | unchanged 16]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------
CSV results saved to canbench_results.csv

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

canbench 🏋 (dir: ./benchmarks/vec) 8de9da0 2026-04-03 08:23:55 UTC

./benchmarks/vec/canbench_results.yml is up to date
📦 canbench_results_vec.csv available in artifacts

---------------------------------------------------

Summary:
  instructions:
    status:   No significant changes 👍
    counts:   [total 16 | regressed 0 | improved 0 | new 0 | unchanged 16]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  heap_increase:
    status:   No significant changes 👍
    counts:   [total 16 | regressed 0 | improved 0 | new 0 | unchanged 16]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 16 | regressed 0 | improved 0 | new 0 | unchanged 16]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------
CSV results saved to canbench_results.csv

@maksymar maksymar changed the title perf: lazy simbling loading in BTreeMap::remove perf: lazy sibling loading in BTreeMap::remove Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant