Repository navigation
Iceberg: reuse the Puffin object metadata across deletion-vector reads - #2419
Conversation
Loading one deletion vector issued two or three S3 `HEAD` requests against the same object. `loadDeletionVector` already calls `getObjectMetadata` for the Puffin file to read its etag for the `PuffinFilesCache` key, but then passes only the path down: `readFooterBlobs` and `loadDeletionVectorUncached` each build a fresh `RelativePathWithMetadata` with empty metadata, and `createReadBuffer` fills it in with another `getObjectMetadata` for every buffer it opens. Thread the already-fetched metadata into both helpers instead. `createReadBuffer` issues its own request only when `RelativePathWithMetadata::metadata` is empty, so seeding it removes the redundant requests without changing which bytes are read. The two call sites that run before the etag fetch keep passing `std::nullopt` and behave as before. On a lake scan with cold deletion vectors this is the dominant cost: a profile of one such query recorded 5706 `S3HeadObject` requests against 2833 `PuffinFilesRead`, with about 94 seconds spent in `HEAD` alone. Reusing a single metadata snapshot for every read of the same Puffin file is also more coherent than re-fetching it. Iceberg data and delete files are immutable, so the separate requests could only ever have observed the same object. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Move the `IObjectStorage.h` include next to the other alphabetically ordered headers, and label the positional `puffin_metadata` argument at the `loadDeletionVectorUncached` call sites. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
CI triage — afc914bVerdict: 5 red checks, none of them a test failure caused by this PR. 4 are infra/flaky/formality; 1 is the aggregate roll-up gate. Builds, Fast test, all stateless Iceberg functional tests, integration tests (0/~6800), unit tests, stress, and the
1. DCO —
|
Regression check: Puffin
|
| Image | |
|---|---|
| Before | altinityinfra/clickhouse-server:0-26.6.8.20001.altinityantalya (antalya-26.6, Oct 14) |
| After | altinityinfra/clickhouse-server:2419-26.6.8.20002.altinityantalya |
Method
Spark writes Iceberg v3 merge-on-read tables to MinIO. ClickHouse reads each table three times with icebergS3, and we compare ProfileEvents['S3HeadObject'] from system.query_log:
- warm: vectors served from the Puffin files cache;
- cold: right after
SYSTEM DROP PUFFIN FILES CACHE; - disabled:
use_puffin_files_cache = 0.
The Iceberg metadata and data-file requests are the same in all three reads, so any difference comes from loading the vectors. The reads use sum(id) rather than count(), because the snapshot-summary count shortcut can answer count() without opening any vectors.
Results: S3HeadObject per query
Puffin container:
| Table | Vectors | Puffin files | Warm | Cold before | Cold after | Disabled (before and after) |
|---|---|---|---|---|---|---|
| One data file | 1 | 1 | 3 | 5 | 3 | 3 |
Four data files, one DELETE |
4 | 1 | 9 | 14 | 9 | 9 |
Two data files, one DELETE each |
2 | 2 | 5 | 9 | 5 | 5 |
Vector replaced by a later DELETE |
1 | 1 | 3 | 5 | 3 | 3 |
Databricks Delta .bin container (same tables, vectors rewritten as .bin):
| Table | Vectors | Warm | Cold before | Cold after |
|---|---|---|---|---|
| One data file | 1 | 3 | 4 | 3 |
Four data files, one DELETE |
4 | 9 | 13 | 9 |
Two data files, one DELETE each |
2 | 5 | 7 | 5 |
Vector replaced by a later DELETE |
1 | 3 | 4 | 3 |
On a cold load, the PR saves this many requests:
- Puffin:
vectors + Puffin files. One for each blob read and one for each footer read, which each used to issue their ownHEAD. .bin:vectors. These have no footer.
This matches the profile in the PR description: 5706 S3HeadObject against 2833 PuffinFilesRead is about 2 per load, and it drops to about 1.
What did not change
- Warm cache hits still issue one
HEADper vector. That request fetches the etag for the cache key, so a fully warm scan over many vectors still pays aHEADper vector. Removing it would be a separate change, for example taking the etag or size from the manifest. use_puffin_files_cache = 0andpuffin_files_cache_size = 0issue oneHEADper vector before and after; the PR doesn't touch this path.- Local storage (
icebergLocal) is unaffected; it doesn't send S3 requests. - Results were identical on both builds.
Regression coverage
New requirement: RQ.Iceberg.DeletionVectors.Cache.MetadataRequestReuse. Tests are in iceberg/tests/deletion_vectors/metadata_requests.py and run under both the Puffin and Delta features:
./regression.py --local --clickhouse docker://<image> --clickhouse-version <version> \
--minio-root-user admin --minio-root-password password \
--only "/iceberg/deletion vectors/metadata requests/*" \
"/iceberg/delta deletion vectors/metadata requests/*"
All 8 scenarios fail on the build before the PR and pass on the PR build.
A cold deletion-vector load must reuse the object metadata of the etag request that builds the Puffin files cache key instead of issuing more S3 HEAD requests. New RQ.Iceberg.DeletionVectors.Cache.MetadataRequestReuse and metadata_requests scenarios (Puffin and Delta .bin), gated to Antalya >= 26.6.8.20002. Co-authored-by: Cursor <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Reduce number of Puffin file HEAD requests
Documentation entry for user-facing changes
...
CI/CD Options
Exclude tests:
Regression jobs to run: