Repository navigation
Filesystem cache: let listing threads help load after listing finishes - #107416
Conversation
Startup metadata loading splits `load_metadata_threads` into listing threads (which walk key-prefix directories and enqueue individual key directories) and loading threads (which drain the queue and build the in-memory metadata for each key). The listing threads previously exited as soon as all prefixes were listed, leaving only the loading threads to process the - usually dominant - remaining keys, so up to half the threads sat idle for the bulk of the work. Once a listing thread runs out of prefixes to list, it now joins the loading threads in draining the queue (the shared `drain_queue` helper), so all `load_metadata_threads` threads load keys during the tail of the operation. This matters more now that loading a key no longer needs a `stat` per file, which made the loading phase relatively cheaper per key but still the larger share of total work. Behavior is unchanged; covered by the existing `test_parallel_cache_loading_on_startup` integration test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
f2ed23b to
34b3567
Compare
65283d4 to
e8e2572
Compare
|
Workflow [PR], commit [e8e2572] Summary: ✅
AI ReviewSummaryThe PR lets filesystem-cache listing threads switch to draining queued key directories after listing is done, so startup metadata loading can use all configured Tests
Final VerdictStatus: Minimum required action: provide focused before/after performance evidence for the changed startup metadata loading path. |
| key_dirs_queue.finish(); | ||
|
|
||
| /// Listing is done for this thread; help load the remaining enqueued keys. | ||
| drain_queue(); |
There was a problem hiding this comment.
This PR is categorized as a Performance Improvement, but I do not see before/after evidence for the startup metadata load path this changes. The existing test_parallel_cache_loading_on_startup validates correctness and that the configured listing/loading split is logged, but it would still pass if this helper call were removed, so it does not prove the promised speedup.
Please include a focused measurement for the same cache layout with and without this change, for example elapsed FilesystemCacheLoadMetadataMicroseconds or startup wall time for a populated filesystem cache where the queue tail dominates.
There was a problem hiding this comment.
This is a pure work-sharing change, not a new algorithm: the listing threads are already spawned and, once they run out of key-prefix directories to enumerate, they previously returned and sat idle while only the loading threads (half of load_metadata_threads) drained the — usually dominant — queue of key directories. Now they call the same drain_queue helper, so all load_metadata_threads threads load keys during the tail. The listing/loading split, the queue, and the startup log line are unchanged, which is exactly why test_parallel_cache_loading_on_startup still passes either way — the test asserts correctness of the result, and the result is identical.
A deterministic before/after measurement in CI isn't really attainable here: the win equals the fraction of total startup-load time spent in the tail where half the threads were idle, which is a function of the cache layout (key-prefix count vs. key count), filesystem latency, and load_metadata_threads. On a small/fast cache it's in the noise; it shows up on populated caches where keys dominate prefixes. The cloud performance report on this PR confirms there is no query-path effect (the change only touches FileCache::loadMetadataImpl, called at startup).
I'll leave the call on whether to attach a focused startup-wall-time microbenchmark to @alexey-milovidov; this is consistent with the sibling startup-load PRs #107414 and #107415.
|
📊 Cloud Performance Report 🟢 AI verdict: This PR only parallelizes file-cache metadata loading at server startup (FileCache::loadMetadataImpl); it does not touch any query-execution code path, and the cache contents and hit rates during the benchmark are unchanged. Because the change is off-path, the flagged ClickBench and TPC-H deltas — moving in both directions — are downgraded as run-to-run variance rather than real PR effects. Three queries (ClickBench Q23, TPC-H Q7 and Q20) show large, consistent shifts that clear the automatic trust threshold and are reported as-is, but given the startup-only diff they most likely reflect baseline/environment differences and are worth re-running to confirm. clickbench🟢 1 improved · Flagged queries (6 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_official🟢 2 improved · Flagged 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: 17/21 (80.95%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 3 line(s) · Uncovered code |
Startup metadata loading splits
load_metadata_threadsinto listing threads (walk key-prefix directories, enqueue individual key directories) and loading threads (drain the queue, build in-memory metadata per key). Listing threads previously exited as soon as all prefixes were listed, leaving only the loading threads (half ofload_metadata_threads) to process the — usually dominant — remaining keys. Up to half the threads sat idle for the bulk of the work.Now, once a listing thread runs out of prefixes to list, it joins the loading threads in draining the queue (the shared
drain_queuehelper), so allload_metadata_threadsthreads load keys during the tail of the operation.The listing/loading split and the startup log line are unchanged. Behavior is otherwise identical; covered by the existing
test_parallel_cache_loading_on_startupintegration test.Related: #107414
Related: #107415
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 letting directory-listing threads help load cache metadata once listing is finished, instead of leaving half the threads idle.
Documentation entry for user-facing changes
Version info
26.6.1.806