Skip to content

[core] Cache BTree index readers across table scans - #1497

Draft
XiaoHongbo-Hope wants to merge 2 commits into
apache:mainfrom
XiaoHongbo-Hope:codex/btree-table-reader-cache
Draft

XiaoHongbo-Hope wants to merge 2 commits into
apache:mainfrom
XiaoHongbo-Hope:codex/btree-table-reader-cache

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

Each scan creates a new global-index scanner. Repeated queries on the same table reopen the same BTree shards and reread their footers and index blocks. That work remains on the warm-query path.

Change

  • Reuse opened BTree readers across scans on the same Table handle and its copies. Readers are used exclusively and returned to an LRU cache capped at an estimated 128 MiB of reader metadata. Data blocks retain their separate btree-index.cache-size budget.
  • Readers retain the FileIO they were opened with. The cache clears idle readers when it sees a credential-generation change and only accepts returned readers from its current generation. Delayed scans cannot roll the cache back. Query-authorized scans and FileIO providers without a credential generation use scan-local readers.

Validation

In a paired three-seed descriptor benchmark on an 8-vCPU ECS, adding b24a2159 to the #1504 baseline lowered median warm latency from 192 to 64 ms at 16 clips and from 289 to 134 ms at 100 clips. Lance measured 71 and 282 ms in the same run. All groups used default concurrency.

The BTree cache and REST token refresh tests passed, including a delayed scan attaching after the cache has advanced to a newer credential generation.

AI-assisted change.

@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as draft November 22, 2026 15:17
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