Skip to content

Fix CI failures in PGO/BOLT profile collection workflow - #105477

Merged
alexey-milovidov merged 1 commit into
masterfrom
pgo-collect-timeout
May 21, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
pgo-collect-timeout

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 20, 2026 •

Copy link
Copy Markdown
Member

Two CI failures in the new OptimizeClickHouse workflow (PR #100938) on master.

1. Collect PGO profiles times out without diagnostic (amd64)

The freshly-started PGO-instrumented clickhouse-server did not respond to
select 1 within the 30-attempt × 2 s = 60 s readiness window in
configure_datasets / start_server. PGO instrumentation slows startup
considerably (every instrumented site bumps a counter), so a 60 s window is too
tight for a cold start. The job log carried only a wall of Run command [... select 1] retries — the server's own preconfig.log / server.log is written
under perf_wd/pgo_server/ and is not uploaded as an artifact, so the actual
reason was invisible.

Failed run:

Fix in ci/jobs/collect_clickhouse_profiles.py:

  • Extract the readiness loop into wait_for_server_ready, switch from a fixed
    retry count to a wall-clock deadline of 600 s, and notice premature process
    exit during the wait (not just in the first 2 s).
  • On readiness failure or premature process exit, dump the tail of the server
    log to stdout via a new dump_log_tail helper.
  • Make polling quiet with a 30 s heartbeat so the longer window does not flood
    the log with Run command lines.

2. Build (BOLT) fails on PGO profile hash mismatches under -Werror (aarch64)

After fix 1 landed and PGO collection now succeeds, the next stage Build (BOLT)
fails because clang's PGO backend emits -Wbackend-plugin:

function control flow change detected (hash mismatch) <symbol>
    Hash = ... up to N count discarded

for several functions (ConcurrencyControl.cpp, Dwarf.cpp, Exception.cpp),
and the project-wide -Werror turns these into hard build failures.

Failed run:

The instrumented build is required to disable ThinLTO (the cmake check
in profile_optimization.cmake enforces this — clang IR instrumentation is
incompatible with ThinLTO), while the BOLT build enables ThinLTO. ThinLTO can
perturb individual function bodies before profile matching, so a non-zero number
of hash mismatches is expected. The compiler simply discards the stale counts
for those functions, which is the correct best-effort behaviour.

Fix in cmake/profile_optimization.cmake: add -Wno-error=backend-plugin
alongside the -fprofile-use=... flags so the mismatches remain visible as
warnings without aborting the build.

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.919

`Collect PGO profiles` failed on master because the freshly-started
PGO-instrumented `clickhouse-server` did not respond to `select 1`
within the 30-attempt × 2 s = 60 s readiness window in
`configure_datasets` / `start_server`. PGO instrumentation slows
startup considerably (every instrumented site bumps a counter), so a
60 s window is too tight for a cold start.

  https://github.com/ClickHouse/ClickHouse/actions/runs/26190353268/job/77057127893

  Job report:
  https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=31cab7e9b5059f3a9aee1f6a9edf24d322d9cd16&name_0=OptimizeClickHouse&name_1=Collect%20ClickHouse%20Profiles%20%28PGO%2C%20BOLT%29%20%28amd64%29

The job log carried only a wall of `Run command [... select 1]`
retries — the server's own log (`preconfig.log` / `server.log`) was
written inside `perf_wd/pgo_server/` and was not uploaded as a job
artifact, so the underlying reason was invisible.

Two changes:

  * Extract the readiness loop into `wait_for_server_ready`, switch
    from a fixed retry count to a wall-clock deadline of 600 s, and
    notice an early process exit during the wait (not just in the
    first 2 s).
  * On readiness failure or premature process exit, dump the tail of
    the server log to stdout via a new `dump_log_tail` helper, so the
    next failure can be diagnosed from the CI job log alone.

Polling is also made quiet, with a 30 s heartbeat, to avoid hundreds
of identical `Run command` lines in the longer window.
@clickhouse-gh

clickhouse-gh Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bb7d3fe]

Summary: ✅


AI Review

Summary

This PR extends server readiness waiting for PGO/BOLT profile collection and adds server-log tail dumps on startup failure. The timeout and diagnostics changes are useful, but the promised quiet polling behavior is not implemented in the current code, so this should not merge yet.

Findings

⚠️ Majors

  • [ci/jobs/collect_clickhouse_profiles.py:180] The readiness probe still calls Shell.get_res_stdout_stderr with its default verbose=True, so it prints Run command [...] every 2 seconds. With SERVER_READINESS_TIMEOUT_S = 600, this can still generate hundreds of repetitive lines and defeats the intended quiet polling + 30-second heartbeat behavior described in the PR.
  • Suggested fix: call Shell.get_res_stdout_stderr(..., verbose=False) in wait_for_server_ready.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
  1. Disable per-probe verbose logging in wait_for_server_ready so only the heartbeat and failure diagnostics remain in CI logs.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 20, 2026
# Polling is intentionally quiet — at one attempt every 2s a 10-minute
# window would otherwise produce hundreds of identical `Run command`
# lines; emit a progress heartbeat every 30s instead.
res, out, _ = Shell.get_res_stdout_stderr(

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.

Shell.get_res_stdout_stderr defaults verbose=True, so this call still prints Run command [...] on every 2-second probe. With a 600-second timeout that can produce ~300 noisy lines, so the intended quiet polling + 30-second heartbeat does not actually happen. Please pass verbose=False here.

@alexey-milovidov alexey-milovidov self-assigned this May 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 21, 2026
Merged via the queue into master with commit 99f6823 May 21, 2026
166 checks passed
@alexey-milovidov
alexey-milovidov deleted the pgo-collect-timeout branch May 21, 2026 00:38
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 21, 2026
@alexey-milovidov alexey-milovidov changed the title Extend server-readiness timeout in PGO/BOLT profile collection Fix CI failures in PGO/BOLT profile collection workflow May 21, 2026
DavidHe-2008 pushed a commit to DavidHe-2008/ClickHouse that referenced this pull request Jun 1, 2026
Extend server-readiness timeout in PGO/BOLT profile collection
pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request Jun 19, 2026
The `OptimizeClickHouse` workflow (`Collect ClickHouse Profiles (PGO, BOLT)`)
failed on both architectures.

amd64: the PGO-instrumented `clickhouse-server` segfaulted on startup right
after `Will remap executable in memory.`. The perf-comparison config
`zzz-perf-comparison-tweaks-config.xml` force-enables `remap_executable`, and
remapping the `.text` segment of the instrumented, non-self-extracting binary
crashes it. Strip the setting from the copied configs before launching the
server; the default `false` is what profile collection wants (remapping to huge
pages is an irrelevant micro-optimization here).

aarch64: the job hit the 8h timeout having run only 44 of 447 perf tests. The
instrumented binary is several times slower than a release build, individual
tests ran for tens of minutes, and passing `--max-queries 0` for the benchmark
files ran *all* of their queries. Profile collection is now strictly
time-bounded:

* each pass gets a wall-clock budget, clamped at run time to the time actually
  left in the job (via `collection_budget`) so a slow build cannot push
  collection past the hard kill, after which nothing is uploaded;
* each test runs under a hard `timeout` so one heavy test cannot stall a pass;
* `--max-query-seconds` / `--prewarm-max-query-seconds` cap per-query time;
* `--runs` is reduced (collection only needs to exercise code paths).

Tests skipped once a budget is exhausted are logged, never silently dropped.

Failing run: https://github.com/ClickHouse/ClickHouse/actions/runs/26215735471
Workflow: https://github.com/ClickHouse/ClickHouse/actions/workflows/optimize_clickhouse.yml

Related: ClickHouse#100938
Related: ClickHouse#105477

Co-Authored-By: Claude Opus 4.8 (1M context) <[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.

2 participants