Repository navigation
Conversation
Sync the weighted LRU implementation and tests with the standalone patch in apache#1174. Co-authored-by: Codex <[email protected]>
timothyw553
left a comment
There was a problem hiding this comment.
overall looks good, left a few comments on a delete/recreate race, fallback stream wrapping, and test coverage (Read/Seek and write cleanup). also one question on the enabled flag.
|
|
||
| struct ClearAfterDelete { | ||
| ContentCache& cache; | ||
| ~ClearAfterDelete() { cache.InvalidateStorage(); } |
There was a problem hiding this comment.
ClearAfterDelete only invalidates in the destructor after DeleteFile returns. what if storage deletes the file and another adapter recreates it at the same path before DeleteFile finishes? readers could still get the old cached bytes in that window. could we track it as an active write and invalidate up front too, plus add a test for that overlap?
struct ClearAfterDelete {
+ explicit ClearAfterDelete(ContentCache& owner) : cache(owner) {
+ std::lock_guard lock(cache.storage_.mutex);
+ ++cache.storage_.active_writes;
+ ++cache.storage_.invalidations;
+ cache.SyncGenerationLocked();
+ }
+
ContentCache& cache;
- ~ClearAfterDelete() { cache.InvalidateStorage(); }
+ ~ClearAfterDelete() {
+ std::lock_guard lock(cache.storage_.mutex);
+ --cache.storage_.active_writes;
+ ++cache.storage_.invalidations;
+ cache.SyncGenerationLocked();
+ }
};| return input_ ? input_->Position() : Result<int64_t>(position_); | ||
| } | ||
|
|
||
| Status Seek(int64_t position) override { |
There was a problem hiding this comment.
looks like the tests never call Seek, and the Read calls in metadata_cache_test.cc only hit wrapped storage streams rather than the in-memory content_ branch. since avro decoding uses both, could we add tests on an actual cached stream for sequential Read, Seek (backward, eof, invalid positions), ReadFully bounds, and reads after Close()?
Add a per-table FileIO adapter that retains complete immutable files within a byte budget and limits the number of active caches across tables. Honor input handle sizes on fallback and invalidate cached data across adapters sharing storage when files are overwritten or deleted.
73cc1a9 to
a4c0715
Compare
Invalidate caches sharing a FileIO before creating or overwriting files, including paths removed outside the adapter. Dispatch whole-file writes to the backend and verify the stream extent when a cold handle overlaps a mutation. Co-authored-by: Codex <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are blocking the immutable-file content cache and FileIO adapter changes.
No open issues 🎉
What changed in this PR
Adds an internal immutable-file content cache and FileIO adapter, providing the foundation for manifest and manifest-list caching in #875.
Changes:
- Extends the LRU cache with weighted entries, immediate resizing, and byte-budget eviction.
- Adds bounded content caching with length validation, process-wide cache limits, and coordinated invalidation during storage mutations.
- Extracts shared I/O helpers and adds regression coverage for caching, eviction, aliases, and overlapping reads and writes.
| File | Description |
|---|---|
src/iceberg/util/property_util.h |
Declares signed 64-bit property parsing. |
src/iceberg/util/property_util.cc |
Implements parsing with property-specific errors. |
src/iceberg/util/error_util_internal.h |
Shares operation and stream-close error handling. |
src/iceberg/util/cache_internal.h |
Adds weighted LRU eviction and updates memoizers. |
src/iceberg/test/mock_io.h |
Supports simulated external file deletion. |
src/iceberg/test/metadata_cache_test.cc |
Covers cache behavior, mutation safety, and lifetime. |
src/iceberg/test/CMakeLists.txt |
Registers content-cache tests. |
src/iceberg/test/cache_test.cc |
Tests weighted eviction, resizing, and move behavior. |
src/iceberg/test/arrow_io_test.cc |
Adds Arrow-backed cache and invalidation regressions. |
src/iceberg/file_io.cc |
Extracts reusable reading logic and shares close handling. |
src/iceberg/file_io_internal.h |
Declares the internal whole-file read helper. |
src/iceberg/content_cache.cc |
Implements caching, registry limits, and I/O adapters. |
src/iceberg/content_cache_internal.h |
Defines cache configuration and internal interfaces. |
src/iceberg/CMakeLists.txt |
Includes the cache implementation in the library build. |
Review effort: Balanced
Summary
Add an internal
ContentCachefor repeated reads of immutable files. A cache hit serves the complete file from memory. #875 integrates this cache with table manifest and manifest-list readers.Cache behavior
io.manifest.cache-enabled. The default limits are 100 MiB per table cache, 8 MiB per file, and eight active table caches per process. Readers that already hold cached bytes can finish after eviction.FileIO. Even a fresh create can reuse an alias for a file deleted outside the adapter, so this also evicts unrelated entries. Reads overlapping the mutation cannot populate the cache. Whole-file writes delegate to the backend’sWriteFileoverride.FileIOand keys entries by location. Credential rotation can reuse the cache while each location identifies the same immutable object. An endpoint or prefix change that redirects a location to another store requires a fresh cache.Validation
On
85b1f27e, all 513util_testtests, 121arrow_testtests, and pre-commit hooks passed locally. The 42 metadata-cache tests also passed across 30 consecutive runs. Three regressions reproduced ona4c0715band passed on the updated head. They cover opening a cold handle after a longer replacement, recreating an externally deleted path, and writing through a backend with a whole-file override. GitHub skipped all 10 hosted checks for this head.