Skip to content

perf(db): cache scalar range prefixes within a shared memory budget - #924

Closed
iaojnh wants to merge 16 commits into
alibaba:mainfrom
iaojnh:codex/inverted-range-adaptive-prefix-20261116
Closed

iaojnh wants to merge 16 commits into
alibaba:mainfrom
iaojnh:codex/inverted-range-adaptive-prefix-20261116

Conversation

@iaojnh

@iaojnh iaojnh commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Sealed scalar range queries repeatedly merge the same range postings. Reuse immutable prefix bitmaps to reduce this work while accounting for both retained cache memory and temporary build allocations in the shared memory budget.

  • Build decile prefixes when an index is sealed or reopened, then add up to 32 checkpoints using serialized posting work within the remaining per-field budget (16 MiB by default). Choose direct scans, prefix addition, or prefix subtraction for each query bound.
  • Register published caches with the global eviction queue. Queries pin an immutable snapshot; reclamation removes the published reference and returns its memory after the last reader finishes. Optional builds yield to required allocations, including when capacity is held by an unfinished build or retired cache.
  • Preserve inclusive/exclusive boundaries, NULL handling, sparse document IDs, and binary-string ordering across cache admission, refusal, and eviction. Validate full document-domain coverage before choosing complement plans.
  • Use owned, validated posting bitmaps for cached operations, load document IDs without unaligned casts, and keep the existing persisted index format.
  • Include the slab header in the ordinal page-pin fixture budget so its lifetime assertions do not depend on background eviction timing.

Validation

Local validation at 026daffc:

  • 73 targeted tests passed: 26 range-cache, 20 RSS-budget, 10 shared-budget, and 17 existing numeric, string, and array-query tests. Changed production sources were rebuilt against existing local dependency archives.
  • All 29 merged-provider tests passed on macOS arm64 (16 KB pages) and x86_64 under Rosetta (4 KB pages). The ordinal pin-lifetime test passed 1,000 repetitions on each architecture.
  • A temporary mutation removing the previous-block release still failed the corrected pin-lifetime test.
  • Changed-line clang-format 18.1.8 and git diff --check passed. Full CI and native Windows testing remain for the upstream checks.

Source PR: iaojnh#53

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.

2 participants