Repository navigation
Conversation
…acity Patch from the analysis in ClickHouse#132906 (@snelheidai), applied verbatim. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…motion On top of the borrowing from ClickHouse#132906: - Lending is opt-in per priority: only the plain SLRU policy enables it. Copies (`copy()`, used by the per-client SLRU_OVERCOMMIT priorities) share the queue sizes but not the limits, so moving limits in one copy would break the size invariant of another. - Dynamic resize keeps the capacity which probationary borrows instead of resetting both queues to their shares: growing the cache no longer evicts borrowed data, and restoring the previous limits after a failed eviction always succeeds. - A promoted partially downloaded segment which grows in protected takes lent capacity back: probationary makes room for it in the same reservation, a hold on the SLRU reserves that capacity against concurrent take-backs, and the limit moves in `incrementSize`, where the reservation's holds are released and its evicted entries are invalidated. - A promotion takes back min(size, lent) and downgrades only the rest. - The two queue shares (and the data and system parts of a split cache) add up to the total: probationary = total - protected, so a filled cache never exceeds its total limit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
05832 reads 6.4 MB through a 10 MiB SLRU cache with a 4 MiB probationary queue twice: the first read evicts nothing and the second one reads everything from the cache. 05234 encoded the old behaviour (an entry bigger than the probationary queue was not stored); it is stored and served now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… check; docs for borrowing 05832: `prewarm_mark_cache` and `prewarm_primary_key_cache` are randomized MergeTree settings. With prewarm on, the INSERT puts the part's marks into the server mark cache, so read 1 never reads the marks files through the filesystem cache; if the marks leave the mark cache before read 2 (a parallel `SYSTEM CLEAR MARK CACHE`), read 2 reads them from the source. Measured on the fix server: with prewarm on and a mark cache clear between the reads, read 2 reads 538 bytes from the source; with prewarm off, 0. 05234: keep the "not stored, leaves no file segments behind" check for an SLRU cache, now with an entry bigger than the whole cache. Docs: `slru_size_ratio` notes that new data can use the unused part of the protected share. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ratio_of_defaults_for_sparse_serialization` is randomized and is 0 in about 30% of runs. Both columns then become Sparse, the first read re-reads segments within the same query, the re-read promotes them to the protected queue, and master passes the test without the fix. Pin the setting to 1 so the columns stay Full. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`static_cast<double>(total)` rounds up for about half of the limits above 2^53, so at a ratio of 1 the rounded share was `total + 1` and its complement `total - share` wrapped around to an unbounded queue; clamping the share to `total` keeps such a config rejected, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion `std::lround` overflows `long` for limits above 2^63 and `static_cast<double>` rounds limits above 2^53 both ways, so the share is rounded and bounded in `double` before the conversion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove comments that restate the code next to them, shorten the ones about lending and take-back to one line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 5 findings over 5 rounds) plus my own review (4 findings; one of them also raised by the model).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261120-095301 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20261120-002700 |
|
Workflow [PR], commit [cc0a0d0] Summary: ✅
AI ReviewSummaryThe PR lets the Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units12 translation units recompiled, 29 s compile time in total, 12 of them have a recent master baseline. |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=13 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Closes: #132906
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
SLRUfilesystem cache policy (the default) now lets new file segments use the part of the cache that the protected queue does not use yet. Before, a working set larger than the probationary queue (40% ofmax_sizeby default) evicted itself before it was read again, even when the cache was mostly empty.Description
New file segments only go to the probationary queue, and it evicts against its own share even while the protected queue is empty, so a working set between 40% and 100% of the cache is read from the remote storage on every repetition (ClickBench's datalake entries use
cache_policy: LRUfor this reason). Analysis and original patch: @ snelheidai, #132906.Probationary now borrows protected's unused limit under the cache state lock, so the two limits still add up to the shares and the per-queue limits stay enforced. A promotion takes the borrowed capacity back and downgrades only the rest; a partially downloaded segment that grows in protected takes it back too (probationary makes room in the same reservation, which also reserves the capacity against concurrent take-backs). Dynamic resize keeps the borrowed capacity, and the queue shares (and the data/system parts of a split cache) now add up to the total. A full protected queue lends nothing, so it keeps today's protection; a scan read twice now stays cached and competes for protected (reporter: two more runs of an 8 GB scan re-read 2 MB of a 371 MB hot set once).
SLRU_OVERCOMMITkeeps the fixed split: its per-client copies share sizes but not limits.Reporter's ClickBench over S3 Parquet, 8 GB cache: Q31 -80%, Q21 -72%, Q22 -30%, controls within 3%. Locally (debug builds, 600 MB scan over a 1 GiB cache, 20 ms per object read): hot reads 12.2 s -> 0.18 s, 600 MB -> 0 bytes from storage.
Tests: gtests for each part,
05832_filesystem_cache_slru_working_set_above_probationary(fails on master);05234encoded the old behaviour. No performance test: the performance job removes the local disks and both of its servers share one cache directory.Workflow [PR]
Sync PR [sync-upstream/pr/133195]