Repository navigation
Filesystem cache: avoid redundant opendir per key directory on load - #107414
Conversation
`FileCache::loadMetadataForKey` opened each key directory twice during startup metadata loading: once via `fs::is_empty` to check for emptiness, and once more via `fs::directory_iterator` to scan the segment files. Open the directory only once and reuse the iterator: an empty directory is detected when the freshly-constructed iterator already equals the end iterator. This halves the number of `opendir`/`readdir` syscalls at the key-directory level, which matters for caches with many keys where startup loading is dominated by filesystem metadata latency. Pure refactor with identical behavior; covered by the existing `test_parallel_cache_loading_on_startup` integration test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [b0eb952] Summary: ✅
AI ReviewSummaryThis PR changes Tests
Final VerdictStatus: Minimum required action: add focused before/after performance evidence for the claimed filesystem cache startup loading improvement. |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Good and small change. LGTM.
|
📊 Cloud Performance Report 🔴 AI verdict: This sync PR's only change replaces fs::is_empty with a reused directory iterator in FileCache::loadMetadataForKey, a startup-time optimization for loading file-cache metadata. That code runs once at server boot and is not on any query execution path, so none of the flagged per-query deltas can be attributed to it. The widespread same-direction shifts (10-25% in both directions), measured with just 6 source runs against 30 base runs, point to environment and run-to-run variance, so all flagged queries are downgraded. Q16 remains flagged only because its large delta tripped the automatic trust override; given the change is boot-time-only, treat it as environment noise too. clickbench🔴 1 regressed · Flagged queries (15 of 43)
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_officialFlagged queries (3 of 22)
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. Debug info
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 6/8 (75.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 4 line(s) · Uncovered code |
|
@groeneai, why did CI fail here? |
|
Runner OOM on the azure ASan shard, not this change. All 4 reds on
This is the known azure ASan runner-OOM cascade. The same host-RSS-cap (53.69 GiB) signature hit 58 distinct PRs and 433 distinct tests on this shard over 2026-06-09..06-13, including 18 master rows. None of the 4 tests touch FileCache load, and a +6/-2 change to |
|
The single failing check
All four hit the same Master history (
I re-ran the failed job. @groeneai, the |
|
@alexey-milovidov It is a runner concurrency/memory-budget issue, and the fix is up in a separate PR: #107441 The CIDB over the last ~28 days excluding the 2026-06-09/06-10 Azure outage days: 187 OvercommitTracker/RSS-cap failures across 148 distinct tests and 59 PRs ( The PR lowers that shard to |
Cherry pick #107414 to 26.4: Filesystem cache: avoid redundant opendir per key directory on load
…er key directory on load
Cherry pick #107414 to 26.5: Filesystem cache: avoid redundant opendir per key directory on load
…er key directory on load
Backport #107414 to 26.4: Filesystem cache: avoid redundant opendir per key directory on load
Backport #107414 to 26.5: Filesystem cache: avoid redundant opendir per key directory on load
… opendir per key directory on load
…7414 Backport ClickHouse#107414 to 26.4: Filesystem cache: avoid redundant opendir per key directory on load
On server startup,
FileCache::loadMetadataForKeyopened each cache key directory twice: once viafs::is_emptyto test for emptiness, then again viafs::directory_iteratorto scan the segment files. For caches with many keys, startup metadata loading is dominated by filesystem metadata latency, so the redundantopendir/readdiris pure overhead.This change opens the directory only once and reuses the iterator: an empty directory is detected when the freshly-constructed iterator already equals the end iterator. The behavior is otherwise identical.
Related: #107415
Related: #107416
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Speed up filesystem cache loading on startup by avoiding a redundant directory open per cache key.
Documentation entry for user-facing changes
Version info
26.6.1.80526.5.3.31,26.4.5.39