Repository navigation
Conversation
Since ClickHouse#127100 the threads reading an Iceberg table share the data manifest iterators, and a thread holding one produced a single entry and put it back. With one data manifest (e.g. TPC-H `lineitem` of the CI dataset: 84 entries, 12 left after partition pruning) the entries came out one turn at a time, and each turn went to whichever thread got the mutex first. A stream's read-ahead `next` (issued right after its first reader is created) competed on equal terms with streams still waiting for their first file, so it often took a second file: only 8-11 of 16 streams got a file and the query read ~2 files sequentially. Now each call takes a number on entry, produced files are numbered in production order, and the n-th call returns the n-th produced file. A call keeps calling `ManifestFileIterator::next` until its own file exists, so one turn serves every earlier waiting call. With one thread the order is the manifests' order as before. x86, 16 CPUs, release build, medians: TPC-H Q6 0.062 -> 0.042 s, `iceberg_suite_shared_read` threads_16 0.032 -> 0.025 s, threads_1 unchanged; traced Q6: 20/20 runs with 12 streams reading one file each (was 1/20). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
cc @kssenii @scanhex12, could you review this and add the |
|
Workflow [PR], commit [a1796b9] Summary: ✅
AI ReviewSummary
Missing context / blind spots
Final Verdict✅ Approve — no unresolved code findings. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units31 translation units recompiled, 345 s compile time in total, 31 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Related: #127100
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Since #127100, short multi-threaded scans of Iceberg tables whose files come from few data manifests are slower: MasterCI
arm
iceberg_suite_local_tpchquery 5 (TPC-H Q6) went from 0.037 to 0.062 s andiceberg_suite_*_readquery 20(
max_threads = 16) is +33%, reported in #127100 (comment).Cause: in
IcebergIterator::nextDataFileEntrya thread holding a manifest iterator produced one entry and put it back, sothe entries of one manifest came out one turn at a time and each turn went to whichever thread got the mutex first. A
stream's read-ahead
next(issued once its first reader exists) then often took a second file while other streamswere still waiting for their first: with the CI
lineitem(one manifest, 12 files after pruning, 16 streams) only 8-11streams got a file and the query read ~2 files sequentially.
Change: each
nextcall takes a number, produced files are numbered, and the n-th call gets the n-th produced file, so aread-ahead call can no longer take a file produced for an earlier call. A call keeps reading the manifest until its own file
is produced, so one turn serves every call that came before it. With one thread the order is unchanged. No new thread or
pool.
Validation (release builds, x86, 16 CPUs, base vs fix): Q6 0.062 -> 0.042 s (pre-#127100: 0.040 s; on MinIO 0.071 ->
0.041 s), query 20 0.032 -> 0.025 s,
max_threads = 1unchanged; 20 of 20 traced Q6 runs read one file per stream (base:1 of 20). 200 manifests, a 20000-entry manifest (all pruned, all read, early matches) and 1/4/16/64 threads are within
noise or faster. Exactly-once stress at 2-64 threads, fault injection at both hand-offs, and the Iceberg stateless and
integration suites pass.
The regression is master-only (#127100 is in no release branch), hence
Not for changelog.Workflow [PR]
Sync PR [sync-upstream/pr/129558]