Skip to content

Run the single-key query of the serialization_pool_lookup performance test in one thread - #122517

Merged
fm4v merged 1 commit into
ClickHouse:masterfrom
groeneai:stabilize-serialization-pool-lookup-perf
Sep 27, 2026
Merged

fm4v merged 1 commit into
ClickHouse:masterfrom
groeneai:stabilize-serialization-pool-lookup-perf

Conversation

@groeneai

@groeneai groeneai commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #117533

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

Not required: CI-only change.

Description

On #117533 the performance dashboard scored serialization_pool_lookup #0 as a confirmed regression and failed arm 5/6 (report): 0.670 s on the old server, 0.799 s on the new one (+19.2%). The shard's own report did not flag it.

Query #0 groups 5M rows by a single-type Dynamic key in all threads, so every row looks up the same pool entry. Its time is a property of the server process: the samples of one server agree within 0.7% (p50), while the per-process medians span 0.643-0.840 s (arm, p05-p95). The time is the same with 16 and 12 threads (arm 0.754 and 0.775 s, before and after #122458). Runs moved by more than 15%:

arm PR arm master amd PR amd master
serialization_pool_lookup #0 123/789 54/558 68/176 220/560
serialization_pool_lookup #1 41/789 11/558 5/176 20/560
serialization_pool_lookup #2 0/789 0/558 0/176 0/560
group_by_dynamic_keys #0 (same per-row lookup, one thread) 0/782 0/559 0/173 0/559

I run #0 in one thread (numbers, max_threads = 1). It still times 5M lookups of the pool entry, but no thread waits for another core. This changes what #0 measures, not the server: a multi-threaded GROUP BY over a single-type Dynamic key still contends on that entry, and #0 no longer times that case. #1 (two keys) and #2 (the multi-threaded MergeTree read) keep the contention coverage.

Locally (x86, official master build, perf.py, 7 runs), new #0 takes 0.57 s with 0.56 s of user CPU and returns the same result as old #0, which took 1.76 s and 15.4 s of user CPU per run with 12 threads.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.824-master (included in 26.10 and later)

Query #0 groups 5M rows by a single-type Dynamic key. For every row the
aggregation looks up the variant's default serialization in
SerializationObjectPool: a shared lock on the key's shard mutex,
weak_ptr::lock, and the release of the returned SerializationPtr. These
are atomic read-modify-writes on two cache lines that every aggregation
thread writes for every row. One key means one shard, so the pool's
sharding cannot spread the load, and the query is bound by how fast those
lines move between cores. That speed is fixed per server process.

CI data (query_metric_runs_v1, arm, 1177 runs since 2026-09-17): the 5-7
samples of one server agree within 0.7% (p50), but the per-process medians
span 0.643-0.840 s (p05-p95). Fast and slow processes do the same work
(same arena bytes, memory, two-level hash tables and page faults) and
differ only in user CPU time (9.5 vs 12.1 s). The wall time does not
depend on the thread count: arm 0.754 s with 16 threads vs 0.775 s with
12, amd 0.669 s with 16 threads on 8 pinned cores vs 0.686 s with 8. So
each A/B run compares two random draws of that per-process speed. Runs
whose new/old median moved by more than 15% (raw samples):

                                 arm PR   arm master   amd PR   amd master
    serialization_pool_lookup #0  123/789     54/558    68/176     220/560
    serialization_pool_lookup ClickHouse#1   41/789     11/558     5/176      20/560
    serialization_pool_lookup ClickHouse#2    0/789      0/558     0/176       0/560
    group_by_dynamic_keys #0        0/782      0/559     0/173       0/559

group_by_dynamic_keys #0 runs the same per-row lookup path with
max_threads = 1. On PR ClickHouse#117533 the performance dashboard scored #0 as a
confirmed regression (arm 5/6, 0.670 -> 0.799 s) that the shard's own
report did not flag.

Run #0 in one thread, from numbers instead of numbers_mt, so it times the
pool's hit path itself, which does not depend on the process. Queries ClickHouse#1
(two keys, where sharding spreads the load) and ClickHouse#2 (the multi-threaded
MergeTree read) keep the contention coverage.

Local check on x86 with the official 26.10.1.820 master build, perf.py,
7 runs: old #0 1.76 s with 12 threads (15.4 s user CPU per run), new #0
0.57 s (0.56 s user CPU), same result. Ten fresh servers pinned to 8
cores with max_threads = 8: old #0 per-process medians 0.68-1.08 s; new
#0 0.56-0.58 s in 8 of them and 0.72-0.73 s in the two whose table
fills were also about 25% slower (9.2-10.0 s vs 7.4-8.6 s).

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

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

Independent model (codex) on this head: 1 nit. My own cold review, done before reading the implementation's evidence: no blocker or major, the same nit and three more.

  • Nit (both reviews): the test-level max_threads comment no longer covers #0. AGREE, not blocking: that comment is master's and still describes Repair subtree2 #1 and Repair subtree2 #2, and #0 states its own override.
  • Nit: "does not depend on the thread count" overstated the data. AGREE, fixed: the description says the time is the same with 16 and 12 threads.
  • Nit: the local numbers read like a speed-up. AGREE, fixed: the description says one thread changes what #0 measures, not the server.
  • Nit: #0's comment names the mechanism, not its per-process effect. AGREE, not blocking: the commit message carries it.

Session id: cron:clickhouse-review-slot-9:20260927-090500

@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [783bdb8]

Summary: ✅


AI Review

Summary

This PR narrows query #0 in serialization_pool_lookup to a single-threaded numbers source with query-local max_threads = 1, which matches the stated goal of removing per-process contention noise from that benchmark while keeping the other queries as multi-threaded coverage. I did not find a correctness, CI-contract, or PR-metadata issue that warrants an inline finding.

Final Verdict

✅ No blocking issues found.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 27, 2026
@groeneai
groeneai requested a review from fm4v September 27, 2026 09:42
@fm4v
fm4v enabled auto-merge September 27, 2026 09:43
@fm4v fm4v self-assigned this Sep 27, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 27, 2026
@fm4v
fm4v added this pull request to the merge queue Sep 27, 2026
Merged via the queue into ClickHouse:master with commit f4fc5b9 Sep 27, 2026
172 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 27, 2026
@fm4v

fm4v commented Sep 28, 2026

Copy link
Copy Markdown
Member

@groeneai tag @egor-click instead of me for any performance comparison framework problems, including: perf dashboard changes, flaky performance tests, general performance comparison framework improvements.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Noted, I'll tag @ egor-click for those from now on, and I have moved my open dashboard question on #119556 to him.

@clickhouse-gh clickhouse-gh Bot added comp-data-types Type system & core datatypes used across query planning/execution. 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-data-types Type system & core datatypes used across query planning/execution. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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.

3 participants