Repository navigation
Conversation
… Hive catalog's FileIO - MetadataCachingFileIO: a HadoopFileIO serving a table's metadata dir from one ContentCache per process, by location - cached: metadata JSON, manifest lists, manifests, Puffin and partition stats; never data or delete files - not cached: Hadoop catalog v<N>.metadata.json and version-hint.text (names come back) - HiveCatalog uses it with io.manifest.cache-enabled and the default FileIO; Iceberg's per-instance cache is not built - cache field transient, looked up again by bounds after deserialization; default expiry 1 h instead of 60 s - IcebergColStatsReader opens Puffin files with their known size - tests: TestMetadataCachingFileIO, TestHiveCatalog
… FileIO, which does not pass it on
- a cache hit never reaches storage, so the cache is per user: with doAs, each user's first read of a file goes through their own permissions - the key is the short user name, looked up on every open, so a FileIO serving several users cannot carry one user's entries to another - the cache field is gone: nothing is kept in the FileIO, a deserialized table uses the same caches as the rest of the process - a user's cache is dropped once unused for the expiry interval (Caffeine holder, system scheduler) - bounds apply per user; with doAs off there is one cache - test: two users share one FileIO; the second user's first read reaches the file system
…ts.openPuffin - one helper opens a Puffin stats file with the file and footer sizes the table metadata records, the FileIO getting the size too - replaces the three copies in IcebergColStatsReader - the writer's carry-forward of earlier stats now passes the size as well, so a cached file is served without a length request
…file system for its length
deniskuzZ
commented
Nov 30, 2026
| * again, so an idle user's cache would otherwise keep its bytes. The scheduler drops it on time even when no one | ||
| * opens a metadata file afterwards. | ||
| */ | ||
| private static final Cache<CacheKey, ContentCache> CONTENT_CACHES = Caffeine.newBuilder() |
Member
Author
There was a problem hiding this comment.
matches Iceberg's own name: ManifestFiles declares Cache<FileIO, ContentCache> CONTENT_CACHES and reads it through contentCache(FileIO io)
… files by Iceberg's FileFormat
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What changes were proposed in this pull request?
MetadataCachingFileIO(iceberg-catalog): aHadoopFileIOthat serves files in a table's metadata directory fromIceberg
ContentCaches shared across the process, one per user, keyed by location:.stats, Hive'scolumn-stats-*.puffin)partition-stats-*)Data and delete files are never cached. Neither are a Hadoop catalog's
v<N>.metadata.json(those names come backwhen a table is created again at the same location) or
version-hint.text. "Metadata directory" means a directorynamed
metadata, Iceberg's default: a table whosewrite.metadata.pathpoints elsewhere is read uncached.HiveCatalog.initializecreates it in place ofHadoopFileIOwhen the catalog setsio.manifest.cache-enabledanduses the default
FileIO(io-implunset orHadoopFileIO).HadoopFileIOis:HadoopConfigurable, so serialized tables still skip theFileIO's Hadoop configuration (HIVE-25843), and
DelegateFileIO, for bulk and prefix operations.bounds. A table serialized into the Tez AM and the tasks therefore uses the same caches as the rest of the process.
A file opened without its length (the metadata JSON, manifest lists, partition statistics) is looked up in the cache
first and, when cached, opened with the cached length.
ContentCache.tryCacheasks a file for its length before itlooks in the cache, so otherwise every hit would cost a length request. The lookup relies on the file
tryCachereturns answering
getLength()from the cache, which Iceberg does not promise; a test fails if that changes.One cache per user. A cache hit never reaches storage, so no permission is checked on it.
hive.server2.enable.doAs, each user's first read of a file goes through their own storage permissions, anda revoked permission takes effect when the entry expires.
FileSystema file is opened with is resolved forthe same user in the same call, so an entry in a user's cache was always read as that user.
FileSystemcache does not tell them apart.Bounds:
io.manifest.cache.expiration-interval-ms(default here 1 h, Iceberg's 60 s expires entries between thequeries of a session),
max-total-bytesandmax-content-length(Iceberg's defaults, 100 MB and 8 MB). They applyto each user's cache. The process keeps at most
iceberg.io.manifest.cache.fileio-maxcaches (8 by default), thelimit Iceberg sets on its own manifest caches, so the bytes held stay within 8 ×
max-total-byteshowever manyusers read. One DEBUG line each time a cache is created.
The
FileIOhidesio.manifest.cache-enabledfrom Iceberg, which would otherwise wrap the same manifests in asecond, per-instance cache.
IcebergStoredStats.openPuffinopens Puffin statistics files with the file and footer sizes the table metadatarecords, for the column statistics reads and for the writer, which carries earlier statistics forward. The
FileIOgets the size too, so a cached file is served without asking the file system for its length.
Why are the changes needed?
Every query re-reads its tables' metadata from object storage several times. HiveServer2 reads the metadata JSON and
the statistics files at compile time. The Tez AM reads the metadata JSON, manifest lists and manifests again during
split planning.
Measured on a 40-node LLAP cluster (r5d.4xlarge, 12 executors; 1TRC part2, an Iceberg table with 21 manifests,
4.3 MiB): cache off / on / on / off, 3 runs each, same image, results identical in every run. With the cache on,
HiveServer2 and the Tez AM that planned the query each held the same 23 files; with it off, no process held a cache.
Measured before the cache was keyed by user, and while a hit on a file opened without its length still made a length
request; that cluster runs with doAs off, so it had one cache either way.
Query time did not change (the halves disagree: -4.4 / -0.2 s on ~95 s). The saving grows with the number of
manifests and with object-store latency, so tables with frequent small commits gain more. This is parity with Trino
and StarRocks.
A cache hit costs no storage request. A first read costs what it costs today, or less. Requests per read on S3A:
Today the Avro and Parquet readers of manifest lists and partition statistics open the file, a HEAD, and then ask for
its length, another HEAD. With the cache,
tryCacheasks for the length first, and Hive'sHadoopInputFilepasses itto
openFile, so the open skips its HEAD. HDFS ignores that option, so there the first read of a metadata JSON costsone
getFileStatuscall more than today. These counts come from the code (Iceberg 1.12.0, Parquet 1.18.1, Hadoop3.4.3), not from a request trace.
Does this PR introduce any user-facing change?
Only when
io.manifest.cache-enabledis set for a Hive catalog that uses the defaultFileIO. Table metadata filesare then cached across queries, per user, in every process that reads them: HiveServer2, the Tez AM, and the LLAP
daemons, which open metadata files only for metadata-table scans. The default expiry is 1 h instead of 60 s when
io.manifest.cache.expiration-interval-msis unset. A process keeps at mosticeberg.io.manifest.cache.fileio-maxcaches (a system property, 8 by default). Nothing changes with the property unset (the default) or with a custom
io-impl.How was this patch tested?
TestMetadataCachingFileIO:metadata) are read as they areversion-hint.textare read as they areFileIOuses the same cacheFileIO; the second user's first readreaches the file system, and the first user is still served from the cache
iceberg.io.manifest.cache.fileio-maxcachesTestHiveCatalog: the catalog's tables get the cachingFileIOwith the property (also withio-implset toHadoopFileIO) and a plainHadoopFileIOwithout it. A second catalog loads a table whose metadata file was madeunparseable, from the cache.
.statsorpartition-stats-files not admittedFileIOthat no longer serializesFileIOContentCacheFileIO, or not whenio-implnamesHadoopFileIOHadoopFileIO, 3,648 B withMetadataCachingFileIO(Hive's
serializeTable, a ~130 KB vertex configuration).TestIcebergColStatsFormat,TestIcebergColStatsWritePolicy,TestCatalogs.HiveServer2 and the Tez AM hold the cached files (heap histogram), with it off no process holds a cache.
🤖 Generated with Claude Code