Skip to content

Perf CI: compare PR builds with a master build compiled with the PR flags - #124676

Merged
Algunenano merged 8 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-reference-built-with-pr-flags
Oct 20, 2026
Merged

Algunenano merged 8 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-reference-built-with-pr-flags

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #100391
Related: #122350
Related: #124592

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Performance Comparison (amd_release, master_head, 6/6) failed on #100391: window_functions_distinct #2 11.0 -> 13.9 ms, a query reading only numbers.

In master_head mode the reference is master's official build, which keeps debug info and sets -DCLICKHOUSE_OFFICIAL_BUILD=1. A PR build has neither, so the same sources give different binaries: the CI-only #123849 has 0x65500 bytes less code than the official build of its base and was 21.6% slower on that query. On some bases a hot loop lands on a placement slow only in the PR flavour: on bases 1899759dcd6, e95690ab45b, 516006f49ad 18 of 25 PR runs were >15% slower, elsewhere 4 of 169, master against master 0 of 90.

Change:

  • MasterCI's Build (amd|arm_release_pr_cache_warmup), which compile master with the PR flags, become Build (amd|arm_release_performance_reference) and now link and upload the server binary, with the release build's PGO/BOLT. The options that tell an official build from a PR build (-DCLICKHOUSE_OFFICIAL_BUILD=1, -DDISABLE_ALL_DEBUG_SYMBOLS=1) are set in one place, flavor_cmake_options.
  • PR runs of performance_tests.py use that binary as the reference. Past the first official build, the lookup crosses only commits where MasterCI skipped the job (same sources), else keeps the official build. Over 14 days, 332 of 356 references get one, none with different sources. Master runs still compare official builds.

Tested: every build type's cmake command is unchanged and the reference's equals a PR build's; stubbed walk; read-only S3 probes.

Cost: the link adds ~24 min (amd) and ~39 min (arm) per reference run, ~40-70 ARM runner-hours/day, ~540 MB S3 per run. MasterCI wall clock is unchanged; no PR job is added. The Build profile diff baseline restarts under the new name.

Not fixed: placement shifts from a PR's own code, and per-process (PIE) noise. #124592 calls a reference found over skipped commits stale, though its sources match.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/124676]

Version info

  • Merged into: 26.11.1.277-master (included in 26.11 and later)

groeneai and others added 2 commits October 8, 2026 13:56
In `master_head` mode the PR performance comparison used master's official
release build as the reference. That build keeps debug info and sets
`-DCLICKHOUSE_OFFICIAL_BUILD=1`, while a PR release build has
`-DDISABLE_ALL_DEBUG_SYMBOLS=1` and no official flag. Both change the
generated code (XRay instruments ~11k more functions when debug info is
present, and the official flag adds code), so the same sources give two
binaries with different code layout. The CI-only ClickHouse#123849 has 0x65500 bytes
less code than the official build of its own base e95690a and was
21.6% slower on `window_functions_distinct ClickHouse#2`. On some master bases a hot
loop lands on a slow placement only in the PR flavour, and every PR on that
base then reds (seen on ClickHouse#100391).

MasterCI's `Build (amd|arm_release_pr_cache_warmup)` jobs already compile
master with exactly the PR cmake flags. They now also link
`clickhouse-self-extracting` and upload it, and take the PGO/BOLT decision
of the release build they mirror, as a PR build does.

For PR runs of the public repository, `find_prev_build` prefers that binary.
When the base has none it walks back only over commits where MasterCI
skipped the warmup job (a skipped job means its inputs did not change, so
the older build has the same sources); anything else falls back to the
official build. Replayed over 14 days of PR references, 332 of 356 get a
build with identical compiled sources and none gets different sources.
Master runs (official vs official) and local runs are unchanged. The report
parsing of `classify_missing_prev_master_run` moves into
`master_job_status`, shared by both walks.

The arm warmup's build-profile upload stays what it was (compiled objects):
the server link trace is deleted before extraction and the symbol table of
the linked binary is not uploaded, so the shared build-profile cluster gets
no new load.

Cost: ~24 min (amd) and ~39 min (arm) of ThinLTO link per warmup run and
~540 MB of S3 per run with default retention. MasterCI wall clock is
unchanged and no PR job is added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The warmup builds now take the PGO decision of the release build they
mirror, so a warmup with a profile enters the "build with PGO failed"
retry. That retry ran only `ninja <targets>`, which for a warmup is the
server link alone: a PGO failure in an object outside the server target
would give a green warmup that skipped the all-object cache warmup. Rerun
the command of the first attempt instead; for every other PGO-eligible
build it is the same `ninja <targets>` as before.

Also map an explicit `"status": null` in the master report like a
missing status in `master_job_status`, as the code before the refactor
did, and say in the build profile hook comments that only the server
binary's link trace and symbols are kept out of the warmup upload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 8, 2026
@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 3 findings over 3 runs, the last one clean) plus my own cold reviews (4 nits).

# Sev Finding Verdict Evidence / action
0 ⚠️ A warmup whose PGO build fails is retried with only ninja clickhouse-self-extracting, skipping the all-object warmup and possibly publishing a no-PGO reference (build_clickhouse.py PGO retry) AGREE, fixed @ ff5f897 The retry reruns the build's own command; checked by driving main() with a failing first build (fails before the fix, passes after).
1 ❌ find_pr_flags_build passes over commits with no build yet, so it can pick an older PR-flags build whose sources differ (performance_tests.py L1484-1491) DISAGREE The official lookup it would fall back to (find_master_build, unchanged) passes over the same commits and picks the same commit's official build: same source gap, plus the flag gap this PR removes. The PR-flags hit is never older than the official one there. Body wording made precise.
2 ⚠️ The linked warmup also uploads size rows of archives/helper tools and the helpers' small link traces DISAGREE True, but no consumer reads them: every Build profile diff query is pinned to its check_name, warmup rows are used only through the .o filter and ExecuteCompiler events; ~350 extra size rows next to ~17K object rows. The server binary's link trace and symbols (the bulk) stay out. Body wording made precise.
3 💡 A "reused from cache" skip proves equality with the cached run, not with the next older build (revert to an earlier digest) AGREE, not blocking Needs a revert plus an official cache miss; the official lookup shares the weakness; 0 cases in the 14-day replay.
4 💡 An explicit null job status classified as never scheduled AGREE, fixed @ ff5f897 Now incomplete, as before the refactor.
5 💡 Body said "every PR on that base" for 18 of 25 runs AGREE, fixed Wording.
6 💡 A PGO-only compile failure confined to an object outside the server binary would make the warmup fall back to no PGO while PR builds keep it AGREE, not blocking A stale profile hits every translation unit alike, and no profiles are shipped today (CLICKHOUSE_PROFILES_COMMIT=none).

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261008-151800

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1087a07]

Summary: ✅


AI Review

Summary

The PR builds master performance references with the public PR release flags, selects them for PR performance comparisons, and preserves official references for master and private PRs. Review of commit 1087a0740f44a459d3e947e264f6a27d0a76606c found no actionable issues. The prior baseline-selection finding is fixed: both baseline discovery and run resolution require object-file rows. Focused checks passed for amd/arm configuration parity with PGO/BOLT, retry behavior, reference lookup failure paths, and workflow selection.

Final Verdict

✅ Approve. No unresolved findings or new inline comments. Verification used mocked build commands; no full ClickHouse build was performed.

…ence-built-with-pr-flags

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 10, 2026
groeneai and others added 2 commits October 10, 2026 19:52
The warmup build now links and records its binaries in binary_sizes, so a
warmup upload without object rows would be taken as a complete baseline and
the object-size section would report every PR object as added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
find_warmup_baseline picks the warmup commit by an object-file row, but
resolve_run then took the newest binary_sizes run of that commit. A rerun
that recorded only the linked binaries would become the warmup side, and
compare_objects would report every PR object file as added. resolve_run
gets an optional filter, and the warmup side passes OBJECT_FILTER, the same
predicate as the marker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 31 queries analysed

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
  • StressHouse run: 8ba80e6b-a4a8-45bf-96cb-d6b955bb9d88
  • MIRAI run: e47b26ba-ecce-4f40-a5b2-4f1ebd02dc9b
  • PR check IDs:
    • clickbench_823105_1791690294
    • clickbench_823111_1791690294
    • clickbench_823117_1791690294
    • tpch_adapted_1_official_823124_1791690294
    • tpch_adapted_1_official_823138_1791690294
    • tpch_adapted_1_official_823175_1791690294

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - c29da3b

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05339_parquet_prewhere_subcolumn_read_through_column not from this PR (it changes ci/ scripts only): the test passes a session temporary table to IcebergLocal, which the replicated DDL worker cannot see (UNKNOWN_TABLE on iceberg_path). 12 PRs and 30 master runs show it since 2026-10-10 21:55Z #125121 (external, merged 00:36Z), the revert of my #124685 that added this test. The tested merge commit predates it, so I will merge master here to pick it up
Mergeable Check, PR praktika rollups of the row above #125121 (external, merged)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20261011-013008

@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 1087a0740f44a459d3e947e264f6a27d0a76606c was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception; stopped retrying after the 1250 s read budget).

See the job log for details.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 9d26d5c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, parallel) / 05316_top_k_primary_key_skip_query_condition_cache flaky, not from this PR (it changes ci/ scripts only): the repeated read is sometimes not made cheaper by the query condition cache (1 0 instead of 1 1); 198 of 198 reruns passed #125152 (mine, open)
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 05317_local_read_throttler_filesystem_cache flaky, not from this PR: under parallel replicas the remote replicas can read every mark, so the checked ProfileEvents land on their query_log rows (0 1 instead of 1 1); 40+ PRs and 6 master runs in 2 days #124920 (mine, open)
Mergeable Check, PR praktika rollups of the rows above #125152 and #124920 (mine, open)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20261011-053007

@egor-click

Copy link
Copy Markdown
Contributor

@groeneai i think the goal is correct, but i am not sure the tradeoff is right
adding 25-40 minutes per job is too much

what are other options you have considered with smaller blast radius?

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks. Options I considered, with their cost:

  1. Build PRs with debug info, like master. The official amd build job (its cmake differs from a PR build only by debug info and the official-build flag) takes 72 min p50 against 33 for a PR build (CIDB, last 7 days). That lands on every PR.
  2. Build the reference inside each PR perf job: one more release build (33-47 min) per PR.
  3. Link only the amd warmup: +24 min on one MasterCI job; arm keeps the official reference.
  4. Remove the difference instead of building around it. CLICKHOUSE_OFFICIAL_BUILD only adds a version string and a hash section after the link, so the code difference between an official and a PR build of one commit comes from XRay counting debug instructions towards its threshold: about 11K functions get sleds only with -g (Build profile diff: do not report the debug-info offset as a size change #116639 traced the whole size gap to it). The fix is small, [XRay] Don't count debug instructions towards the instruction threshold llvm/llvm-project#219100 (open, no review yet), and CI builds its own toolchain from release/22.x in ci/jobs/build_toolchain.py, which already patches Ninja, so it can carry this patch. The toolchain also needs a versioned ld.lld-22: today the release link picks the distro /usr/bin/ld.lld-22, and with ThinLTO the XRay pass runs in the linker. Cost: one toolchain rebuild, nothing per run, and Perf CI: compare PR builds with a master build compiled with the PR flags #124676 is no longer needed. The shipped binary then has the XRay sleds of a -g0 build, so about 11K fewer functions for SYSTEM INSTRUMENT.

I would pick 4. Before sending it, I would build one commit with -g and -g0 on the patched toolchain and check that .text has the same size and layout. Should I go with 4 and close #124676 once the new toolchain is in?

@Algunenano

Copy link
Copy Markdown
Member

@groeneai I think the best option is to make an extra master build with the same flags as the PRs, for 2 reasons:

  • PR builds are faster. Since they are in the slow path already, making them slower would make CI runs slower which we want to avoid.
  • Final master builds, if using PGO, would still not be comparable with PR builds with "official" flags, so we'd be in the same situation.

So please, add a new build (reusing the profile build as you did is fine), but make sure the binary is built exactly with the same flags (let's put flags and cmake options like no debug in a common place) and that we name this binary something understandable like release_performance_reference or similar. Then PRs will use this binary for comparison, and master builds can compare official build vs official build

@Algunenano Algunenano self-assigned this Oct 19, 2026
groeneai and others added 2 commits October 19, 2026 12:38
…ence-built-with-pr-flags

# Conflicts:
#	ci/defs/defs.py
…e_reference`

Review on ClickHouse#124676: keep reusing the MasterCI build that compiles master with
the PR flags, but make it explicit that its binary is the performance
reference, and keep the cmake options that tell an official build from a PR
build in one place so the reference cannot drift from a PR build.

- Rename `Build (amd|arm_release_pr_cache_warmup)` to
  `Build (amd|arm_release_performance_reference)`, with the artifacts
  `CH_AMD|ARM_RELEASE_PERFORMANCE_REFERENCE`. The job still compiles every
  object with the shared sccache read-write, and the arm one still uploads
  the build profile baseline, now under the new check name.
- `flavor_cmake_options` in build_clickhouse.py is the only place that adds
  `-DCLICKHOUSE_OFFICIAL_BUILD=1` (official) or `-DDISABLE_ALL_DEBUG_SYMBOLS=1`
  (PR, public, ThinLTO). A reference build takes the PR options, the cmake
  line of its release build type and that build's PGO/BOLT decision.

Behavior is unchanged: for every build type, master/PR, public/private and
with/without PGO+BOLT profiles, main() produces the same cmake and build
commands as before the refactor (280 combinations), and the reference cmake
equals the PR release cmake for amd and arm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in 1087a07, plus a master merge for the conflict in ci/defs/defs.py:

  • The reference still reuses the MasterCI build that compiles master with the PR flags, now named Build (amd_release_performance_reference) and Build (arm_release_performance_reference) (artifacts CH_AMD_RELEASE_PERFORMANCE_REFERENCE, CH_ARM_RELEASE_PERFORMANCE_REFERENCE). PR perf runs compare against it; master runs compare official against official.
  • flavor_cmake_options in build_clickhouse.py is now the only place that adds the official-only -DCLICKHOUSE_OFFICIAL_BUILD=1 or the PR-only -DDISABLE_ALL_DEBUG_SYMBOLS=1. The reference build takes the PR options, the cmake line of its release build and that build's PGO/BOLT decision. I ran main() for every build type, master and PR, public and private, with and without PGO/BOLT profiles: the commands are the same as before, and the reference cmake equals the PR release cmake for amd and arm.

The arm build's Build profile diff baseline is now stored under the new name, so it restarts from the first master run after the merge.

@Algunenano

Copy link
Copy Markdown
Member

@groeneai How does the transition to use these images work? What happens when we merge and there isn't any build yet?

@groeneai

Copy link
Copy Markdown
Collaborator Author

Nothing has to be done by hand at merge. The PR perf job looks the reference up on S3 in every run (no job requires it), so a missing build only changes which binary it compares with:

  • Until a MasterCI run has published Build (amd_release_performance_reference) / Build (arm_release_performance_reference), the walk over the tested master commits finds no such job in their MasterCI reports, logs no performance reference build, the reference is the official build and compares with the official master build, as today. I ran find_prev_build from this branch against current master just now: amd and arm both return the official build that way.
  • The MasterCI run of the merge commit always builds it: the job name is new, so there is no cache record that could skip it. From then on, every PR run whose tested master (HEAD^1 of the CI merge commit) contains it uses the reference build. Later master commits where the job is skipped (inputs unchanged) are walked back to the last one that built it.
  • If a reference build is missing for any other reason (failed, still running), that run falls back to the official build, as today.

Build profile diff behaves the same way: its object and per-TU sections show the catch-up note until that first master run, not a failure.

@Algunenano
Algunenano enabled auto-merge October 19, 2026 16:56
@Algunenano
Algunenano added this pull request to the merge queue Oct 20, 2026
Merged via the queue into ClickHouse:master with commit ba608dd Oct 20, 2026
178 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants