Skip to content

Add "Build profile diff" check: compare PR build profile against master - #111164

Merged
alexey-milovidov merged 30 commits into
masterfrom
build-profile-diff
Aug 2, 2026
Merged

alexey-milovidov merged 30 commits into
masterfrom
build-profile-diff

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

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 to CHANGELOG.md):

A new Build profile diff check runs in every PR after the Build (arm_release) job. It compares the PR's build profile against master using the CI logs database (build_time_trace, binary_sizes, binary_symbols) and posts (and keeps updated) a PR comment when there is a significant change.

PR release builds and official master builds are compiled with different flags (PR ThinLTO builds strip debug symbols via -DDISABLE_ALL_DEBUG_SYMBOLS=1 and skip the official-build flag), so the check uses two master baselines:

  • the master sccache-warmup build (Build (arm_release_pr_cache_warmup)), which compiles master with the PR's exact flags: baseline for per-object .o sizes and per-TU compile time of the translation units the PR recompiled, with per-entity drill-down (template instantiations, header parsing), normalized by the median PR/master ratio so machine-speed differences between runners do not produce false findings. The warmup job now runs the build profile hook to produce this data;
  • the official master build (Build (arm_release)): baseline for the artifacts that do not depend on debug info: the stripped binary size, per-symbol sizes of the final binaries, and per-function ThinLTO optimization time (also median-ratio normalized). Unstripped binary sizes and link wall time are not compared at all - they differ by construction.

The reason PR builds had no data in these tables was an explicit pr_number == 0 gate in build_profile_hook.py - this PR removes it for arm_release. PR time traces are uploaded reduced (only the event kinds the diff consumes), because the bulk of a full trace is per-pass LLVM events of the ThinLTO link, and PR builds are far more frequent than master pushes. Additionally, prepare-time-trace.sh now collects symbols of the final linked binaries with nm: (Thin)LTO builds skip nm on .o files, so binary_symbols previously had no rows at all for amd_release/arm_release. The symbol-size and warmup-baselined sections activate once master accumulates baseline data.

The producer hook is fail-close: a profile artifact a release build is required to produce raises when missing or empty instead of being skipped, so a regressed producer cannot turn into a false-green "no data" comparison. Each comparison aspect is reported as a separate sub-result, so the aspects land as individual rows in cidb and in the CI report.

Validated locally against real data from the CI logs cluster, and with fixture-backed tests (ci/tests/test_build_profile_diff_job.py, ci/tests/test_build_profile_hook.py) that drive the real query builders against clickhouse local.

The new job is allow_failure while it stabilizes.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Version info

  • Merged into: 26.8.1.644 (included in 26.8 and later)

A new PR-workflow job compares the aarch64 release build of the PR
against the latest master build using the CI logs cluster, and posts
(and keeps updated) a PR comment when there is a significant change:

  * sizes of the final binaries (clickhouse, stripped, self-extracting,
    keeper) and of every intermediate .o file;
  * per-symbol sizes of the final binaries;
  * link time and per-function ThinLTO optimization time
    (down to individual functions and template instantiations);
  * per-TU compile time of the translation units the PR recompiled,
    with per-entity drill-down (template instantiations, headers),
    normalized by the median ratio to filter out machine-speed skew.

Supporting changes:

  * build_profile_hook.py no longer skips PRs: the arm_release build
    uploads profile data for PRs too (the reason PR data was absent was
    an explicit pr_number == 0 gate). PR time traces are uploaded
    reduced - only the event kinds the diff consumes - because the bulk
    of a full trace is per-pass LLVM events of the ThinLTO link that
    nobody reads, and PR builds are far more frequent than master ones.
  * prepare-time-trace.sh also collects symbols of the final linked
    binaries with nm: (Thin)LTO release builds skip nm on .o files, so
    binary_symbols had no rows at all for amd_release/arm_release.
  * LogCluster gains a select method (query in the request body, with
    retries tolerating the cluster's minutes-long memory-pressure
    spikes) and explicit url/user/password overrides for local runs.

Validated locally against real data: an adjacent-master pair shows the
noise floor (binary sizes within ~100 bytes, link time within a few
percent, verdict "no significant changes"), and the type-pair kernel
pruning commit (4ed98f9) is correctly flagged: -54.84 MiB stripped
binary, the pruned HashJoin instantiation .o files at -48%, link time
-24%/-34%.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [05d316e]

Summary: ✅


AI Review

Summary

This PR adds a new Build profile diff CI job, routes its read queries through a read-only CI logs endpoint, hardens the profile producer to fail close when required telemetry is missing, and adds fixture-backed coverage for the comparison logic and workflow gating. I did not find any new blocker or major issue on the current PR head; the remaining risk is mostly operational rather than logical, because the check still depends on the CI logs cluster and GitHub history queries, but the current code now treats those failures as loud, comment-refreshing failures instead of silent green comparisons.

Missing context / blind spots
  • ⚠️ I did not re-run ci/tests/test_build_profile_diff_job.py or ci/tests/test_build_profile_hook.py locally during this review; confidence comes from code inspection plus the fixture coverage added in the PR.
Final Verdict

✅ No new blocker or major findings on the current PR head.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 21, 2026
Comment thread ci/jobs/build_profile_diff_job.py Resolved
Comment thread ci/defs/job_configs.py Resolved
Comment thread ci/jobs/build_profile_diff_job.py Resolved
…I logs cluster credentials from AWS SSM and test-base has no `aws` CLI

The job failed with `/bin/bash: line 1: aws: command not found` because
`Secret.get_aws_ssm_parameter` shells out to the AWS CLI, which the
`clickhouse/test-base` image does not ship. `clickhouse/stateless-test`
extends test-base and installs the AWS CLI; stateless test jobs already
fetch these same secrets inside that image, so in-container IMDS access
is proven to work.

Also address the review findings:
- scope each comparison side to the newest uploaded build run: a rerun of
  `Build (arm_release)` re-inserts the whole dataset under the same
  pull_request_number/commit_sha/check_name, and mixing runs corrupts the
  aggregations (sums double, max picks the slowest rerun);
- cover `clickhouse-keeper` in the per-symbol diff (keyed by file, symbol),
  comparing each binary only when both sides have its symbol data;
- add `utils/prepare-time-trace/prepare-time-trace.sh` and
  `ci/jobs/scripts/log_cluster.py` to the build digest so the producing
  build reruns when the profile producer/upload path changes.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111164&sha=4e62df6112628621fc1d6535da72526f7b352409&name_0=PR
PR: #111164

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The 04507_mvt_encode_state_serialize failure on the ParallelReplicas shard is unrelated to this PR (a parallel-replicas bug, see #74366); a fix is already open in #111148.

The Build profile diff job failure (aws: command not found) is fixed by running the job in the clickhouse/stateless-test image, which ships the AWS CLI. The same push addresses the review findings: each comparison side is now scoped to the newest uploaded build run, the per-symbol diff covers clickhouse-keeper too, and the build digest includes prepare-time-trace.sh and log_cluster.py so the producing build reruns when the upload path changes.

Comment thread ci/defs/job_configs.py Resolved
Address the AI review findings on the `Build profile diff` check.

Major 1 (cross-run mixing): the newest `(check_start_time, instance_id)` was
resolved independently per table via a per-table `latest_run` subquery. Because
the producer uploads `binary_sizes`, `build_time_trace`, and `binary_symbols`
independently and skips genuinely-empty artifacts, a rerun that uploaded only
some tables let the size/link sections read the newest run while
`compare_symbols` silently fell back to an older run. Each side is now pinned to
one concrete build run once (`resolve_run`, from the canonical `binary_sizes`
table) and that `(check_start_time, instance_id)` is reused across every table
(new `Side` dataclass). A table missing for that run reads as absent instead of
falling back to a different run.

Major 2 (false-green on consumer-only change): `Build (arm_release)` is
cacheable under a digest that does not include `build_profile_diff_job.py`, so a
change to the consumer alone could get a cache hit, upload no rows for the new
commit, and return a green "no data" result without exercising the changed SQL.
Added `ci/tests/test_build_profile_diff_job.py`: fixture-backed tests that run
the real query builders against `clickhouse local`, seeding two PR reruns with
the newest run missing the symbol table plus a no-PR-data (cache-hit) case. They
assert the pinned run is the newest, that sizes come from it, and that symbols
are not read from an older run. The `CI Tests` job digest is `./ci`, so a
consumer-only change re-runs these tests and can no longer merge on a false green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed both AI-review Majors in ebc594f:

Cross-run mixing: each side is now pinned to a single build run once — resolve_run reads the newest (check_start_time, instance_id) from the canonical binary_sizes table, and the new Side dataclass carries that pair into side_conditions so it is reused across every table (binary_sizes, build_time_trace, binary_symbols). The per-table latest_run subquery is gone. A table missing for the pinned run now reads as absent instead of silently falling back to an older rerun.

False-green on consumer-only change: added ci/tests/test_build_profile_diff_job.py — fixture-backed tests that drive the real query builders against clickhouse local, seeding two PR reruns with the newest run missing the symbol table, plus a no-PR-data (cache-hit) case. They assert the pinned run is the newest, sizes come from it, and symbols are not read from an older run. The CI Tests job digest is ./ci, so a consumer-only change re-runs these tests and can no longer merge on a false green.

Comment thread ci/jobs/build_profile_diff_job.py Resolved
Comment thread ci/jobs/build_profile_diff_job.py Resolved

@maxknv maxknv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but I think this implementation has many reasons to be unreliable.

I think relying on LogCluster is good for post-analysis, but not as a check in CI.

I'd suggest using profile data directly and bypassing LogCluster entirely for comparison.
New Artifact object can be created with this profile data. It's provided by the build job and required by the new comparison. The reference data from the master can be retrieved from s3 in the job.

It would be stable from day one, easier to run locally and maintain, and much more reliable, require no AWS secrets and CI infra.

Comment thread ci/jobs/build_profile_diff_job.py Outdated

summaries = [s.summary or s.title for s in significant]
result_info = "Significant changes: " + "; ".join(summaries) if significant else f"No significant changes vs master {base_sha[:9]}"
Result.create_from(status=Result.Status.OK, info=result_info).complete_job()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: if we write each sub-check (compile time, link time, size, etc) as a separate Result object in the job's Result.results array, it might be beneficial as they are all written into the cidb. Also, it should look clearer in the CI report.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - each comparison aspect is its own Result in the job's Result.results (see the sub_results list at the end of main()), so they land as separate rows in cidb and as separate lines in the CI report: Binary sizes, Object file sizes, Slowest function optimization changes (ThinLTO), Compile time of recompiled translation units, Symbol sizes.

Comment thread ci/jobs/build_profile_diff_job.py Outdated
"""
shas = []
seen = set()
for sha in list(info.get_kv_data("master_commits") or []):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The correct "kv data" to use is master_track_commits_sha (not master_commits). It includes 100 master commits, topped by the commit included in ephemeral GH's merge-commit, where CI runs.
  2. Why do we need to fill it up to 600 commits from gh api, then, if we still only check the first 100 later, and then pick up only one from them? or i misunderstood smth..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_master_shas still falls back to master_commits in ci/jobs/build_profile_diff_job.py:341-343. That means a missing master_track_commits_sha no longer fails closed: find_baseline / find_warmup_baseline will walk the global master tip instead of the PR's master-parent chain.

store_data.py already has a warning path at ci/jobs/scripts/workflow_hooks/store_data.py:77-99 when HEAD^1 / git rev-list cannot produce that anchored chain, so this is not just a theoretical path. In that case the job can compare the PR against a commit newer than its merge base and attribute unrelated master changes to the PR. This still needs to raise in CI rather than silently downgrade to master_commits; only the explicit --local --base-sha path has a safe fallback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

master_track_commits_sha is now the only CI baseline chain; the old fallback to master_commits is gone.

gh api still has one job: master_track_commits_sha holds only the newest ~100 anchored master SHAs, which is enough for the 7-day release baseline but not for the 14-day per-TU warmup lookup. extend_master_shas pages older ancestors from GitHub only for that longer TU window (and --local --base-sha uses the same API because it has no CI kv metadata at all).

Comment thread ci/jobs/build_profile_diff_job.py Outdated
try:
raw = subprocess.run(
[
"gh",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purpose of gh api is not clear...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered in the thread above: master_track_commits_sha is now the only baseline chain in CI. gh api has one remaining job - that kv value holds only the newest ~100 anchored master SHAs, which covers the 7-day release baseline but not the 14-day per-TU warmup lookup, so extend_master_shas pages older ancestors from GitHub for that longer window only. A local run (--local --base-sha) uses the same API because it has no CI kv metadata at all.

alexey-milovidov and others added 2 commits July 22, 2026 00:06
…n pinning, new-TU significance

Addresses the unresolved review findings on #111164:

- `maxknv`: `get_master_shas` now reads `master_track_commits_sha` (the PR's
  master-parent chain, anchored to the merge base) instead of `master_commits`
  (the global tip), and drops the `gh api` fill-to-600 loop — `find_baseline`
  only ever considers the first 100 candidates and the `store_data` hook already
  stores ~100, so paging more was dead weight.

- `clickhouse-gh`: `drill_down_tu` no longer re-resolves the baseline run from
  the commit sha alone. `compare_compile_times` now carries the exact winning
  `(check_start_time, instance_id)` out of `base_rows` and hands the pinned
  `Side` to the drill-down, so it reads the TU's entities from the run that
  actually recompiled it. A later rerun of the same master commit that did not
  touch this TU no longer pins the drill-down to a run with no rows for the
  file (which reported every PR entity as `new`).

- `clickhouse-gh`: an expensive translation unit without a recent master
  baseline now marks its section significant and populates the summary — a
  missing baseline must not silence a large new compile-time cost in the
  top-level verdict.

Extends `ci/tests/test_build_profile_diff_job.py` with fixture-backed tests for
each of the three behaviors.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed the outstanding review findings in a6fe00cb6b9 (pushed on top of a fresh merge of master):

  • master_track_commits_sha (thanks @maxknv): get_master_shas now reads master_track_commits_sha — the PR's master-parent chain, anchored to the merge base — instead of the global-tip master_commits, and the gh api fill-to-600 loop is gone. find_baseline only ever looks at the first 100 candidates and the store_data hook already stores ~100, so paging more was dead weight.
  • Drill-down run pinning (clickhouse-gh): compare_compile_times now carries the winning (check_start_time, instance_id) out of base_rows and hands the pinned Side to drill_down_tu, so the per-TU breakdown reads entities from the exact run that recompiled the TU. A later rerun of the same master commit that did not touch the TU no longer pins the drill-down to a run with no rows for it (which had reported every PR entity as new).
  • New-TU significance (clickhouse-gh): an expensive translation unit without a recent master baseline now marks its section significant and populates the summary — a missing baseline must not silence a large new compile-time cost in the top-level verdict.

Added fixture-backed tests for all three in ci/tests/test_build_profile_diff_job.py (21 pass locally via clickhouse local); ruff clean.

Still open for your call, @maxknv: the higher-level design question of whether to bypass the CI logs cluster entirely and compare against a build-provided profile artifact + S3 reference. That's a larger direction change I've left for you to decide rather than reworking unilaterally.

Comment thread ci/jobs/build_profile_diff_job.py Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@maxknv, about that comment, it is an ideological direction.

I want to use ClickHouse more and files less.
The CI Logs cluster can be overloaded sometimes, but it is a good problem to solve.

TLDR: files are bad, ClickHouse is good.

@clickhouse-gh

clickhouse-gh Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

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

⚠️ Significant changes: slowest function optimization changes (thinlto).

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 684.45 MiB 681.47 MiB -2.99 MiB (-0.44%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes

No master baseline from the warmup build yet (it is the only master build compiled with the PR's flags, profiled since this check was introduced); the comparison will activate once master catches up.

Slowest function optimization changes (ThinLTO) ⚠️

Median per-function time ratio to the master baseline is ×1.15 (different machine and build flags); deltas below are relative to that ratio.

Binary Function Master PR Δ vs median
programs/clickhouse-keeper DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.14238646256509887658] new 16.2 s +16.2 s
programs/clickhouse DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.15310835701980635540] 8.6 s gone -9.9 s (-100%)
programs/clickhouse-keeper DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.15310835701980635540] 8.4 s gone -9.6 s (-100%)
programs/clickhouse DB::SettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.14238646256509887658] new 6.3 s +6.3 s
programs/clickhouse-keeper DB::registerFunctionConversion(DB::FunctionFactory&) 6.7 s 13.9 s +6.2 s (+81%)
programs/clickhouse-keeper _GLOBAL__sub_I_TargetLibraryInfo.cpp 5.8 s 11.2 s +4.6 s (+69%)
programs/clickhouse DB::getSettingsChangesHistory()::$_0::operator()() const 4.7 s 2.4 s -2.9 s (-54%)
programs/clickhouse DB::Parquet::writeColumnChunkBody(DB::Parquet::ColumnChunkWriteState&, DB::Parquet::WriteOptions co… 5.4 s 3.4 s -2.8 s (-46%)
programs/clickhouse-keeper DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.41530897155626… new 2.6 s +2.6 s
programs/clickhouse-keeper DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12816159879… new 2.4 s +2.4 s
programs/clickhouse DB::Aggregator::writeToTemporaryFile(DB::AggregatedDataVariants&, unsigned long) const 3.6 s 1.7 s -2.4 s (-58%)
programs/clickhouse DB::attachSystemTablesServer(std::__1::shared_ptr<DB::Context const>, DB::IDatabase&, bool, bool) 4.5 s 2.9 s -2.3 s (-44%)
programs/clickhouse DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12822858084705… 1.9 s gone -2.2 s (-100%)
programs/clickhouse DB::MergeTreeSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.10544783980… 1.8 s gone -2.1 s (-100%)
programs/clickhouse-keeper DB::ServerSettingsTraits::Accessor::instance()::$_0::operator()() const [clone .llvm.12822858084705… 1.8 s gone -2.1 s (-100%)
programs/clickhouse-keeper _GLOBAL__sub_I_sqid.cpp 1.7 s 4.0 s +2.0 s (+105%)
programs/clickhouse-keeper DB::registerFunctionVectorFunctions(DB::FunctionFactory&) 2.3 s 4.6 s +2.0 s (+78%)
Compile time of recompiled translation units

No master baseline from the warmup build yet (it is the only master build compiled with the PR's flags, profiled since this check was introduced); the comparison will activate once master catches up.

Symbol sizes

No symbol data for the master baseline yet (it is collected for release builds only since this check was introduced); the comparison will activate once master catches up.

Job report

@maxknv

maxknv commented Jul 22, 2026

Copy link
Copy Markdown
Member

@maxknv, about that comment, it is an ideological direction.

I want to use ClickHouse more and files less. The CI Logs cluster can be overloaded sometimes, but it is a good problem to solve.

TLDR: files are bad, ClickHouse is good.

I understand the direction, and it's great to move this way.
The Logs cluster just doesn't seem like something we can use in its current form as a core CI service for quality gating.
It's not only about overloading, but also about how we configure and use it in CI. It's an experimental sandbox, and the CI integration is very implicit.
In contrast, the CIDB cluster is much more native to CI. The public endpoint makes it more accessible, and it works much more reliably.

…a comment

The check's first real run exposed that a PR build and an official master
build are not directly comparable: PR ThinLTO builds compile with
-DDISABLE_ALL_DEBUG_SYMBOLS=1 (and without the official-build flag) while
master keeps debug symbols, so on a no-op PR the comment reported an apparent
-73% binary size, -78% object sizes and -39% link time. Fixes:

- Object file sizes and per-TU compile times are now baselined on the master
  sccache-warmup build (Build (arm_release_pr_cache_warmup)), which compiles
  master with the PR's exact cmake flags. The build profile hook now runs on
  the warmup job and uploads its object sizes and reduced compile trace; the
  sections degrade to a catch-up note until master accumulates warmup data.
- Binary size comparison is restricted to clickhouse-stripped (the only
  binary whose size does not depend on debug info), with a threshold that
  absorbs the residual official-flag/PGO/BOLT difference.
- The link time section is dropped: master links with debug symbols and PRs
  do not, so the wall times are incomparable by construction.
- Per-function ThinLTO times are normalized by the median PR/master ratio,
  the same way the per-TU section absorbs machine-speed skew.

Also addressed both AI-review Majors:

- The producer hook is now fail-close: an artifact a profiled release build
  is required to produce (all three for amd_release/arm_release, object
  sizes for the warmup build) raises when missing or empty instead of being
  silently skipped, so a regressed prepare-time-trace.sh or missing nm can
  no longer turn into a false-green "no data" comparison.
- The "no PR data" early return now updates the tagged PR comment instead of
  leaving a comparison for an older commit in place.

Per review, each comparison aspect is reported as a separate sub-result so
the aspects land as individual rows in cidb and in the CI report.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Pushed 8576ccf, addressing the review findings and a comparability bug the check's own first report exposed.

Why the first report showed −73% binary size on a CI-only PR: PR ThinLTO builds compile with -DDISABLE_ALL_DEBUG_SYMBOLS=1 and without the official-build flag (build_clickhouse.py), while official master builds keep debug symbols. So unstripped binaries, .o files and link time were incomparable by construction. Fixed by splitting the baseline:

  • Object sizes and per-TU compile times are now baselined on the master sccache-warmup build (Build (arm_release_pr_cache_warmup)), which compiles master with the PR's exact flags. The build profile hook now runs on that job (object sizes + reduced compile trace); the sections show a catch-up note until master accumulates warmup data.
  • Stripped binary size, per-symbol sizes, per-function ThinLTO times stay baselined on the official master build - they do not depend on debug info. ThinLTO per-function times are median-ratio normalized like the per-TU section; the stripped-binary threshold absorbs the residual official-flag/PGO difference.
  • Link time is not compared at all (debug-info link vs stripped link), and the unstripped/self-extracting binaries are excluded.

Both AI-review Majors:

  • The producer hook is now fail-close: an artifact a profiled release build must produce (profile.json, binary_sizes.txt, binary_symbols.txt for amd_release/arm_release; object sizes for the warmup build) raises when missing or empty instead of logging skipping upload, so a regressed prepare-time-trace.sh or missing nm fails Build (arm_release) loudly instead of turning into a false-green "no data" diff.
  • The "no PR data" early return now updates the tagged PR comment (No ... build profile data for commit <sha>) instead of leaving the comparison for an older commit in place.

@maxknv's nitpick: each comparison aspect is now emitted as its own sub-result in the job's Result.results, so the aspects land as separate cidb rows and separate lines in the CI report.

Fixture tests updated (24 pass via clickhouse local), ruff clean, praktika YAML regeneration produced no diff.

The current CI reds are known flakies unrelated to this CI-only PR: 01730_distributed_group_by_no_merge_order_by_long (#111067), test_check_table and test_replicated_table_structure_alter (#110036) - all have tracking issues linked in the CI report.

Comment thread ci/jobs/build_profile_diff_job.py Resolved
… of both final binaries

Address the two AI-review Majors on the previous revision:

- The warmup build's time trace cannot be unconditionally required: when
  every TU is an sccache hit it is legitimately empty, which made a broken
  trace extractor indistinguishable from the all-cache-hit case ('binary_sizes.txt'
  alone kept 'find_warmup_baseline' succeeding while the per-TU compile-time
  section quietly lost its baseline). '_verify_trace_extraction' now uses the
  ground truth: the compiler leaves one raw '-ftime-trace' file per TU it
  actually ran on, so raw traces present + nothing extracted fails the hook
  loudly.

- 'compare_opt_functions' no longer hard-wires 'programs/clickhouse': it now
  diffs 'OptFunction' time keyed by (binary, function) over 'FINAL_BINARIES'
  ('clickhouse' and 'clickhouse-keeper'), with the same per-binary gating as
  the symbol section - a binary is compared only when both sides have its
  link trace, and a PR-side binary without a master baseline is called out
  instead of silently dropped. 'SYMBOL_BINARIES' is renamed 'FINAL_BINARIES'
  since it now feeds both sections.

The new keeper fixture also exposed a latent type error in the report
predicate: 'greatest(pr_dur, base_dur * skew)' mixes 'UInt64' and 'Float64',
which ClickHouse rejects with 'ILLEGAL_TYPE_OF_ARGUMENT'; 'pr_dur' is now cast
explicitly.

Tests: 5 new (3 hook, 2 fixture-backed via clickhouse local), 29 pass total.

#111164
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed both AI-review Majors in 0198243:

Warmup trace fail-open: the warmup build's time trace cannot be unconditionally required — when every TU is an sccache hit it is legitimately empty — so the hook now disambiguates with the ground truth: the compiler leaves one raw -ftime-trace file per TU it actually ran on. _verify_trace_extraction fails the build loudly when raw traces exist in the build directory but nothing was extracted into profile.json, so a regressed extractor can no longer silently starve the per-TU compile-time baseline while binary_sizes.txt keeps find_warmup_baseline green.

ThinLTO section keeper blind spot: compare_opt_functions now diffs OptFunction time keyed by (binary, function) over both final binaries (clickhouse, clickhouse-keeper), with the same per-binary gating as the symbol section: a binary is compared only when both sides have its link trace, and a PR-side binary without a master baseline is called out in the section body instead of silently dropped. The report table gained a Binary column.

The new keeper fixture also exposed a latent type error in the report predicate — greatest(pr_dur, base_dur * skew) mixes UInt64 and Float64, which the server rejects with ILLEGAL_TYPE_OF_ARGUMENT; pr_dur is now cast explicitly. Five new tests (three for the hook, two fixture-backed via clickhouse local); 29 pass, ruff clean.

The two integration-test failures on the previous commit are unrelated flaky tests with tracked issues: test_check_table (#111289) and test_replicated_table_structure_alter (#110036).

Comment thread ci/jobs/build_profile_diff_job.py Resolved
…indow

The per-TU compile-time comparison searches warmup traces over
TU_BASE_DAYS = 14, but the section was gated on the warmup object-size
baseline resolved with BASE_DAYS = 7. A warmup trace 8-14 days old
therefore degraded the whole section to the catch-up note even though
compare_compile_times would find real baselines. Now the section checks
warmup trace availability itself, in its own window, and only degrades
when no warmup ExecuteCompiler rows exist there at all; the BASE_DAYS
warmup baseline keeps gating only the object-size section it belongs to.

Adds the regression test the review asked for: a master commit whose
only warmup data is 10 days old yields a real comparison, not the note.

#111164
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed the remaining AI-review Major in f74e620: compare_compile_times no longer inherits the 7-day (BASE_DAYS) warmup gate from the object-size baseline. It now resolves warmup trace availability itself, over its own TU_BASE_DAYS = 14 window, and degrades to the catch-up note only when no warmup ExecuteCompiler rows exist there at all — so an 8–14-day-old warmup trace produces a real per-TU comparison instead of a false catch-up note. The BASE_DAYS warmup baseline keeps gating only the object-size section it belongs to.

Added the requested regression test (test_compile_times_use_warmup_traces_older_than_the_object_baseline): a master commit whose only warmup data is 10 days old has no object baseline (find_warmup_baseline returns None), yet the compile-time section compares tu.cpp against it. All 30 fixture tests pass via clickhouse local, ruff check clean.

@alexey-milovidov

alexey-milovidov commented Jul 29, 2026 •

Copy link
Copy Markdown
Member Author

Addressed the two Majors from the latest AI review in 00c5a98, and merged master.

  • Section-level skew was one-sided (build_profile_diff_job.py:944): per-TU deltas are measured against the median PR/baseline ratio, so a uniform shift moves that median and zeroes every delta — the case TU_SKEW_SIG_RATIO exists to catch — but it only fired for skew >= TU_SKEW_SIG_RATIO. Twelve translation units going 65 s → 30 s gave all-0.46 ratios, no per-TU finding and a green "No significant changes" while total compile time dropped by 420 s. The bar is now symmetric (max(skew, 1 / skew) and abs of the aggregate delta) and the summary names the direction.
  • Stale comment on the fail-close paths (build_profile_diff_job.py:1206): the comparison is factored into run_comparison and wrapped in a try that replaces the tagged comment with a current-sha "comparison failed" body before surfacing the exception, so a failure in get_master_shas, find_baseline, resolve_run, extend_master_shas or any cluster read no longer leaves the previous head's comparison pinned to the pull request. only_update, like the no-data path: a pull request that never got a comparison does not need a comment to say the job failed.

Two tests, both verified to fail before the fix: test_uniform_compile_time_speedup_is_significant (new fixture run prsha-uniform-speedup, twelve translation units baselined at 65 s and recompiled at 30 s) and test_a_failed_comparison_replaces_the_stale_comment. 60 tests pass, ruff check clean.

CI reds on 9e3ec08 were both unrelated to this CI-only change:

Still open for a human decision (unchanged): @maxknv's point about bypassing the Logs cluster in favour of a build-provided profile artifact + S3 reference.

Comment thread ci/jobs/build_profile_diff_job.py Resolved
… the baseline

The AI review found that `extend_master_shas` and `seed_master_shas` took
`repos/.../commits?sha=...` verbatim as the master chain, but that listing
interleaves merged PRs' second-parent commits: they pollute the baseline
candidate set, burn the page budget, and their ancient commit dates can fire
the TU_BASE_DAYS cutoff long before the first-parent history reaches it,
silently truncating the baseline window into a false-green compile-time
comparison.

New `_walk_first_parent` reconstructs the chain by following `parents[0]`
(the listing now carries parent shas), re-anchoring every fetch at the first
first-parent sha not fetched yet so each fetch is guaranteed to advance the
walk. The cutoff now fires on the chain's own tail; a listing that does not
start with its own anchor fails close. `seed_master_shas` uses the same walk,
capped at the ~100-commit kv-chain shape. `EXTEND_MAX_PAGES` raised to 60
since a mixed 100-commit page advances the chain by only ~25-50 commits.

Both rewritten tests model the real API (ancient-dated merged-PR commits in
every listing) and fail on the previous implementation.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111164&sha=1ddf512de11b00b3261684cb133ea3ab93ed2763&name_0=PR
#111164

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Addressed the AI-review Major in 1787559: the master-history extension now walks the true first-parent chain.

Why the raw listing was wrong: repos/.../commits?sha=... interleaves merged PRs' second-parent commits with the master merge commits. Taking it verbatim had two failure modes: the PR commits polluted the baseline candidate set and burned the page budget, and their commit dates — set when the PR branch was authored, arbitrarily far in the past — could fire the TU_BASE_DAYS cutoff long before the first-parent history reached it, silently truncating the baseline window (valid warmup baselines vanish, TUs get misreported as new, or the section degrades to the catch-up note).

The fix: new _walk_first_parent reconstructs the chain by following parents[0] — the listing now carries each commit's parent shas — and re-anchors every fetch at the first first-parent sha not fetched yet, so each fetch is guaranteed to advance the walk. The cutoff fires on the chain's own tail; a listing that does not start with its own anchor fails close. seed_master_shas (the --local --base-sha mode) uses the same walk, capped at the ~100-commit shape of the master_track_commits_sha kv chain. EXTEND_MAX_PAGES went 20 → 60, since a mixed 100-commit page advances the chain by only ~25–50 first-parent commits. Both rewritten tests model the real API (ancient-dated merged-PR commits in every fixture listing) and fail on the previous implementation. 60 tests pass, ruff check clean.

The two CI reds on 1ddf512 are unrelated to this CI-only PR:

  • 01666_merge_tree_max_query_limit on the coverage ParallelReplicas shard — known flaky test, tracked in Flaky test: 01666_merge_tree_max_query_limit #112426.
  • Stress test (arm_asan_ubsan): segmentation fault in avro::StreamWriter::flush → avro::DataFileWriterBase::close under DB::StorageFileSink::finalizeBuffers (STID 1288-3e19). This PR touches only ci/, utils/prepare-time-trace/ and workflow files, so it cannot cause a server segfault; CIDB shows no other occurrence of this signature in 21 days and I found no tracking issue.

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111164&sha=1ddf512de11b00b3261684cb133ea3ab93ed2763&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%29 (the Avro segfault above) and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. Confirming your unrelatedness call: this is a pre-existing trunk bug in the Avro output format, reachable from a plain INSERT, and nothing in your ci/ diff participates. Root cause below; I will send the fix as a separate PR and link it here.

The aborting query, from the Received signal line in fatal.log (not the CIDB row):

INSERT INTO FUNCTION file('test_7_04019.avro', 'Avro', 'c0 Nullable(Tuple())')
SELECT c0 FROM test_7.test_nullable_empty_tuple

fatal.log carries exactly one fault, Address: NULL pointer, so the reported frame is the cause and not the aftermath of an earlier one.

Root cause: AvroRowOutputFormat::finalizeImpl is the only path that reaches the avro writer's close without first calling syncIfNeeded, and syncIfNeeded is the only thing that binds the encoder to a stream.

AvroRowOutputFormat.cpp:646-670 -- writePrefix calls createFileWriter then syncIfNeeded (:649, :651), and write does the same (:657, :658). finalizeImpl calls createFileWriter then goes straight to close (:668, :670), with no syncIfNeeded.

That matters because the constructor never touches the encoder: DataFileWriterBase::init (contrib/avro/lang/c++/impl/DataFile.cc:96-120) only calls setMetadata, so metadata_is_written_ stays false and StreamWriter::out_ stays nullptr (api/Stream.hh:382). The encoder is bound only by writeHeader (DataFile.cc:281, encoderPtr_->init(*stream_)), whose two callers are ~DataFileWriterBase (:126) and syncIfNeeded (:253). close (:135) does not: it calls flush -> sync, and sync's first statement is encoderPtr_->flush() (:143), which dereferences the null out_ at Stream.hh:439. sync does re-init at :145, but that is after the flush that faults.

The avro library guards this itself and is the clearest evidence the omission is the bug: ~DataFileWriterBase writes the header first when !metadata_is_written_ (DataFile.cc:125-126) before calling close. close alone has no such guard, so a caller invoking it directly must do what the destructor does.

Reaching finalizeImpl with a never-initialized writer needs the prefix suppressed and zero rows written. StorageFileSink::initialize suppresses the prefix when the target file is already non-empty: do_not_write_prefix = naked_buffer->size() then writer->doNotWritePrefix() (src/Storages/StorageFile.cpp:2365, :2377-2378). With need_write_prefix false, IOutputFormat::finalizeUnlocked (IOutputFormat.cpp:161) skips writePrefixIfNeeded and calls finalizeImpl directly; if no chunk ever arrived, write never ran either, so nothing called syncIfNeeded and the writer created inside finalizeImpl is flushed with a null stream. That path is fuzzer-timing dependent, which matches the frequency: keyed on the frame rather than the STID, CIDB has 2 hits in 180 days, this one and one on master on 2026-04-22 (Stress test (experimental, serverfuzz, arm_tsan), commit 391498a). Your 21-day window was simply shorter than the interval.

The fix is one line in finalizeImpl, calling syncIfNeeded before close, mirroring writePrefix/write and the destructor. It is idempotent, since syncIfNeeded is guarded by metadata_is_written_ (DataFile.cc:251). I am validating it in both directions with a test that pins the header-suppressed, zero-row shape, and I will link the PR here.

No fixing PR or tracking issue exists yet: searches for avro StreamWriter, DataFileWriterBase, avro finalizeImpl and doNotWritePrefix over open PRs all return nothing.

@groeneai

Copy link
Copy Markdown
Collaborator

Root cause found, and it is not Avro-specific. Two symptoms, one defect. I have a deterministic reproducer and a verified fix, but the scope turns on a concurrency question I would rather you decide than guess.

The defect. ClickHouse declares Avro as non-appendable (markFormatHasNoAppendSupport("Avro"), AvroRowOutputFormat.cpp:730) and StorageFile::write enforces that with CANNOT_APPEND_TO_FILE at StorageFile.cpp:2579. But that enforcement sits inside if (!paths.empty()) (:2568), and neither the file-descriptor form nor the partitioned form goes through it: the fd constructor never populates paths (:1274-1292), and PartitionedStorageFileSink returns at :2553, before the check. So StorageFileSink::initialize opens with O_APPEND, sets do_not_write_prefix = naked_buffer->size() (:2365) on a non-empty file, and appends to a format that cannot be appended to.

From there it splits:

  • With rows the encoder is bound normally and a second Avro header is written after the existing bytes. Exit code 0, no diagnostic, and the file is unreadable (Invalid data file. Magic does not match). This is silent data loss and it happens on master today.
  • With zero rows write() never runs, so nothing calls syncIfNeeded(). AvroRowOutputFormat::finalizeImpl (:663-671) is the only one of the three writer entry points that reaches close() without it, and DataFileWriterBase::sync flushes the encoder as its first statement (DataFile.cc:143) before binding it to the stream one line later. StreamWriter::out_ is still null, so out_->flush() segfaults. That is the failure you saw. The avro library guards this exact case in its own destructor (DataFile.cc:124-126), which is what makes the omission identifiable.

Deterministic reproducer on unmodified master, no fuzzer needed:

printf 'PREBYTES' > target.avro
clickhouse local --query "INSERT INTO FUNCTION file(3, 'Avro', 'c0 UInt8') SELECT 1 WHERE 0" 3>>target.avro

Segfault, with the same frames as the CI report. Varying one axis at a time: an empty target is clean, writing rows is clean of the segfault but produces the corrupt file, and every other format is clean, so the trigger is exactly non-empty-target plus zero-rows plus Avro.

The fix I verified. Enforce the format's own contract in StorageFileSink::initialize, where the authoritative per-sink size already exists, immediately before the prefix would be suppressed. Nine lines. Both symptoms become CANNOT_APPEND_TO_FILE with the target untouched; writing to an empty target still works and reads back; JSONEachRow still appends. It also aligns four routes that disagree today, since the path route and ENGINE = File(Avro) already raise that error.

Measuring the blast radius across all 13 non-appendable formats through the fd route: 10 of them already produce unreadable output today, so for those this replaces silent corruption with a clear error. ORC and Parquet are the exception, because their footer-seeking readers tolerate a junk prefix, so those two currently appear to work and would start failing. That is the one real behaviour change and it is why the engine documentation, which promises unconditionally that "if file exists, INSERT would append new values in it", needs qualifying in the same change.

Where I need your call. Reading the failing job's clickhouse-server.err.log, the state is reached through concurrency: 31 distinct query ids across 5 threads touch that test's Avro path, with 5 overlapping pairs. That is possible because rwlock is a per-instance member (StorageFile.h:198) and each file() call constructs a fresh StorageFile, so two inserts to one path never exclude each other. The comment at StorageFile.cpp:1757 already records this for the read path.

The guard still closes both reported symptoms regardless of the interleaving, because it fires on an fstat of the already-opened descriptor before the writer is created. I measured 12 racing iterations with zero segfaults. What it does not close is the case where both sinks see an empty file and both write a header: two concurrent writers into a freshly-emptied path give a file that reads back as one row, so one writer's data is lost.

So either:

  1. I send the guard now, and open a separate issue for the lost update, or
  2. the two go together, which means introducing a path-scoped lock held from open through finalization. No such primitive exists today, it would sit in a path shared by file(), ENGINE = File, partitioned writes and clickhouse-local, and it decides user-visible behaviour I should not pick unilaterally: whether a second concurrent insert blocks or fails, with what timeout, and whether it must hold across processes.

My preference is 1, because the crash and the silent corruption are the reported problems and the residual is narrower and no longer silent. But 2 is the complete fix for the concurrency defect, and it would make the documented "INSERT queries will wait each other" true for the first time. Tell me which you prefer and I will send that PR.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai Go with option 1: send the nine-line guard now, and open a separate issue for the concurrent lost-update case.

The reported problems are the segfault and the silent corruption, and your guard closes both deterministically. Option 2 means designing a path-scoped lock held from open through finalization, shared by file(), ENGINE = File, partitioned writes and clickhouse-local, with user-visible blocking/timeout/cross-process semantics — that deserves its own issue and discussion, not a rider on a crash fix. The residual after option 1 (two concurrent writers both seeing an empty file) is narrower, no longer silent, and will be tracked.

Two asks for the guard PR:

  1. Since ORC and Parquet fd-route appends currently appear to work and will start raising CANNOT_APPEND_TO_FILE, qualify the File engine documentation ("if file exists, INSERT would append new values in it") in the same PR, and use the "Backward Incompatible Change" changelog category if you conclude the promise was load-bearing — otherwise spell the behavior change out in the description.
  2. Put the deterministic reproducer in the tests (both the zero-rows segfault case and the with-rows corruption case).

Thanks for the thorough root-cause work — the four-routes-disagree analysis makes the right layer for the check obvious.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Status on 1787559: the AI review verdict is now green ("No new blocker or major findings on the current PR head"), and CI is green except a single unrelated red — Logical error: Got read request from replica A for unknown stream B. on the amd_llvm_coverage ParallelReplicas shard, which is #110518 (already labeled in the report; fix open in #111689, not yet merged, so updating the branch would not clear it).

No code changes needed this round. Remaining before merge: the LogCluster-vs-artifact design question from @maxknv, and the final human merge.

@groeneai

Copy link
Copy Markdown
Collaborator

Option 1 confirmed. Before I send the guard, two corrections to my own measurements above, both of which change what the PR will say.

The lost update I described does not exist. I claimed two concurrent writers into a freshly-emptied path give a file that reads back as one row. That was a misreading: 147 bytes is the size of a single writer's output, not the survivor of two. Re-measured, two concurrent same-path Avro inserts produce exactly twice the single-writer size (294 bytes; at 200k rows, 8 of 8 iterations gave 1186026 = 2 x 593013). No bytes are lost. The unreadable result is two concatenated headers, which is the with-rows corruption again, not a lost update. My staggered truncate runs were invalid too: one writer finishes in 0.16 to 0.80s, so 0.15 to 1.0s delays never overlapped, and a purely sequential control produces an identical file, which is just engine_file_truncate_on_insert replacing as documented.

So I have no demonstrated lost-update defect, and I would rather not open an issue on a premise I just refuted. The accurate residual is the narrower one already acknowledged in the tree at StorageFile.cpp:1759: rwlock is a per-instance member (StorageFile.h:198) and TableFunctionFile builds a fresh StorageFile per call, so nothing excludes same-path writers. I can file that as "no mutual exclusion between same-path writers", without claiming data loss, if you still want it tracked.

The behavior change is wider than I reported. I said 10 of 13 formats are already unreadable with ORC and Parquet the only regression. Measured across all 13, 6 read back cleanly today: Arrow, ArrowStream, JSON, Npy, Parquet, ORC. But none of them actually appends. Writing 1 and then appending 2 reads back [1] for the first five, so the appended rows are silently discarded, and Parquet fails a real column read with TProtocolException: Invalid data: OffsetIndex. All 13 today either corrupt the file, silently drop the appended rows, or already error.

That answers your changelog question. The documented promise was never load-bearing on this route because it never appended, so I will use Bug Fix and spell the behavior change out in the description, naming all 6 affected formats rather than 2.

Both asks are in the PR: the documentation qualification, edited in the embedded Documentation block at StorageFile.cpp:2873 since the generated .mdx line sits inside the autogenerated region, and both reproducer cases as tests.

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

The guard is up: #112839

Both asks are in it. The documentation qualification is in the embedded Documentation block in StorageFile.cpp, and the sentence is scoped per route, because engine_file_truncate_on_insert and engine_file_allow_create_multiple_files do not both apply on the routes the guard newly rejects: the descriptor route never reads flags and its paths is empty, and the partitioned route returns its sink before the multiple-files branch. Both reproducer cases ship as tests, the zero-rows one that segfaults and the with-rows one that leaves the file unreadable, alongside the partitioned route, Parquet, and controls asserting that an empty target still writes, JSONEachRow still appends, and both settings still work.

Changelog category is Bug Fix, with the behavior change named in the description for all six formats, per the measurement I sent you.

I did not open the concurrency issue, since the premise I would have filed it on is the lost update I retracted. The accurate residual is the narrower one already acknowledged at StorageFile.cpp:1759, that nothing excludes same-path writers, and I am happy to file that framing if you want it tracked separately.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master into the branch (was ~1976 commits behind, PR was reported as CONFLICTING) — commit 05d316ef44f.

The only conflict was in ci/defs/job_configs.py: master added ./packages to build_digest_config.include_paths (so package definition changes reschedule a rebuild) while this branch added ./ci/jobs/scripts/log_cluster.py and ./utils/prepare-time-trace/prepare-time-trace.sh (so profile producers reschedule a rebuild). Both are purely additive, so both entries are kept.

Verification after the merge: 60 tests pass (ci/tests/test_build_profile_hook.py + ci/tests/test_build_profile_diff_job.py), ruff check clean, and python3 -m praktika yaml produces no diff (the run_on_upstream_failure gate assertion in test_the_generated_workflow_keeps_only_the_upstream_half_of_the_gate still holds against the regenerated .github/workflows/pull_request.yml).

The merge also pulls in #111689 (merged 2026-07-31), which fixes the only unrelated red on the previous head — Got read request from replica A for unknown stream B (#110518) on the coverage/ParallelReplicas shard — so that red should clear on the next run.

AI review on the previous head was green ("No new blocker or major findings"). The remaining open item is still the design question from @maxknv: whether the check should read the profile from the Logs cluster (current implementation) or from a build-provided artifact referenced in S3/CIDB.

@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

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

This PR only adds CI machinery (a new 'Build profile diff' check plus build-profile upload tooling in prepare-time-trace.sh and the CI job configs); it does not touch the server's query-execution path. The single flagged query, ClickBench Q15, was deterministically suppressed as within master's variance band, and that verdict is consistent with the diff: a build/CI-only change cannot plausibly move a SELECT median, so the -12.3% reading is run-to-run noise. No real performance change here. The private and public diffs are identical, so this conclusion applies to both.

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 640044b5-b360-4cc0-a397-305a1f8f2031
  • MIRAI run: b3ad7ba8-1b13-4691-925d-8f51fb9cadd9
  • PR check IDs:
    • clickbench_1319200_1785641063
    • clickbench_1319207_1785641063
    • clickbench_1319218_1785641063
    • tpch_adapted_1_official_1319229_1785641063
    • tpch_adapted_1_official_1319245_1785641063
    • tpch_adapted_1_official_1319270_1785641063

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Status on 05d316ef44f:

  • Public CI is green (all builds, stateless, integration, stress, upgrade, fuzzers passed); the Build profile diff job's own report is 5/5 passed. AI review verdict: ✅ No new blocker or major findings on the current PR head. Cloud performance: no_change.
  • The only red is CH Inc sync — tests failed (2 new, 1 known) on private sync PR #65197. The failures are Lost s3 keys, S3_ERROR No such key thrown (in clickhouse-server.log or clickhouse-server.err.log) (Stateless tests, amd_debug, distributed cache, meta in keeper, s3 storage, parallel) and Distributed cache processed no requests on remote storage (Stress test, amd_debug, meta in keeper). No individual test failed — these are private-only S3 / distributed-cache log checks. This pull request changes only CI machinery (ci/*.py, utils/prepare-time-trace/prepare-time-trace.sh, workflow YAML) and no server code, so it cannot affect the S3 object lifecycle or the distributed cache. Reran the failed private jobs.
  • No new review feedback. The remaining open item is the design question from @maxknv (read the profile through the CI logs cluster vs. a build-provided artifact plus S3 reference) — that is a human decision, left as is.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 2, 2026
@alexey-milovidov alexey-milovidov self-assigned this Aug 2, 2026
Merged via the queue into master with commit 4b3181f Aug 2, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the build-profile-diff branch August 2, 2026 16:44
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 2, 2026
pull Bot pushed a commit to Mu-L/ClickHouse that referenced this pull request Aug 3, 2026
pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request Aug 6, 2026
…memory-pressure spikes

Since 2026-08-03, the `Post Hooks` step of `Build (arm_release)` fails on
75-86% of all runs, PRs and master alike: the telemetry INSERT into the
shared CI logs cluster is rejected with HTTP 500, Code 241
`MEMORY_LIMIT_EXCEEDED` ("User memory limit exceeded ... OvercommitTracker
decision: Query was selected to stop"), and `build_profile_hook.py` fails
closed. The wave started when ClickHouse#111164 began uploading reduced build
profiles for every PR build, multiplying the INSERT rate.

`LogCluster.do_query` made a single attempt (`retries=1`), while `select`
in the same file already retries 8 times with a growing backoff, its
comment documenting exactly these minutes-long Code 241 pressure spikes.
Retry the INSERT transport on the same schedule, and rewind a file-like
body before every attempt: requests consumes the stream on the first POST,
and re-sending the exhausted stream would run an INSERT with an empty body
- a success with the telemetry silently lost. 4xx rejections still fail
after the first attempt, and the fail-close `assert` stays.

Example report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109496&sha=latest&name_0=PR&name_1=Build%20(arm_release)
Related: ClickHouse#113408

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

Labels

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