Skip to content

Build amd_release without ThinLTO in PRs that skip the AMD performance comparison - #131328

Merged
alexey-milovidov merged 6 commits into
masterfrom
amd-release-without-thinlto
Nov 20, 2026
Merged

alexey-milovidov merged 6 commits into
masterfrom
amd-release-without-thinlto

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Build amd_release without ThinLTO in PRs that skip the AMD performance comparison: there it is the only consumer that cares how the binary is optimized.

The AMD performance comparison runs in a PR only with pr-performance, ci-performance, a "Performance Improvement" changelog category, or a full ARM run. Over 2026-11-06 to 2026-11-13 (CI DB), 2569 of 2983 PR amd_release builds (86%) had no AMD performance comparison, but still paid for ThinLTO: about 1060 runner-hours of arm-large in that week. The median Build ClickHouse step is 19.9 minutes for amd_release and 4.0 for arm_binary. The release build also gates the amd_release integration tests, packages and Docker images, so they start earlier.

Without ThinLTO, PGO and BOLT, the compile commands of amd_release are the same as those of amd_binary: 16224 of 16227 common translation units, checked by diffing compile_commands.json of both cmake configurations. The current PR amd_release shares only 298 of them (-flto=thin -fwhole-program-vtables -g0). Master builds amd_binary on every commit, so sccache already holds these objects and the build is mostly the link. The standalone clickhouse-keeper objects (166) are the exception; #130819 removes them.

The other consumers (packages, Install packages, Compatibility check, integration tests, Upgrade check, ClickBench, which checks correctness and not timings, the oracle AST fuzzer) do not depend on LTO. arm_release keeps ThinLTO, because the ARM comparison runs in nearly every PR (coverage selection still picks more than 200 test files in most of them), so ThinLTO miscompilations stay covered in PRs. Master, backports, release branches and the private repository are unchanged.

How:

  • configure_amd_release_thinlto (a pre-hook of the PR workflow) makes the decision with the same predicate as the filter that skips the AMD comparison (now the shared _amd_performance_skipped). It is a pre-hook because ci-force-all bypasses the filter hooks and then runs every performance job, so that case keeps ThinLTO.

  • Praktika gets a generic per-job digest salt from the workflow kv data (job_digest_salts). The non-LTO build and its dependents are cached under their own digest. A PR run may reuse any cached record, so without the salt a later run with the same digest that does run the AMD comparison (e.g. after adding pr-performance) could reuse a non-LTO binary. Trusted workflows never reuse PR records anyway.

  • build_clickhouse.py reads the flag and configures with -DENABLE_THINLTO=0 and without PGO/BOLT. flavor_cmake_options then does not add -DDISABLE_ALL_DEBUG_SYMBOLS=1, as in amd_binary.

  • The artifacts of a salted job go to their own S3 directory (Cache.artifact_dir, e.g. build_amd_release_without_thinlto), so the two variants built at the same commit (e.g. when pr-performance is added and removed) do not overwrite each other, and a cache record of one variant never restores the binary of the other.

This PR changes ci/jobs/build_clickhouse.py, which is a build change for the performance selection, so its own run keeps the AMD comparison and ThinLTO: it does not validate the non-LTO build time. The cache-hit claim is checked by the compile_commands.json comparison above; the build time will show in the first PRs after the merge.

Related: #130824
Related: #130819

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):

...

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.26-master (included in 26.12 and later)

…nce comparison

The AMD performance comparison runs in a PR only with `pr-performance`,
`ci-performance`, a "Performance Improvement" changelog category, or a full ARM
run. Over 2026-11-06 to 2026-11-13, 2569 of 2983 PR `amd_release` builds (86%)
had no AMD performance comparison, but still paid for ThinLTO: the median
`Build ClickHouse` step of `amd_release` is 20 minutes, of `amd_binary` 4.

Without ThinLTO, PGO and BOLT, the compile commands of `amd_release` equal those
of `amd_binary` (16224 of 16227 common translation units, checked by diffing
`compile_commands.json`), which master builds on every commit, so sccache serves
the compilation and the build is mostly the link. Its other consumers (packages,
`Install packages`, `Compatibility check`, integration tests, `ClickBench`,
`Upgrade check`) do not depend on how the binary is optimized. `arm_release`
keeps ThinLTO: the ARM performance comparison runs in nearly every PR.

The decision is made in a pre-hook (`configure_amd_release_thinlto`), because
`ci-force-all` bypasses the filter hooks and then runs every performance job.
Praktika gets a generic per-job digest salt from the workflow kv data
(`job_digest_salts`), so that the non-LTO build is cached separately and a later
run with the same digest that does run the AMD comparison (e.g. after adding
`pr-performance`) cannot reuse the non-LTO binary.

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

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [39860b3]

Summary: ✅


AI Review

Summary

The PR builds amd_release without ThinLTO, PGO and BOLT when AMD performance comparisons are skipped, with separate cache digests and artifact directories. Reviewed head 39860b3119b588dfe47b97df2958ab1204428b6c: both previous findings are fixed, and no new actionable findings remain. Consumers checked: Runner._pre_run handles direct files, wildcard packages and artifact reports; Docker reads the report URLs; local --pr/--sha runs restore persisted salts; release and performance baseline downloads use unchanged, unsalted builds. Focused local checks passed for 14 selection scenarios, dependent digest separation, four variant transitions, local entrypoint restores and cross-commit cache reuse for both variants.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 13, 2026
@clickhouse-gh
clickhouse-gh Bot requested review from leshikus and maxknv November 13, 2026 14:38
Comment thread ci/praktika/hook_cache.py Resolved
@alexey-milovidov
alexey-milovidov marked this pull request as ready for review November 13, 2026 15:02
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Nov 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 39860b311 with master 463f45f5f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline.

Job report

@PedroTadim

Copy link
Copy Markdown
Member

LGTM so far

alexey-milovidov and others added 2 commits November 15, 2026 07:44
The two variants of `Build (amd_release)` (with and without ThinLTO) had
different cache digests but uploaded to the same
`PRs/<pr>/<sha>/pr/build_amd_release` directory. A rerun at the same commit
with the other variant overwrote the artifacts, and the cache record of the
first variant then restored the binary of the second one, so an AMD
performance comparison could measure a non-LTO binary.

`Cache.artifact_dir` appends the salt of a salted job to its artifact
directory, and the runner uses it for both upload and download. A cache
record of a salted job has a salted digest, so a run reusing it has the same
salt and resolves the same directory.

Address review: #131328 (comment)

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

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131328&sha=b9911c0f6a8122acc72052a8bc1084928cb313bf&name_0=PR&name_1=Stress%20test%20%28amd_debug%29 (Logical error: Inconsistent KeyCondition behavior (STID: 5182-57a3)) and provide a fix in a separate PR. If the fix is already in progress, link it here. This PR changes only CI scripts; the same exception appeared in the last 30 days in unrelated PRs (#129663, #131505, #130261, #130124, #128521, #126290 and others), and there is no open issue for it.

Comment thread ci/praktika/cache.py Resolved
@groeneai

Copy link
Copy Markdown
Collaborator

The fix in progress is #124111 (mine, open, waiting for review).

The query in fatal.log is a fuzzed 03733_has_function_key_condition query, SELECT count() FROM test_has_idx_nullable WHERE key_nullable IN (NULL) SETTINGS transform_null_in = 1, on a Nullable(UInt32) key where every 10th row is NULL. For a 1-element set matchesExactContinuousRange claims an exact range, but with NULL as the element the matching granules (the NULL ones at the end of the part) are not reported as wholly matching, and the debug check catches that. #124111 stops matchesExactContinuousRange from claiming an exact range for a 1-element set holding NULL, and for a decreasing function of a Nullable key, which is the other shape among the carriers you listed.

Debug builds of master 6ea176f, without and with the #124111 diff (it applies cleanly):

Query master + #124111 use_primary_key = 0
this one abort 10000 10000
Nullable(String) key, k IN (SELECT DISTINCT multiIf(x IS DISTINCT FROM 1048577, NULL, ...) FROM set_numbers), transform_null_in = 1 abort 10000 10000
Nullable(Int128) key DESC, b = 1 AND intDiv(a, toInt8(-2)) < 100 abort 3 3
Nullable(Float32) key, intDiv(a, toInt8(2147483646)) < 0 (divisor -2) abort 3 3

Rows 2-4 are reduced versions of queries from the other carriers in your list.

My other open PR, #121089, which I linked earlier for the IN (NULL) shape, no longer prevents this abort on current master (6ea176f with its diff applied still aborts), so #124111 is the one to review.

alexey-milovidov and others added 2 commits November 18, 2026 17:20
…-thinlto

Conflicts in the workflow pre-hooks: keep both `configure_amd_release_thinlto` and the new `configure_toolchain_builds`.
A local job run with `--pr`/`--sha` creates fresh kv data, so
`Cache.artifact_dir` did not know that the producing run salted
`Build (amd_release)` and looked for its artifacts in `build_amd_release/`
instead of `build_amd_release_without_thinlto/`.

`CacheRunnerHooks.configure` now publishes the run's digest salts as
`job_digest_salts.json` under the run's S3 prefix (always, so that a rerun
at the same commit without salts replaces them), and
`Runner.generate_local_run_environment` restores them into the kv data.

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

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131328&sha=b459812fb7a10eb5fd8599ac1e79bc3bfa1d16cc&name_0=PR&name_1=Performance%20Comparison%20%28amd_release%2C%20master_head%2C%203%2F6%29 (also shard 6/6: Performance Comparison (amd_release, master_head, N/6) hits the 7200 s job timeout while still running perf.py, job labeled disk-almost-full) and provide a fix in a separate PR. If the fix is already in progress, link it here. This PR builds the compared binaries as before (its own run keeps ThinLTO); the same timeout happened 57 times in 18 other PRs during 2026-11-11 to 2026-11-18 (e.g. #128394, #123890, #131683), and I found no open issue for it.

@groeneai

Copy link
Copy Markdown
Collaborator

I checked these. The 57 amd_release master_head PR shards killed at 7200 s on 2026-11-11..11-18 (CI DB) have two causes:

  1. 41 on 2026-11-15, including both shards here. The NightlyCoverage run of 2026-11-15 at 79929b2c collected no coverage, so the selection treated every non-long test as uncovered and ran all of them with all queries (Test Files (142), --max-queries 0 on every test). Both shards here were still in Tests after 101 min. Fixed by my Do not select performance tests from a coverage collection that covered no test #131772, merged 2026-11-15 11:58Z; the kills after that are reruns of heads tested before the merge. There were 0 on 2026-11-16 and 11-17.
  2. 16 on two PRs with wide diffs: 15 on 2026-11-12..11-14 (example) and 1 today (report). Here the coverage selection is legitimately large, 65 to 107 tests per shard, and every selected test runs all its queries (max_queries=0 for all_query_tests in ci/jobs/performance_tests.py), so Tests alone takes 80 to 100 min. Neither the selection nor the test loop is bounded by the job time. This one is not fixed yet: I'm working on a fix in a separate PR and will post the link here.

The disk-almost-full label only means the peak disk usage was at least 85% (ci/praktika/host_metrics.py). The logs have no disk errors; the jobs ended on the 7200 s timer.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix for the second group is #132767: the selected tests are now split over the shards by their measured runtimes instead of round robin by name. Replayed on today's killed run (report), the heaviest shard goes from 92 to 68 min of tests.

One correction to my comment above: the 15 kills on 2026-11-12..11-14 were caused by that PR's own binary. On the same tests it took about 1.8 times the master time in total (CI DB per-test runtimes), and its ARM shards in full mode were killed too, so #132767 does not change those.

@PedroTadim PedroTadim self-assigned this Nov 19, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (pulls in #131772). The remaining red check, Stress test (arm_release) (Logical error: 'Unexpected return type from accurateCastOrNull. Expected Nullable(Tuple(Array(Decimal(9, 2)))). Got Nullable(Tuple(Array(Nullable(Decimal32))))', report), is unrelated to this CI-only change: it is tracked by #132281 and fixed by the open #132543. @groeneai, thanks for the performance-timeout analysis and #132767.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 20, 2026
Merged via the queue into master with commit 079335d Nov 20, 2026
196 checks passed
@alexey-milovidov
alexey-milovidov deleted the amd-release-without-thinlto branch November 20, 2026 09:40
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 20, 2026
@stresshouse

stresshouse Bot commented Nov 20, 2026

Copy link
Copy Markdown

📊 Cloud Performance Report

⚠️ AI verdict: not_sure — inconclusive across 28 queries analysed

PR verdict: not_sure. 1 measured difference(s) not attributable to this PR. clickbench Q10: The measured difference cannot be attributed to this PR from the available source evidence. The tested merge 78285a20 differs from its master parent 8486bd17 only in CI Python files: ci/jobs/build_clickhouse.py, ci/jobs/scripts/workflow_hooks/filter_job.py, ci/praktika/cache.py, ci/praktika/hook_cache.py, ci/praktika/runner.py and ci/workflows/pull_request.py. No server source changed, so Q10's GROUP BY MobilePhoneModel with COUNT(DISTINCT UserID) runs the same code as on master. The only change that could affect the binary is configure_amd_release_thinlto, which drops ThinLTO/PGO/BOLT from …

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 10 not_sure 92 114 +23.2% <0.0001 aggregation: The measured difference cannot be attributed to this PR from the available source evidence. The tested merge 78285a20 differs from its master parent 8486bd17 only in CI Python files: ci/jobs/build_clickhouse.py, ci/jobs/scripts/workflow_hooks/filter_job.py, ci/praktika/cache.py, ci/praktika/hook_cache.py, ci/praktika/runner.py and ci/workflows/pull_request.py. No server source changed, so Q10's GROUP BY MobilePhoneModel with COUNT(DISTINCT UserID) runs the same code as on master. The only change that could affect the binary is configure_amd_release_thinlto, which drops ThinLTO/PGO/BOLT from …

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
  • StressHouse run: bcf83a90-d9d6-445f-9dd7-582b7152e732
  • MIRAI run: 631d2410-1f77-4d6b-9a42-6078181d431f
  • PR check IDs:
    • clickbench_450087_1795171611
    • clickbench_450093_1795171611
    • tpch_adapted_1_official_450100_1795171611
    • tpch_adapted_1_official_450115_1795171611

alexey-milovidov added a commit that referenced this pull request Nov 22, 2026
… without ThinLTO

Since #131328 was merged, the artifacts of
a salted job are stored in a directory of their own (`Cache.artifact_dir`), so a build
without ThinLTO no longer overwrites the ThinLTO build of the same commit. The salt
unique to the run attempt that `record_thinlto_choice` gave to the ThinLTO variant was
there only because of that overwrite. After the last merge of master it also moved the
ThinLTO `amd_release` binary to `build_amd_release_with_thinlto_run_<id>_<attempt>/`,
where `double_check_perf.py` and the `perf-comparison` recipes do not look.

So `record_thinlto_choice` is removed, and `configure_amd_release_thinlto` is the one
of master again, with one difference: it records the build type in the list
`builds_without_thinlto` instead of the flag `amd_release_without_thinlto`, so that the
PR workflow of the private repository can list its own builds there. The ThinLTO
variant is not salted, it is cached as before and stays in `build_amd_release/`.

The optimization mode check in `double_check_perf.py` is removed as well: the directory
that it downloads from never holds a build without ThinLTO. The `LINK_FLAGS` check in
`performance_tests.py` stays, for local runs: they download the variant that the run at
that commit built.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). 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.

4 participants