Skip to content

Immutable storage for mmap map index - #8828

Merged
agourlay merged 1 commit into
devfrom
immutable-mmap-map-index
Apr 30, 2026
Merged

agourlay merged 1 commit into
devfrom
immutable-mmap-map-index

Conversation

@agourlay

@agourlay agourlay commented Apr 28, 2026 •

Copy link
Copy Markdown
Member

Make the mmap map index immutable on disk, mirroring the change applied to the mmap numeric index in #8594 and the mmap text index in #8840.

  • MmapMapIndex no longer persists runtime deletions: BufferedUpdateBitSlice is replaced with an in-memory BitVec.

  • deleted.bin is now build-time only — it records the points whose payload was empty at build time. It joins values_to_points.bin, point_to_values.*, and mmap_field_index_config.json in immutable_files().

  • On reload, callers must re-supply the authoritative deletion mask via the new deleted_points: &BitSlice argument to MmapMapIndex::open / MapIndex::new_mmap / builder_mmap. The id-tracker is the source of
    truth at runtime.

  • The reload merges the build-time empty-payload bits with the caller-provided mask via bitor_assign, after resizing to point_to_values.len() (defaulting missing trailing entries to live).

  • flusher() is now a no-op; remove_point() only updates the in-memory bitvec.

  • ram_usage_bytes() now reports the in-memory deletion bitvec plus point_to_values for the mmap variant.

  • Added type-level docs on MmapMapIndex and method-level docs on flusher / remove_point describing the deletion durability contract.

@agourlay
agourlay marked this pull request as ready for review April 30, 2026 12:54
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9cc8e9f3-7a0b-4113-9983-0312156ec4d7

📥 Commits

Reviewing files that changed from the base of the PR and between 0918b05 and 3704bf7.

📒 Files selected for processing (4)
  • lib/segment/src/index/field_index/index_selector.rs
  • lib/segment/src/index/field_index/map_index/immutable_map_index.rs
  • lib/segment/src/index/field_index/map_index/mmap_map_index.rs
  • lib/segment/src/index/field_index/map_index/mod.rs

📝 Walkthrough

Walkthrough

This PR refactors deletion handling in mmap-backed map indexes. Instead of persisting runtime deletions through a BufferedUpdateBitSlice structure, the implementation now accepts an external deleted_points: &BitSlice parameter that is cloned into an in-memory BitVec. Runtime deletions are applied only to the in-memory bitmap and no longer persist to disk. The public APIs of MapIndex::new_mmap/builder_mmap and MmapMapIndex::open/build are updated to require the deleted points bitset as a parameter, with corresponding updates to index selector logic. Regression tests validate deletion behavior after reload and when bitset coverage is partial.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested reviewers

  • ffuugoo
  • coszio
  • JojiiOfficial
  • generall
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Immutable storage for mmap map index' directly describes the main change: making mmap map index immutable on disk, which is the primary objective of this PR.
Description check ✅ Passed The description clearly explains the purpose, implementation details, and behavior changes including deletion handling, persistence changes, and the new parameter requirements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch immutable-mmap-map-index

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 6/8 reviews remaining, refill in 14 minutes and 52 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@agourlay
agourlay merged commit ff7930f into dev Apr 30, 2026
20 of 21 checks passed
@agourlay
agourlay deleted the immutable-mmap-map-index branch April 30, 2026 13:05
timvisee pushed a commit that referenced this pull request May 8, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 2, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants