Skip to content

[rust] Cache decoded BLOB indexes across readers - #897

Merged
JingsongLi merged 5 commits into
apache:mainfrom
XiaoHongbo-Hope:codex/cache-decoded-blob-indexes
Sep 28, 2026
Merged

JingsongLi merged 5 commits into
apache:mainfrom
XiaoHongbo-Hope:codex/cache-decoded-blob-indexes

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Opening the same immutable .blob file with a new reader currently reloads its footer and index, adding two object-store range reads each time.

This caches the decoded index across readers, following the bounded process-local cache used by PyPaimon in apache/paimon#9547.

Changes

  • Cache up to 16 decoded BLOB indexes in a process-local LRU.
  • Share immutable indexes with Arc; readers and BLOB payloads are not cached.
  • Scope cache entries to the originating FileIO storage context.
  • Keep cache locks out of asynchronous I/O.
  • Verify cache reuse within one FileIO and isolation across independent storage contexts.

Trade-offs

  • Cold reads are unchanged.
  • Cache hits avoid two range requests per BLOB file.
  • Up to 16 decoded indexes remain in memory.
  • This relies on Paimon data file paths being immutable; there is no API or format change.

Tests

  • cargo test -p paimon --lib blob (140 passed)
  • cargo test -p paimon --lib file_io (48 passed)
  • cargo clippy -p paimon --lib --tests -- -D warnings
  • cargo fmt --all --check
  • git diff --check

@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review September 25, 2026 16:25
Comment thread crates/paimon/src/arrow/format/blob.rs Outdated
Comment on lines +1679 to +1680
if let Some(index) = cache.get(file_path) {
return Ok(index.clone());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same path can refer to different files when two FileIO instances use different storage roots. I tested this with two BLOB files of the same size and row count: opening the second reused the first file’s index and returned NULL instead of its actual value. The cache key needs to distinguish the storage namespace too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same path can refer to different files when two FileIO instances use different storage roots. I tested this with two BLOB files of the same size and row count: opening the second reused the first file’s index and returned NULL instead of its actual value. The cache key needs to distinguish the storage namespace too.

Thanks. I hesitated because Paimon files use UUID names, so two files within one storage namespace are extremely unlikely to have the same path, and PyPaimon also keys by path. I’ll fix the cache key and add a regression test.

@QuakeWang QuakeWang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi
JingsongLi merged commit 833edac into apache:main Sep 28, 2026
14 checks passed
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.

3 participants