[storage/index] simplify+optimize Cursor#3760
Conversation
|
bugbot run |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
commonware-mcp | 2105050 | May 15 2026, 01:54 PM |
Benchmark resultsTip ✅ PASSED: No benchmark exceeded the regression threshold. Benchmark comparison table
Baseline commit(s): |
e749a19 to
cf31534
Compare
Deploying monorepo with
|
| Latest commit: |
2105050
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e88680b1.monorepo-eu0.pages.dev |
| Branch Preview URL: | https://unsafe-index-2.monorepo-eu0.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR refactors the shared index Cursor implementation to traverse and mutate the per-key linked list in place (using a simplified 3-state enum and pointer bookkeeping), removing the prior multi-phase “detach/reattach on Drop” approach. It also adjusts insertion/removal logic in the ordered/unordered index implementations to align with the new cursor behavior, and updates/adds tests (including a regression case for insert_and_prune on a vacant/pruned insert).
Changes:
- Replaced the previous 7-variant cursor phase machine with an in-place cursor using
State+NonNull<Record<V>>pointers. - Simplified
remove()for ordered/unordered indexes by directly removing the map entry and iterating the record chain to update metrics. - Updated index tests to match the new iteration/insertion ordering, and added a regression test ensuring prunable
insert_and_prunedoes not create an entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| storage/src/index/unordered.rs | Updates insert/remove mechanics to work with the simplified in-place cursor and maintain metrics. |
| storage/src/index/storage.rs | Replaces the cursor implementation with a pointer-based in-place traversal/mutation model and simplifies IndexEntry. |
| storage/src/index/partitioned/ordered.rs | Updates ordered-partitioned index tests to reflect the new per-key value iteration ordering. |
| storage/src/index/ordered.rs | Mirrors unordered index insert/remove changes for the BTree-backed implementation and updates related tests. |
| storage/src/index/mod.rs | Updates cursor docs, provides a default Unordered::prune impl, and adjusts/adds tests for the new semantics. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e749a19. Configure here.
1b149bb to
ca0a8fe
Compare
b36f5f2 to
9781a69
Compare
f32516d to
87255f4
Compare
29459f5 to
9c9d4ae
Compare
9c9d4ae to
61ef0d7
Compare
Replace the 7-variant Phase state machine with a simpler 3-state enum and raw pointer traversal. The new Cursor operates on the linked list in-place instead of detaching visited nodes into a "past" accumulator and reattaching on Drop. Also fixes a minor bug in previous impl and adds a regression test.
Exercises the full Cursor lifecycle (next, find, delete, insert, drop) on every key, revealing the ~59% speedup from the Cursor simplification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
15aeeff to
55ba772
Compare
|
Found an issue: Patch: |
|
Yeah this is the issue the QED bot turned up, looks like my fix wasn't a full fix though. (Admittedly I half hearted it since there really aren't supposed to be duplicate keys in the first place in an "immutable" db.). Any fix relying on insert() is going to be error prone since technically it doesn't guarantee the resulting order among collisions, but this patch is good enough for now (modulo one line noted below).
^^ This line isn't needed (duplicate locations aren't allowed). but otherwise I've applied this patch, and added a distinct regression test rather than patch the original one.
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #3760 +/- ##
==========================================
- Coverage 95.82% 95.77% -0.05%
==========================================
Files 471 472 +1
Lines 187680 189352 +1672
Branches 4415 4569 +154
==========================================
+ Hits 179851 181360 +1509
- Misses 6404 6475 +71
- Partials 1425 1517 +92
... and 57 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary
Updates
storage::indexcursor mutation to operate in place, avoiding the previous detach/reattach flow while preserving cursor semantics. Inserted collisions are now (typically) stored and returned in newest-first order, though contract continues to provide no ordering guarantee among colliding keys.Changes
prev/currentpointers.&mut Record.insert_and_pruneso vacant entries are not created when the incoming value is already prunable.removedrain owned collision chains directly while keeping metrics accurate.insert_and_prunebenchmarkResults
index::insert_and_prune/items=10000index::insert_and_prune/items=50000qmdb::apply_batch/directqmdb::apply_batch/uncomm_ancestorqmdb::apply_batch/comm_ancestorqmdb::apply_batch/comm_uncomm_chainqmdb::apply_batch/multi_uncomm