Skip to content

feat(io): add a weighted cache for immutable file content - #1174

Open
manuzhang wants to merge 6 commits into
apache:mainfrom
manuzhang:codex/weighted-lru-cache
Open

manuzhang wants to merge 6 commits into
apache:mainfrom
manuzhang:codex/weighted-lru-cache

Conversation

@manuzhang

@manuzhang manuzhang commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Add an internal cache for immutable file content. #875 uses it for manifest files and lists when a table enables caching.

  • A weighted LRU bounds retained bytes. Cached values are read-only, and a throwing weigher preserves the previous value, weight, and eviction order. Storage grows as entries arrive. Original LRU allocation review.
  • A FileIO adapter caches complete files by their storage location and serves independent seekable readers over the shared bytes. Explicit prefix reads go to storage. Empty and oversized files bypass cache population. Deletes go through storage. Cleanup removes every cached spelling of the deleted storage path. If the backend cannot identify that path, cleanup clears the table’s cache. Prefix-read review.
  • The process-wide LRU holds weak references to per-table caches. A cache takes a slot on its first insertion and gives it up when its last file is invalidated or its last handle is destroyed. Eviction releases cached files even while a table is live. Open readers keep the bytes they are reading. The default limit is eight. The internal ContentCache::SetGlobalCapacity setter changes it immediately. feat: cache immutable manifest content per table #875 exposes it as Table::SetManifestCacheLimit. Global eviction review.
  • Share stream-close handling with FileIO so a close error preserves an earlier read or write error.

Validation

The standalone util_test suite covers read-only LRU access, weigher failures on insert and replacement, prefix reads followed by full reads, warm-cache retention during oversized reads, stream fallback errors, eviction and reader lifetime, reuse of a slot after its cache is destroyed, unsupported adapter deletes, and canonical reads after alias deletion or replacement. The Arrow tests also exercise deletion through an S3 URI alias and a local path alias. Pre-commit and clang-tidy 22.1.8 passed locally.

Track entry weights, support eviction on resize, and grow storage on demand.

Co-authored-by: Codex <codex@openai.com>
manuzhang added a commit to manuzhang/iceberg-cpp that referenced this pull request Nov 25, 2026
Sync the weighted LRU implementation and tests with the standalone patch in apache#1174.

Co-authored-by: Codex <codex@openai.com>
manuzhang and others added 2 commits November 25, 2026 22:14
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@manuzhang manuzhang changed the title feat(util): support weighted LRU eviction feat(io): add a weighted cache for immutable file content Nov 25, 2026
manuzhang and others added 2 commits November 25, 2026 22:41
Use typed cache properties and keep the process capacity configurable through the runtime setter. Reject deletes on the cache adapter and keep older input handles from restoring invalidated bytes.

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@manuzhang
manuzhang marked this pull request as ready for review November 25, 2026 15:27
@manuzhang
manuzhang requested review from wgtmac and zhjwpku November 25, 2026 15:27

This branch has not been deployed

No deployments
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