Repository navigation
Add parser memory comparison job implementation - #96199
Conversation
|
Workflow [PR], commit [e8b724b] Summary: ✅ AI ReviewSummaryThis PR adds the standalone implementation of the parser-memory comparison job and its focused unit tests, while deferring workflow activation to a follow-up PR. The current code still has two material issues: one supported CI checkout mode cannot resolve a valid master baseline, and one reporting path can attach an aggregated byte delta to the wrong stack label. Missing context / blind spots
Findings
Final VerdictRequest changes. |
Made-with: Cursor # Conflicts: # .github/workflows/pull_request.yml # ci/defs/defs.py # ci/defs/job_configs.py # ci/workflows/pull_request.py # src/Common/Jemalloc.cpp # src/Common/Jemalloc.h # src/Parsers/examples/parser_memory_profiler.cpp
The merge with master replaced parser_memory_profiler.cpp with master's version, which moved symbolization from Jemalloc.h to JemallocProfileSource.h but lost the --symbolize-batch CLI mode needed by the CI script. Re-adds --symbolize-batch using the new symbolizeJemallocHeapProfile() API. The global SymbolizationLRUCache handles cross-file address deduplication. Also removes unused run_profiler_with_heap() from the CI script. Made-with: Cursor
Made-with: Cursor # Conflicts: # src/Parsers/examples/parser_memory_profiler.cpp
Made-with: Cursor
…s --symbolize-batch The parser_memory_profiler binary is PIE (position-independent executable) on aarch64 builds, so ASLR randomizes the base address on each invocation. This means addresses in heap files from one process cannot be symbolized by a different process invocation (--symbolize-batch), resulting in '??' stacks. Fix: pass --profile --symbolize together so symbolization happens in the same process that generated the heap profile, where addresses are valid. Made-with: Cursor
Revert the in-process symbolization workaround back to the 3-phase batch approach: (1) profile queries, (2) batch-symbolize all heap files in a single --symbolize-batch call, (3) analyze results. The batch approach is much faster (~3 min vs ~3 hours) because it resolves DWARF symbols once per binary instead of per-query. It requires the parser_memory_profiler binary to be non-PIE (fixed addresses), which is addressed in a separate PR. Made-with: Cursor
Made-with: Cursor # Conflicts: # .github/workflows/pull_request.yml # ci/workflows/pull_request.py
| "main", | ||
| "(anonymous namespace)::dumpProfile", | ||
| "dumpProfile", | ||
| "kdf_sshkdf_free", |
There was a problem hiding this comment.
This is likely due to wrong resoling, let's remove this to know that we have this bug
Each expanded query row now shows: - Cross-version diff table (PR minus Master per stack) - PR allocation flamegraph (server-side SVG icicle chart) - Individual profiles (existing, preserved) Made-with: Cursor
| status = "OK" | ||
| total_improvements += 1 | ||
| else: | ||
| status = "OK" |
There was a problem hiding this comment.
Result status uses wrong string constants
High Severity
The per-query Result objects are created with plain string statuses "FAIL" and "OK" (lines 995, 998, 1001), but the rest of the file and codebase consistently uses Result.Status.FAILED and Result.Status.SUCCESS constants (see lines 841, 850, 855, 929, 932, 955, 1078, 1080). If these constants differ from the plain strings (which is very likely — e.g. Result.Status.FAILED is probably "failure" not "FAIL"), every per-query Result will carry an invalid status, breaking CI report rendering and status aggregation.
Additional Locations (1)
There was a problem hiding this comment.
"OK" -> Result.StatusExtended.OK
Made-with: Cursor # Conflicts: # .github/workflows/pull_request.yml
# Conflicts: # .github/workflows/pull_request.yml
Use `clickhouse-examples` published by the ARM release build for the PR artifact dependency and master lookup. Remove the redundant examples target from `arm_binary` and fail the check when no reference artifact can be resolved. CI: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/ebbae7f1776ece4e50c423e2f03ab7d210b819d6/parser_memory_check/job.log Related: #111398
Do not analyze missing symbolized heap profiles or publish misleading green query results after `batch_symbolize` fails. Clean the temporary heap profiles and finish the job immediately with the existing failure result. Add a regression test that verifies analysis and HTML report generation are not called on this path. Review: #96199 (comment) CI: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/ebbae7f1776ece4e50c423e2f03ab7d210b819d6/parser_memory_check/job.log
| Iterates master_track_commits_sha (like performance_tests.py) to find | ||
| the closest available build. Returns empty string if none found.""" | ||
| info = Info() | ||
| commits = info.get_kv_data("master_track_commits_sha") or [] |
There was a problem hiding this comment.
get_merge_base_profiler_url currently depends entirely on master_track_commits_sha. In PR CI that key is populated by store_data.py from git rev-parse HEAD^1, but the workflow also supports DISABLE_CI_MERGE_COMMIT=1, which checks out the raw PR head instead of the synthetic merge ref. In that mode HEAD^1 is just the PR commit's parent, so this loop ends up probing REFs/master/<pr-branch-sha>/build_arm_release/clickhouse-examples and eventually fails with No master clickhouse-examples artifact was found.
Could we add the same GitHub-API fallback that promql_compliance_s3.master_track_commits / llvm_coverage_job.get_git_info use, so the baseline lookup stays valid in both checkout modes?
Match stacks using one primary symbol per physical backtrace address so DWARF inline expansions in master correlate with stripped PR symbols. Normalize LLVM clone suffixes while retaining full inline stacks for display and detailed allocation flamegraphs. Exclude stacks containing `dumpProfile` from measured totals and differential flamegraphs because profile filename construction is profiler bookkeeping, not parser memory. Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/cd143e56627fbed82d9a5295e4733fe6c060efa5/parser_memory_check/parser_memory_report.html
Build and publish the `clickhouse-examples` multicall binary from the PR and master ARM release jobs. Keep backport and release-branch jobs unchanged to avoid unnecessary artifact uploads. Related: ClickHouse#96199 CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/ebbae7f1776ece4e50c423e2f03ab7d210b819d6/parser_memory_check/job.log
Ignore unstable Boost.Container allocation plumbing only when it leads to the same `DB::` caller, while preserving the original stack for display. Current report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/557e1692b6cf87dfff9dae7acc9944423232e8bf/parser_memory_check/parser_memory_report.html Original report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/cd143e56627fbed82d9a5295e4733fe6c060efa5/parser_memory_check/parser_memory_report.html
Use the same canonical stack aggregation for the cross-version table and differential flamegraph. Exclude identical stacks so queries such as `SELECT 1` render an empty diff instead of a full red/blue graph caused by symbolization differences. Report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/557e1692b6cf87dfff9dae7acc9944423232e8bf/parser_memory_check/parser_memory_report.html
| display_map = {} | ||
| for b, s, _full, canonical in stacks: | ||
| key = tuple(canonical) | ||
| byte_map[key] = byte_map.get(key, 0) + b |
There was a problem hiding this comment.
aggregate_canonical_stacks sums all stacks that collapse to one canonical key, but display_map[key] = s keeps only the last label. Because compute_diff sorts stacks by |diff| before they reach this helper, the surviving label is usually the smallest contributor in that merged group rather than the dominant one.
A minimal repro on the current code is:
compute_cross_version_diff(
[
(100, "big stack", [], ["DB::A", "DB::B"]),
(10, "small stack", [], ["DB::A", "DB::B"]),
],
[],
)
# [(-110, 110, 0, "small stack")]The row reports 110 B but points at small stack, which can send triage to the wrong allocation site. Please keep the largest-|bytes| representative (or render the canonical form / all merged displays) when aggregating a canonical key.
|
📊 Cloud Performance Report ✅ AI verdict: This PR is CI-infrastructure-only: it adds a "Parser memory check" job with its supporting script and tests, and cleans up a build-target special case. None of these changes touch the server's query-execution path, so no clickbench query delta can be attributed to it. The flagged Q15 "improvement" (-13.5%) is downgraded to not_sure as run-to-run variance, and the Q30/Q31/Q32 deltas are consistent with normal noise (Q30 and Q31 fall inside master's current variance band, Q32's two tests disagree). The envelope suppressions look correct given the diff. clickbenchFlagged queries (4 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. 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🟢 No significant changes Debug info
|
Keep the parser memory job and its tests in this PR, but restore workflow generation, job registration, and build configuration to `master`. The activation will follow in a short-lived PR after this implementation merges.
Restore the original 100-byte threshold and include the CI source-of-truth files in the parser memory job digest so wiring-only changes run the check and retain the ARM release artifact provider. Related: #113491 Related: #96199 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113491&sha=aba0b3c805159c3f9277934caf3a8745b1914553&name_0=PR Report example: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/cd143e56627fbed82d9a5295e4733fe6c060efa5/parser_memory_check/parser_memory_report.html
Bundle the stateful profiler in clickhouse-examples and add a separate report job that reuses the parser memory check's stack correlation and flamegraph helpers. Related: ClickHouse#96199 Reference report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/96199/cd143e56627fbed82d9a5295e4733fe6c060efa5/parser_memory_check/parser_memory_report.html




Adds the parser-memory comparison job implementation and its unit tests without
registering or running the job in any CI workflow.
The job profiles SQL parsing allocations with
clickhouse-examples, comparesthe PR binary with the merge-base master artifact, correlates stacks across
different symbolization modes, and produces per-query tables and flamegraphs.
CI activation is intentionally deferred to a separate, short-lived PR after
this implementation merges. This keeps frequently changing public and private
CI configuration files out of the long-lived implementation review.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not applicable.
Version info
26.8.1.832(included in26.8and later)