Skip to content

Add a performance test for queries that run under a CPU workload - #126515

Merged
alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-test-workload-cpu-scheduling
Oct 19, 2026
Merged

alexey-milovidov merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/perf-test-workload-cpu-scheduling

Conversation

@groeneai

@groeneai groeneai commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #126336
Related: #126133

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

Requested in #126336. No performance test used the workload CPU scheduler, so a regression in slot renewal, parking or preemption was invisible to the Performance Comparison.

workload_cpu_scheduling.xml creates a CPU resource and workloads, and measures:

  • a parallel GROUP BY in a workload with 64 slots and in one with 4 slots for 8 threads;
  • a window step in one thread while the other executor threads idle and park;
  • a one-thread remote() initiator that parks its slot while it waits on the sockets;
  • a throttled read that parks on every throttler sleep (local_filesystem_read_method = 'read' throttles page cache reads too);
  • a shell item: a CPU query sharing one slot with a sibling workload's query that has just parked on every read of its set; parked credit (parkLease never lowers requested_ns; competing workloads starve for seconds #126133) lengthens its latency.

The test fails unless each SQL item parks in its setup run, the 4-slot workload runs fewer threads than the 64-slot one, and the shell item's CPU query waits for its slot, so a query moved off the scheduler cannot pass as a speed-up.

The test creates server-wide objects, so ordinary runs now prove their teardown as --long runs do: the drop queries run on every exit, teardown-complete is printed only when each succeeded or found its object absent, and the CI loop stops the batch otherwise. Before, a failed run could leak them into the next tests of the shard.

Validation, locally with CI's x86 server profile: in two 15-run A/A comparisons every item's median differs by at most 2% and the stat_threshold of any 7 consecutive runs is at most 0.08. Master against #126336: the shell item is 30% faster with the fix, the other items within 1.8%.

🤖 Generated with Claude Code


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

Version info

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

groeneai and others added 5 commits October 17, 2026 15:30
…teardown

Ordinary (PR / master) runs now use the teardown contract that `--long`
runs already have: the drop queries run on every connection that ran
setup at the normal end and on every early exit (atexit), only
UNKNOWN_TABLE / UNKNOWN_DATABASE count as proof that an object is absent,
and `teardown-complete` is printed only when the servers are known
clean. The CI loop stops the batch when a test does not print it (a
`long` test skipped in an ordinary run created nothing).

Before, a timed-run error left the test's objects on the servers and the
batch went on, and the ordinary drop loop ignored every drop error on a
connection with a tolerated setup failure. A test that creates a
server-wide object (a CPU resource) would move every later test of the
shard to another execution path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Queries take their threads from a workload with a CPU resource: a wide
workload, a narrow one with fewer slots than threads, and two sibling
workloads under one slot, where a CPU query runs next to a query that
has parked on every throttled read of its set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uplicate items

`remote()` runs with one thread: the only executor thread then holds the
CPU slot while it waits on the sockets, so it parks there. With more
threads the sockets are polled by a thread without a slot. It runs in the
wide workload only, as does the window step (the limit does not bind
there). Constants recalibrated (GROUP BY 200M rows, remote() 80M rows,
CPU query 400M rows).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each SQL item runs once in the setup, and the setup fails unless every one of them parked in its workload: a
query routed off the CPU scheduler is faster, so the comparison alone would report it as an improvement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… test

The setup oracle now also fails when the 4-slot workload runs as many threads as the 64-slot one, and reads only
the newest row of each probe, so a failed run does not fail the reruns of the next 10 minutes. The shell item fails
unless its CPU query waited for the slot it shares with the neighbour.

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

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 rounds, 4 findings, the last round clean), plus my own review.

# Sev Finding Verdict Evidence / action
1 ⚠️ The items are only timed, so a query routed off the CPU scheduler would pass (workload_cpu_scheduling.xml) AGREE, fixed @ c4d183d The setup now runs each SQL item once and fails unless every one of them parked; checked both ways (an unknown workload, cpu_slot_parking = false).
2 ⚠️ The setup check does not prove the 4-slot limit, and the shell item has no check at all AGREE, fixed @ ea9c1ff The setup also fails unless the 4-slot workload runs fewer threads than the 64-slot one, and the shell item fails unless its CPU query waited for the slot it shares with the neighbour (ConcurrencyControlWaitMicroseconds). The park site needs no extra check: each one-thread probe has a single wait site.
3 ⚠️ teardown-complete can be printed with nothing dropped (perf.py teardown()) DISAGREE Before the setup scope is set no create query has run, so there is nothing to drop. The docstring and the description now say what the marker proves: every drop query succeeded or found its object absent.
4 💡 One failed probe fails every rerun on that server for 10 minutes AGREE, fixed @ ea9c1ff The check reads only the newest row of each probe.
5 💡 Drops on a reference whose do_not_check_in_pr setup failed are now strict DISAGREE Same as --long; the only user (#113575) drops with DROP TABLE IF EXISTS.
6 💡 compare.sh confirm reruns do not stop on an unproven teardown DISAGREE A failed rerun keeps the original verdict; no loop checked teardown in ordinary runs before.

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

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review the perf.py part? Ordinary runs now run the drop queries on every exit, print teardown-complete only when each drop succeeded or found its object absent, and the CI loop stops the batch otherwise, as --long runs already do; the new test needs it because it creates server-wide workloads.

@clickhouse-gh

clickhouse-gh Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ea9c1ff]

Summary: ✅


AI Review

Summary

Adds performance coverage for CPU workload scheduling, including parking and contention between sibling workloads. Ordinary performance runs now execute teardown on failure and stop the batch when cleanup cannot be established. Reviewed commit ea9c1ff8abd47c0deec8c093e5996e6fa1716087, including the current code and all prior discussion. No actionable findings.

Missing context / blind spots
  • ⚠️ Real-server execution was not independently reproduced: this checkout has no ClickHouse binary, and the linked CI report contained no performance-test result rows when inspected. The PR reports local stability and before/after measurements. All 13 mocked runner checks passed, covering ordinary and long runs, setup/query/drop failures, tolerated reference failure, skipped tests, and cleanup-marker handling; these do not validate server-side cleanup or scheduler timing. Completed performance runs on amd64 and arm64 would close this gap.
Final Verdict

Status: ✅ Approve. No required changes identified.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 17, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 17, 2026
@serxa serxa self-assigned this Oct 17, 2026

@serxa serxa 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.

Looks like a good starting point for perf test with workload scheduling enabled

@serxa

serxa commented Oct 17, 2026

Copy link
Copy Markdown
Member

Make sure it is mergable and tag me

@groeneai

Copy link
Copy Markdown
Collaborator Author

The branch has no conflicts with current master, and master has not touched any of its four files since the base. Style check and Code Review passed. The red Mergeable Check is from the first attempt, before the can be tested label, and is recomputed when this run finishes.

The only jobs left are the six Performance Comparison (arm_release) shards, which are the ones that run the new test. They have been queued since 20:22 UTC behind the pr-arm-medium runner backlog (about 1,800 queued jobs). I'll tag you when they finish.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@serxa CI has finished and is green, and the PR is mergeable with no conflicts against master. On the ARM performance runners all six items of the new test passed with diffs within 2.1%, and every run of the five SQL items parked (at least 6 parks per query).

@serxa
serxa added this pull request to the merge queue Oct 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 18, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 18, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
Merged via the queue into ClickHouse:master with commit 5042751 Oct 19, 2026
526 of 528 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 19, 2026
@clickhouse-gh clickhouse-gh Bot added comp-scheduler Workload scheduler and resource management: CPU/IO/memory scheduling, concurrency control, worklo... and removed comp-testing Test content only (no production code). labels Nov 22, 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-scheduler Workload scheduler and resource management: CPU/IO/memory scheduling, concurrency control, worklo... 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