Repository navigation
Conversation
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex) plus an independent cold review
Severity: ❌ blocker / One adjacent observation, deliberately not folded in: Session id: cron:clickhouse-review-slot-9:20260730-174000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-9:20260730-174000 |
|
cc @CurtizJ @antonio2368, could you review this? Reading a small member out of a packed part clamps the read buffer to that member but leaves |
|
Workflow [PR], commit [1a970a9] Summary: ❌
AI ReviewSummaryThis PR clamps the packed-member read path so a small archive member no longer inherits a multi-megabyte remote seek threshold and read-and-discard the whole archive prefix. I reviewed the current diff, the touched read-buffer code paths, the existing inline thread, the top-level discussion, and the current PR state; I did not find a remaining correctness or performance issue that warrants an inline review finding. Final Verdict✅ No blockers or majors. |
|
📊 Cloud Performance Report ✅ AI verdict: This sync PR (public #112644) clamps the remote seek threshold to the buffer size in PackedFilesReader, cutting read amplification when small members such as marks are fetched from Packed part archives on object storage. That path is only exercised for Packed parts; a ClickBench single-table scan reads large Wide parts, so the changed code is not on these queries' hot path. All three flagged queries show small wall-clock improvements (up to -12.1%) with flat CPU — an I/O-shaped delta — but none are attributable to this change, and the deterministic gates correctly held them at no_change/inconclusive (the Q15 within-envelope suppression checks out). No regressions. clickbenchFlagged queries (2 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/6 (83.33%) · Uncovered code |
… member A packed part stores every column file inside one `data.packed` archive. Reading a small marks member sizes the read buffer for that member, but the remote seek threshold still described the whole session, so skipping the archive prefix ahead of the member was judged too short to seek and was read-and-discarded through the member-sized buffer instead. A ~500 byte marks member behind a ~2.9 MiB prefix therefore cost the whole prefix: 3049387 bytes fetched to obtain the marks. Clamp the seek threshold down to the buffer size in `PackedFilesReader::patchSettings`, so the prefix is seeked over instead. The same member then costs 27522 bytes. The clamp covers all packed `readFile` callers and, under distributed cache, that stage's own threshold as well. Seeking rather than bridging a gap costs an extra request, and the trade is strongly favourable: measured on an uncached encrypted disk, the marks path goes from 9 requests moving 3049387 bytes to 12 requests moving 27522 bytes. The extra cost is a small constant rather than per-range, measured at +1 request with both 5 and 40 disjoint in-member ranges. The regression test measures on an uncached disk and asserts remote bytes, so it does not depend on whether a shared filesystem cache still holds the segment.
d7d9dce to
606fbe1
Compare
The two measured reads request the same bytes from the same path, so whichever ran first could serve part of the second one from a read cache and halve its counter. `CachedCompressedReadBuffer` keys on (path, offset), so with the randomized `use_uncompressed_cache = 1` the second read measured 12398 bytes where a read of untouched bytes measures 24796, and the lower bound of the premise check rejected it. CI reproduced this deterministically: 122 of 122 runs failed under the drawn settings and 210 of 210 passed without them, with the minimizer naming `use_uncompressed_cache`. Reading the second cell from its own table means no earlier query in the test has fetched those bytes, so no cache can pre-warm them regardless of which cache the randomizer enables.
CI finish ledger - 1a970a9Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260801-000000 |
|
Fixing PR for the The test left |
|
Closing as superseded by #118483: it bounds the read to the member's slice before seeking, so the archive prefix is no longer read and discarded. Measured with this PR's own test on master |
Related: #110929
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Avoids reading and discarding megabytes of data when reading a small file out of a packed part. Reading one marks file used to transfer the whole archive prefix ahead of it, because the read buffer was sized for the small file while
remote_read_min_bytes_for_seekstill described the whole session, so the skip was judged too short to be worth a seek. Now the seek threshold is clamped along with the buffer, so the prefix is seeked over instead.Description
A packed part keeps every column file inside one
data.packedarchive. When a caller asks for a small member,ReadSettings::adjustBufferSizeshrinks both buffer sizes to that member (MergeTreeMarksLoaderpasses a marks file of ~100 to ~500 bytes), but it leavesremote_fs_settings.min_bytes_for_seekat its session value of 4 MiB.PackedFilesReader::readFilethen opens the whole archive with those settings, and the seek to the member lands inReadBufferFromRemoteFSGather::seek, where a skip shorter thanmin_bytes_for_seekis served byignore()rather than a real seek. So the entire archive prefix is transferred through a member-sized buffer.The fix clamps the remote seek threshold down to the already-clamped remote buffer size in
PackedFilesReader::patchSettings, mirroringStorageObjectStorageSource.cpp, which setsmin_bytes_for_seek = buffer_sizeright afteradjustBufferSize. One clamp covers all 10readFilecall sites.Measured on an encrypted cached disk, reading a 507-byte marks member behind a 2.88 MiB prefix: 5988 reads and 3050322 bytes before, 28 reads and 36750 bytes after. Uncached, the marks path goes from 9 requests and 3050322 bytes to 12 requests and 27522 bytes. The clamp lasts for the life of the view, so gaps inside a large member are seeked over rather than bridged. Measured there, that costs one or two extra requests and saves bytes, and the extra count grows with neither the member size nor the number of disjoint ranges read, because
setReadUntilPositionalready bounds the reader per range.I found this while investigating an
arm_asan_ubsanstress hung check where three marks-loading queries each moved 1.1 to 3.1 MB to obtain 96 to 144 bytes of marks. This removes that amplification; it does not by itself eliminate the hung-check class, and I have filed the remaining halves separately.The
ENABLE_DISTRIBUTED_CACHEclamp guards the same field thatReadPipelinesubstitutes when distributed cache is active.