Skip to content

Avoid rewriting the parent tree when removing an absent subtree value#1295

Merged
cberner merged 1 commit into
masterfrom
claude/multimap-remove-nonexistent-fix-j173wc
Jul 7, 2026
Merged

Avoid rewriting the parent tree when removing an absent subtree value#1295
cberner merged 1 commit into
masterfrom
claude/multimap-remove-nonexistent-fix-j173wc

Conversation

@cberner

@cberner cberner commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

MultimapTable::remove() computed whether the value existed in the subtree but then ran its re-insert block unconditionally. When the removed value was not present, subtree.remove() returned None and left the subtree untouched (delete_key leaves the root untouched when the key isn't found), yet the collection was still re-inserted into the parent tree. That copy-on-wrote the root→leaf path, queued the old pages to be freed, and could even flip the value-set from subtree back to inline storage — all for a logical no-op. The inline arm and Table::remove() already short-circuit correctly.

The fix returns early when the value was not present, matching the inline arm.

Impact

Contents, length, and integrity were already unaffected — this only removes the wasted write amplification for a common operation (removing a value that isn't present from a subtree-backed key).

Testing

  • New regression test multimap_remove_nonexistent_value_from_subtree_does_not_churn asserts that a no-op removal on a subtree-backed key allocates and frees zero pages. It fails before the fix (baseline 7 → 10 allocated pages from the transient CoW churn) and passes after.
  • Full gate green: cargo fmt --check, cargo clippy --all-targets --all-features, and cargo test --all-features (310 tests, 0 failures).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AHrwK7untocWhi8S4VV9V2


Generated by Claude Code

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.22%. Comparing base (88881b8) to head (caf2f37).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1295   +/-   ##
=======================================
  Coverage   90.21%   90.22%           
=======================================
  Files          36       36           
  Lines       16289    16320   +31     
=======================================
+ Hits        14695    14724   +29     
- Misses       1594     1596    +2     
Files with missing lines Coverage Δ
src/multimap_table.rs 93.65% <100.00%> (+0.01%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

MultimapTable::remove() computed whether the value existed in the subtree but
then ran the re-insert block unconditionally. When the value was not present,
subtree.remove() returned None and left the subtree untouched, yet the collection
was still re-inserted into the parent tree. That copy-on-wrote the root->leaf
path, queued the old pages to be freed, and could even flip the value-set from
subtree back to inline storage -- all for a logical no-op. The inline arm and
Table::remove() already short-circuit correctly.

Return early when the value was not present, matching the inline arm. Contents,
length, and integrity were already unaffected; this only removes the wasted write
amplification. Add a regression test that asserts a no-op remove on a
subtree-backed key allocates and frees no pages.

Assisted-by: Claude Code
Claude-Session: https://claude.ai/code/session_01AHrwK7untocWhi8S4VV9V2
Assisted-by: Claude
@cberner cberner force-pushed the claude/multimap-remove-nonexistent-fix-j173wc branch from 1345c63 to caf2f37 Compare July 7, 2026 22:17
@cberner cberner merged commit 6cb8bff into master Jul 7, 2026
8 checks passed
@cberner cberner deleted the claude/multimap-remove-nonexistent-fix-j173wc branch July 7, 2026 22:35
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