Repository navigation
Initialize profiler mark caches and handle uncached async loading - #119516
Conversation
MergeTree reads require a context mark cache. Initialize it with the server settings and cap its configured size to the available-memory ratio, matching clickhouse-local. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=0f939338cdc9cacc29a817cef37492e3f8d7e5ba&name_0=PR&name_1=Storage%20memory%20check Related: ClickHouse#119480
|
Workflow [PR], commit [b8aa31c] Summary: ✅
AI ReviewSummaryThis PR initializes the regular and secondary-index mark caches in Findings
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit b8aa31c.
Changed lines: Changed C/C++ lines covered: 30/67 (44.78%) · Uncovered code |
Mirror clickhouse-local initialization for the index mark cache and force a skip-index read in the storage scenario so the asynchronous marks-loading path is covered. Related: ClickHouse#119516 Related: ClickHouse#119480
Mirror clickhouse-local initialization for the index mark cache and force a skip-index read in the storage scenario so the asynchronous marks-loading path is covered. Related: ClickHouse#119516 Related: ClickHouse#119480
Expose an intentional null-cache mode so CI can exercise asynchronous mark loading without relying on an accidentally incomplete context. Related CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=0f939338cdc9cacc29a817cef37492e3f8d7e5ba&name_0=PR&name_1=Storage%20memory%20check Related PR: ClickHouse#119480
Fix the ARM tidy `readability-use-std-min-max` diagnostics in the mark-cache initialization added by this pull request. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=be756d66cfbd3b257d0145ff82522835511245cb&name_0=PR&name_1=Build%20%28arm_tidy%29 Related PR: ClickHouse#119480
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 17 s compile time in total, 8 of them have a recent master baseline. |
Cover the null mark-cache path directly in MergeTreeMarksLoader. The test starts an asynchronous zero-mark load with no cache; the old implementation dereferenced storage during the cache lookup, while the fixed implementation completes through the uncached loader. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=c5b92dd3b19f7c641e86c2588b5861b3c7b4deaf&name_0=PR&name_1=Storage%20memory%20check PR: ClickHouse#119480
| const size_t configured_mark_cache_size = server_settings[ServerSetting::mark_cache_size]; | ||
| const size_t mark_cache_size = std::min(configured_mark_cache_size, max_cache_size); | ||
| const double mark_cache_size_ratio = server_settings[ServerSetting::mark_cache_size_ratio]; | ||
| global_context->setMarkCache(mark_cache_policy, mark_cache_size, mark_cache_size_ratio); |
There was a problem hiding this comment.
storage_memory_check.py runs the scenario list from the PR checkout against both binaries (ci/jobs/storage_memory_check.py:43-63 and :192-193). With the default cache initialization added here, the PR-side storage_memory_profiler now retains mark-cache entries after the new read in 03_add_secondary_indexes.sql, while the downloaded merge-base binary still has null mark caches and frees the same marks at query end.
That means the shared master/PR comparison is no longer measuring the storage scenario alone; for this PR it is also measuring "mark_cache/index_mark_cache enabled" vs "mark_cache/index_mark_cache absent". Because the storage-memory job flags any change above 100 bytes, even one cached marks file is enough to look like a regression. Please keep the shared comparison on a behavior the current master binary can reproduce, and move the cache-enabled validation to a separate path or make it opt-in instead of the default.
The storage memory profiler creates a lightweight global context but did not initialize its regular or secondary-index mark caches.
MergeTreereads could therefore pass a null cache pointer into asynchronous mark loading and fail inpthread_mutex_lockduring the storage scenarios.Initialize both caches from the server settings and cap them by the configured RAM ratio, matching
clickhouse-local.MergeTreeMarksLoaderalready supports a missing cache in synchronous loading, so make the asynchronous path equally safe by skipping the cache lookup while preserving uncached loading through the existing thread pool.Add
--no-mark-cachesas an intentional validation mode. The related CI PR runs a dedicated PR-only scenario with asynchronous mark loading and a forced data-skipping index under this mode, while the shared master/PR comparison stays backward-compatible.Failing CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=0f939338cdc9cacc29a817cef37492e3f8d7e5ba&name_0=PR&name_1=Storage%20memory%20check
Related: #119480
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not applicable.
Workflow [PR]
Sync PR [sync-upstream/pr/119516]
Version info
26.9.1.1239(included in26.9and later)