Repository navigation
Enable storage memory scenario check in PR CI - #119480
Conversation
Run the stateful storage scenarios as a separate check while reusing the existing parser memory reporting helpers and the clickhouse-examples artifact. Related: ClickHouse#115675
|
Workflow [PR], commit [150d1f2] Summary: ✅ AI ReviewSummaryThis PR adds the Findings
Final VerdictNot ready to merge. The new |
Include the lane definition and PR workflow sources in its digest so changes that wire or configure the check execute it instead of filtering it out.
The ARM CI binaries both received SIGSEGV while cloning a table after its indexes and projection were materialized. Define the additional tables explicitly and log each query before execution for actionable failures. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=0f939338cdc9cacc29a817cef37492e3f8d7e5ba&name_0=PR&name_1=Storage%20memory%20check PR: ClickHouse#119480
This reverts commit a44beb5.
Temporarily expose the exact statement that receives SIGSEGV in the ARM storage memory check. This diagnostic will be reverted from the CI-enablement PR after the separate tool fix is validated. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119480&sha=0f939338cdc9cacc29a817cef37492e3f8d7e5ba&name_0=PR&name_1=Storage%20memory%20check PR: ClickHouse#119480
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
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
Run a PR-only storage scenario with asynchronous mark loading and both mark caches intentionally absent. This covers the null-cache server path without requiring the older master baseline binary to understand the new option. 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
Duplicate the validation option temporarily so the CI-only PR can exercise the server fix before the tool PR is merged into master. 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
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 temporary copy of the profiler changes used to validate the CI job. 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
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, 18 s compile time in total, 8 of them have a recent master baseline. |
The merge-base profiler does not initialize its mark caches, so force synchronous mark loading in the shared multi-table scenario. The PR binary still exercises asynchronous loading without caches in its dedicated validation run. 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
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
| { | ||
| no_system_tables = true; | ||
| } | ||
| else if (arg == "--no-mark-caches") |
There was a problem hiding this comment.
Exposing --no-mark-caches here makes Context::getMarkCache() and Context::getIndexMarkCache() null for arbitrary SQL, but the profiler still attaches system tables by default. system.server_settings and getServerSetting are not safe under that contract: collectChangeableServerSettings unconditionally dereferences both caches at src/Core/ServerSettings.cpp:3632-3634, so even a trivial scenario like SELECT getServerSetting('max_concurrent_queries') will hit a null dereference in this mode.
Please either keep zero-sized caches instead of leaving them null, or make the live server-settings path null-safe before exposing --no-mark-caches as a user-visible option.
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
| @@ -525,31 +527,43 @@ def store_settings_history_changes(info, path=SETTINGS_HISTORY_FILE): | |||
| # store integration test diff to find: TODO: find changed test cases | |||
| if info.pr_number: | |||
| # store master side commits for perf tests comparison | |||
There was a problem hiding this comment.
Info.sha on PR workflows is the PR head SHA (pull_request.head.sha in ci/praktika/_environment.py), not the synthetic merge commit. In DISABLE_CI_MERGE_COMMIT=1 mode this branch now depends on gh api repos/ClickHouse/ClickHouse/compare/master...{info.sha} succeeding, but that only works when the head commit is resolvable in the public upstream repo.
That regresses the supported ClickHouse/ClickHouse-private / fork-PR case: a private-only head SHA leaves merge_base_commit_sha empty here, so the code below stores no master_track_commits_sha at all. The baseline-driven jobs that consume that metadata (Parser memory check, Storage memory check, build_profile_diff, perf, coverage, ...) then lose their master artifact lookup in raw-head mode.
Please derive the merge base from a ref that is guaranteed to exist in the current checkout / current PR repo, instead of hard-coding the compare call to ClickHouse/ClickHouse.
| if os.getenv("DISABLE_CI_MERGE_COMMIT") == "1": | ||
| # HEAD is the raw PR head in this mode, so HEAD^1 is another PR | ||
| # commit. Walk master from the merge base resolved above instead. | ||
| master_parent_commits = ( |
There was a problem hiding this comment.
Using merge_base_commit_sha as the anchor still does not give you a master first-parent chain. get_master_first_parent_commits explicitly follows parents[0], so if a branch was cut from another PR head before that branch was merged, git merge-base master <head> is the side-branch commit, not the merge commit that actually landed on master.
In that shape, this call walks X2 -> X1 -> ... down the old side branch and never visits the merge commit M on master, so master_track_commits_sha starts with commits that never had MasterCI artifacts. The memory/perf baseline lookup can still fall back to a non-master or much older build in DISABLE_CI_MERGE_COMMIT=1 mode.
The anchor here needs to be a commit that is guaranteed to be on master's first-parent chain (for example the tested master-side base commit), not the raw merge-base object.
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Prevent background merge selection allocations from crossing the heap profile checkpoint. CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/119480/5d231d28a46818502ba21e1aea90437e3c99586e/pr/storage_memory_check/storage_memory_report.html
…y-ci # Conflicts: # .github/workflows/pull_request.yml
| print( | ||
| f"Stored {len(master_parent_commits)} master parent commits for perf test comparison, starting from {master_parent}" | ||
| ) | ||
| if os.getenv("DISABLE_CI_MERGE_COMMIT") == "1": |
There was a problem hiding this comment.
why did you add this? DISABLE_CI_MERGE_COMMIT=1 is not used
There was a problem hiding this comment.
Because the workflow still exposes DISABLE_CI_MERGE_COMMIT in both PR and BackportPR, and other CI code already treats raw-head checkout as a supported mode (ci/jobs/unit_tests_bugfix_validation_job.py:135-155). This patch makes master_track_commits_sha depend on merge_base_commit_sha in that mode, so if the org variable is enabled for debugging or incident mitigation the baseline-selection jobs start depending on this path immediately.
The stateful profiler can observe a short-lived background executor task at a checkpoint, which adds several hundred bytes of run-to-run noise. Use a 1 KiB absolute threshold for this lane and display the lane-specific threshold in the HTML report. CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/119480/443667af6f7516d5107c4cc63fb9327d4fe63278/pr/storage_memory_check/storage_memory_report.html
The `Storage memory check` job added in ClickHouse#119480 (and the `Parser memory check` job, whose digest the same PR degraded) listed generic, high-churn paths in their `digest_config.include_paths`: - `./ci/defs/defs.py` - `./ci/defs/job_configs.py` - `./.github/workflows/pull_request.yml` - `./ci/workflows/pull_request.py` - `./ci/jobs/scripts/workflow_hooks/store_data.py` `store_data.py` is a workflow-wide pre-hook shared by ~10 workflows, not a source file these jobs use. Because these generic files change in many unrelated pull requests, the jobs' cache was constantly invalidated and they re-ran on changes that do not affect them. Restrict each digest to the job script and the source files it actually uses: - `Parser memory check`: `parser_memory_check.py` + `utils/parser-memory-profiler/` - `Storage memory check`: `storage_memory_check.py`, `parser_memory_check.py` (imported by the job), + `utils/storage-memory-profiler/` Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ck scenario The job ran the 9-scenario sequence once per binary and diffed each checkpoint-to-checkpoint window between the master and PR clickhouse-examples builds. With no warmup, a one-time process initialization first touched inside window k is charged entirely to window k, and two different binaries reach those first touches after a different cumulative number of events, so the same one-time cost lands in different windows on the two sides. One window then reports a fixed positive offset and an adjacent one the same negative offset, which is silently accepted as an improvement. In the last 36 hours this failed 7 of 113 PR heads across five mutually unrelated PRs, none of which touches ci/. On four of them the reported regression was the identical constant +1,280 bytes on four different scenarios. Identified at the frame level: the allocation is a calloc whose two unresolved frames sit at libc addresses, outside the binary's own text, below the first touch of a function-local static. glibc keeps __cxa_atexit registrations in 32-entry blocks, so the 33rd, 65th, ... registration callocs a fresh struct exit_function_list of next(8) + idx(8) + 32 * sizeof(struct exit_function)(32) = 1,040 bytes, which jemalloc rounds up to its 1,280-byte size class and never frees. Against the 8 KB baseline of 08_parts_analysis that offset is 15.8%, so it clears both the absolute (1,024 B) and the percentage (1.0%) threshold and fails the job. Run the sequence once unmeasured before the measured pass, by passing the scenario list twice to the existing --file option and measuring only the second pass, using the previous pass's final checkpoint as the baseline. By then every path the scenarios exercise has initialized its statics and grown its pools, so no first touch is left inside a measured window. This is the mechanism of PR ClickHouse#115739, which fixed the same class in Parser memory check with a warmup parse, adapted to a stateful profiler. The change is in the job script rather than in the profiler because the master arm binary is downloaded from S3 built from master: a new flag would make the old master binary exit with Unknown option, and an unconditional C++ warmup would give the PR arm a warm baseline while master stayed cold. A job-side change applies to both arms in the same run from the same script, so it is symmetric from the first execution and needs no transition window. Deliberately not done: STORAGE_CHANGE_THRESHOLD_BYTES is untouched, no stack is filtered, and the symbolized file count per arm stays at 10 so the dominant cost of the job does not grow. Stack exclusion was rejected because the frames are unsymbolized, leaving only "leading frames are ??" (which would blind the check to every allocation inside any non-ClickHouse library) or "the delta is exactly 1,280" as keys. The latter is unsound beyond being a magic number: the same window contains three further +1,280 rows that are ordinary operator new[] from ThreadPoolImpl::scheduleImpl, so such a filter would hide real thread-pool regressions. Validated against three local clickhouse-examples builds. The class is present without the fix (2 rows), absent with it (0), and present again on a fresh unfixed run. It does not blind the check: with the fix in place, an injected real 64 KiB-per-table allocation still fails at +65,080 bytes on 01_create_table, +132,016 on 05_multiple_tables and shows exactly +65,536 on 07_many_parts. Cross-arm, an antisymmetric +12,192 / -12,192 pair that was the entire reported change of two adjacent windows collapses to +40 / -40, and five windows go to exactly zero. The sequence is re-runnable, which the second pass depends on: 09_cleanup.sql drops all five objects the other eight scenarios create, and all six two-pass runs across the three binaries exited 0. If a future scenario leaves an object behind, 01_create_table.sql's plain CREATE TABLE makes the profiler exit non-zero and the job report ERROR rather than mis-measure. The README records that contract for the next scenario author. Cost: the master and PR scenario runs are doubled while the download, the single-scenario pr-async-no-cache run and all symbolization are unchanged. Sized from CI data, where the download plus all three profiler runs occupy 10m27s of a 1,807 s job, the estimate is roughly +8 minutes. A regression that manifests only on the first touch of a code path is now charged to the unmeasured pass and no longer reported. This is the same tradeoff PR ClickHouse#115739 accepted and the correct one for a check whose subject is per-scenario storage memory. Related: ClickHouse#119480 Related: ClickHouse#115739 Co-Authored-By: Claude Opus 5 <[email protected]>
…cenario `Storage memory check` fails unrelated PRs with a byte-constant `change=+1,056`. Since ClickHouse#120487 removed the one-time initialization offset, 9 heads had `+1,056` as their only failing scenario, on `03_add_secondary_indexes.sql` and `04_add_projection.sql`. A pooled thread that runs a mutation step attaches to the task's `ThreadGroup` through `ThreadGroupSwitcher`, and that attach constructs thread-local performance-counter state: `TasksStatsCounters`, a `ProcfsMetricsProvider`, and two `__cxa_thread_atexit_impl` registrations which by construction live until the thread exits. `GlobalThreadPool` keeps its threads, so those bytes stay live once a thread has participated, and the quantity the checkpoint diff measures is how many distinct pool threads have ever served the scenario. Which window a thread's first participation lands in is a scheduling draw. It is one cluster of 7 stacks costing exactly 528 bytes per participating thread: +384 `TasksStatsCounters::create`, -64 `ThreadGroup::SharedData::SharedData`, +64 `detachFromGroup`, +48 `make_shared<ProcfsMetricsProvider>`, +32 and +32 for the two `__cxa_thread_atexit_impl` registrations, +32 for the query-id string copy in `applyQuerySettings`. The gate is `absolute_change > 1024 AND percent_change > 1.0`, so one unit passes and two clear it by 32 bytes: the threshold sits inside the noise quantum. PR ClickHouse#120702 at `b48703670359` has rows for `04_add_projection.sql` at both 528 and 1,056, the same commit measured twice with different answers, so no threshold value could measure this quantity. Raising the threshold is the move that already failed: `150d1f2d0290b` raised this lane from the parser lane's 100 to 1,024 for this exact mechanism, and two units cleared it three days later. Waiting for background tasks to quiesce cannot work either, because this state is registered with `__cxa_thread_atexit_impl` and is not a teardown tail. Pinning the pools to one thread would be C++-side, and the master arm binary is downloaded from the merge base, so such a fix is asymmetric until it reaches master. Instead add the three thread attach/detach frames to the analyzer's existing `EXCLUDED_STACK_FRAME_PREFIXES`, which `compute_diff` already consults before a stack reaches the gated total. Both arms of a run are analysed by the same script from the same checkout, so the change applies symmetrically from the first run, and keying on the allocation site covers every pool at once rather than enumerating pools or settings. On the production reports for ClickHouse#118967, ClickHouse#120960, ClickHouse#121251 and ClickHouse#120702, removing this cluster takes every failing scenario's change to exactly 0, with the largest residual anywhere 64 bytes against the 1,024-byte threshold. Locally, 20 repeated two-pass runs of one binary reproduce the 528-byte unit with the same 7-row composition and a multiplicity that varies run to run; an injected 64 KiB-per-table allocation is still reported at full size; and reverting only these three prefixes restores the pre-fix numbers byte-for-byte. Two consequences are deliberate. The cluster rows also leave the HTML report, exactly as `dumpProfile` overhead already does, because a row the check must not gate on should not be presented as a finding. And thread-accounting regressions are no longer measured here, which the same-commit pair above shows was never possible anyway. `STORAGE_CHANGE_THRESHOLD_BYTES` is left at 1,024. Removing this noise is what would make lowering it toward the parser lane's 100 possible, but that is a calibration decision with its own data. Related: ClickHouse#120487 Related: ClickHouse#119480 Co-Authored-By: Claude Opus 5 <[email protected]>

Adds a separate
Storage memory checkto pull request CI. The job runs the stateful storage scenarios with the pull request and merge-baseclickhouse-examplesbinaries, compares live-allocation deltas at every checkpoint, and publishes the existing HTML report with correlated stacks and differential flamegraphs.The job reuses the parser-memory symbolization and reporting helpers, but remains separate from
Parser memory checkbecause it measures stateful storage scenarios rather than isolated AST lifetimes. It also runs a PR-only validation scenario with asynchronous mark loading, a forced data-skipping index, and intentionally absent mark caches to cover the null-cache server path without requiring the older baseline binary to support the new profiler option.Example report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/119480/be2b9d727dc7b170d5193f32b1b505216acbd716/pr/storage_memory_check/storage_memory_report.html
Related: #115675
Related: #119516
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Workflow [PR]
Sync PR [sync-upstream/pr/119480]
Version info
26.9.1.1591(included in26.9and later)