Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9b02ccc
feat: cache immutable manifest content per table
manuzhang Nov 6, 2026
1812a51
docs: remove manifest cache changes from FileIO guide
manuzhang Nov 6, 2026
69da203
refactor: align content cache source and header names
manuzhang Nov 6, 2026
182ce44
style: fix manifest cache lint warnings
manuzhang Nov 12, 2026
8ff9a61
fix: make the manifest cache safe during commits and cleanup
manuzhang Nov 18, 2026
2cd135e
test(s3): expect the Arrow file size lookup error
manuzhang Nov 19, 2026
9b01988
fix: bound manifest caches and preserve credential rotation
manuzhang Nov 20, 2026
b448a52
fix: allow configuring the manifest cache limit at startup
manuzhang Nov 20, 2026
2ca730b
style: use std::array for manifest cache property keys
manuzhang Nov 23, 2026
ef627f9
feat(util): support weighted LRU eviction
manuzhang Nov 25, 2026
57dac00
fix(util): allocate LRU storage on demand
manuzhang Nov 25, 2026
94195fd
fix(util): preserve LRU weights across cache updates
manuzhang Nov 25, 2026
01ccbf1
feat(io): add a bounded cache for immutable file content
manuzhang Nov 25, 2026
8d1eb0e
refactor(io): build manifest integration on the content cache
manuzhang Nov 25, 2026
f0e17f0
fix(io): invalidate canonical content after storage deletes
manuzhang Nov 25, 2026
e4c55ab
refactor(table): use the reviewed content cache for manifest cleanup
manuzhang Nov 25, 2026
dd0c9b9
refactor(io): track manifest caches with weak references
manuzhang Nov 25, 2026
7ff8312
refactor(table): adopt weak manifest cache registration
manuzhang Nov 25, 2026
a4d9203
fix(io): invalidate cached aliases and release empty cache slots
manuzhang Nov 25, 2026
e3e6de0
fix(table): use alias-safe manifest cleanup
manuzhang Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions mkdocs/docs/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,38 @@ follows:
`iceberg::avro::RegisterAll()`.
- Parquet readers and writers are registered by
`iceberg::parquet::RegisterAll()`.

## Manifest content caching

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.

Is file-io a better home for these texts?


Tables can cache immutable manifest and manifest-list bytes. Per-table settings come
exclusively from `FileIO::properties()`; table metadata properties do not enable
or override the cache. REST catalogs supply their merged catalog and table I/O
configuration through the table's `FileIO`. Applications that inject a `FileIO`
must expose the desired settings through its `properties()` method.

| Property | Default |
|---|---|
| `io.manifest.cache-enabled` | `false` |
| `io.manifest.cache.max-total-bytes` | `104857600` (100 MiB) |
| `io.manifest.cache.max-content-length` | `8388608` (8 MiB) |

Independent table loads have separate caches and byte budgets. A table and its
manifest I/O adapters share ownership of its cache. The process-wide registry
tracks the cache through a weak reference once it stores its first file.
Removing the last cached file or destroying the last cache handle frees its slot.

By default, at most eight caches retain files at once. Call
`Table::SetManifestCacheLimit(max_caches)` with a positive integer to change the
limit. Lowering it immediately evicts the least recently used caches, even if
their tables are still loaded. The next cacheable insertion repopulates an
evicted cache. Active readers and input files can still hold bytes after
eviction, and concurrent load buffers are outside the retained byte budget.
Call `Table::ClearManifestCache()` to release a table's retained content explicitly.
Manifest cleanup invalidates cached aliases of each deleted file. If storage
cannot identify the deleted file across aliases, cleanup clears that table's cache.

Compatible refreshes and committed table handles share their source table's cache.
S3 access keys, secrets, session tokens, and token expiry can rotate without losing
warm content when the remaining storage configuration matches. Changes to cache
limits or storage configuration, such as an endpoint or region, start a new cache.
Data files and table metadata JSON continue to use storage I/O directly.
1 change: 1 addition & 0 deletions src/iceberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(ICEBERG_SOURCES
catalog/memory/in_memory_catalog.cc
catalog/session_catalog.cc
catalog/session_context.cc
content_cache.cc
data_table_scan.cc
delete_file_index.cc
deletes/dv_util.cc
Expand Down
45 changes: 40 additions & 5 deletions src/iceberg/arrow/arrow_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <limits>
#include <mutex>
#include <optional>
#include <utility>
#include <vector>

#include <arrow/buffer.h>
Expand All @@ -35,6 +36,7 @@
#include "iceberg/arrow/arrow_io_internal.h"
#include "iceberg/arrow/arrow_io_util.h"
#include "iceberg/arrow/arrow_status_internal.h"
#include "iceberg/content_cache_internal.h"
#include "iceberg/util/macros.h"

namespace iceberg::arrow {
Expand Down Expand Up @@ -411,7 +413,7 @@ class ArrowPositionOutputStream : public PositionOutputStream {
int64_t closed_position_ = 0;
};

class ArrowInputFile : public InputFile {
class ArrowInputFile : public iceberg::internal::InputFileWithStoragePath {
public:
ArrowInputFile(std::shared_ptr<::arrow::fs::FileSystem> fs, std::string location,
std::string path, std::optional<int64_t> file_size)
Expand All @@ -421,14 +423,45 @@ class ArrowInputFile : public InputFile {
file_size_(file_size) {}

std::string_view location() const override { return location_; }
std::optional<std::string_view> storage_path() const override {
const auto type = fs_->type_name();
// Local paths can have symlinks, and a custom filesystem defines its own aliases.
if (type != "s3" && type != "mock") return std::nullopt;
// Ignore boundary slashes for invalidation, where extra matches are harmless.
std::string_view key(path_);
const auto first = key.find_first_not_of('/');
if (first == std::string_view::npos) return std::nullopt;
return key.substr(first, key.find_last_not_of('/') - first + 1);
}

Result<int64_t> Size() const override {
if (file_size_.has_value()) {
return *file_size_;
}
::arrow::fs::FileInfo file_info(path_, ::arrow::fs::FileType::File);
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto input, fs_->OpenInputFile(file_info));
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto size, input->GetSize());
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto info, fs_->GetFileInfo(path_));

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.

A file can still open when GetFileInfo fails or reports Unknown. Please keep the open/get-size/close fallback for these cases and cover a readable file whose stat fails.

if (info.type() == ::arrow::fs::FileType::NotFound) {
return IOError("File does not exist: {}", location_);
}
if (info.type() != ::arrow::fs::FileType::File) {
return IOError("Not a regular file: {}", location_);
}
if (info.size() != ::arrow::fs::kNoSize) {
file_size_ = info.size();
return *file_size_;
}
// Some filesystems report a file without a size.
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto input, fs_->OpenInputFile(info));
auto size_result = input->GetSize();
auto close_status = input->Close();
if (!size_result.ok() && !close_status.ok()) {
auto status = size_result.status().WithMessage(
size_result.status().message(),
"; additionally failed to close file: ", close_status.ToString());
ICEBERG_ARROW_RETURN_NOT_OK(status);
}
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto size, std::move(size_result));
ICEBERG_ARROW_RETURN_NOT_OK(close_status);
file_size_ = size;
Comment thread
manuzhang marked this conversation as resolved.
Resolved
return size;
}

Expand All @@ -445,7 +478,9 @@ class ArrowInputFile : public InputFile {
std::shared_ptr<::arrow::fs::FileSystem> fs_;
std::string location_;
std::string path_;
std::optional<int64_t> file_size_;
// Set by Size() so a later Open() can skip the size lookup. Not synchronized: like
// other InputFile handles, this one is not shared across threads.
mutable std::optional<int64_t> file_size_;
};

class ArrowOutputFile : public OutputFile {
Expand Down
1 change: 1 addition & 0 deletions src/iceberg/catalog/memory/in_memory_catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ Result<std::shared_ptr<InMemoryCatalog>> InMemoryCatalog::Make(
const std::string& name, const std::shared_ptr<FileIO>& file_io,
const std::string& warehouse_location,
const std::unordered_map<std::string, std::string>& properties) {
ICEBERG_PRECHECK(file_io != nullptr, "InMemoryCatalog requires a non-null FileIO");
std::shared_ptr<MetricsReporter> reporter;
auto it = properties.find(std::string(kMetricsReporterImpl));
if (it != properties.end() && !it->second.empty() &&
Expand Down
4 changes: 3 additions & 1 deletion src/iceberg/catalog/rest/rest_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ Result<std::shared_ptr<RestTable>> RestTable::Make(
std::shared_ptr<Catalog> catalog, std::string full_name,
std::shared_ptr<MetricsReporter> reporter, RestScanContext rest_context,
std::unique_ptr<Labels> labels) {
ICEBERG_PRECHECK(io != nullptr, "FileIO cannot be null");
if (metadata == nullptr) {
return InvalidArgument("Metadata cannot be null");
}
return std::shared_ptr<RestTable>(new RestTable(
auto table = std::shared_ptr<RestTable>(new RestTable(

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.

We can revert this line of change.

std::move(identifier), std::move(metadata), std::move(metadata_location),
std::move(io), std::move(catalog), std::move(full_name), std::move(reporter),
std::move(rest_context), std::move(labels)));
return table;
}

Result<std::unique_ptr<DataTableScanBuilder>> RestTable::NewScan() const {
Expand Down
Loading