Repository navigation
Run the single-key query of the serialization_pool_lookup performance test in one thread - #122517
Conversation
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]>
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.
Session id: cron:clickhouse-review-slot-9:20260927-090500 |
|
Workflow [PR], commit [783bdb8] Summary: ✅
AI ReviewSummaryThis PR narrows query Final Verdict✅ No blocking issues found. |
|
@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. |
|
Noted, I'll tag @ egor-click for those from now on, and I have moved my open dashboard question on #119556 to him. |
Related: #117533
Changelog category (leave one):
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 #0as 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
Dynamickey 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%:serialization_pool_lookup #0serialization_pool_lookup #1serialization_pool_lookup #2group_by_dynamic_keys #0(same per-row lookup, one thread)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-threadedGROUP BYover a single-typeDynamickey 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
26.10.1.824-master(included in26.10and later)