Repository navigation
Reduce CPU usage of thread pools with many threads waiting for a free slot - #129010
Conversation
|
Workflow [PR], commit [0c6cfc4] Summary: ✅
AI ReviewSummaryThe PR separates scheduler notifications from completion notifications and wakes one blocked scheduler per finished Missing context / blind spots
Findings
Tests
Final Verdict |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units385 translation units recompiled, 3069 s compile time in total, 384 of them have a recent master baseline. Translation units without a recent master baseline:
|
1e744f0
`upload_budget` gives the REPORT-stage uploads at least 60 s however late the job is, but the dashboard gate was called with `min(upload_deadline, end)`. When the benchmarks end late, the uploads start after `end`, so the gate's deadline has already passed when it starts: it raises "it was spent before the first request" without asking the dashboard, and the shard is judged by its own report, which fails on any slower row. The 3 red jobs since 2026-11-04 (master 29da6da, PRs ClickHouse#128972 and ClickHouse#129010) had 25-40 s of the uploads' 60 s left, and the dashboard answers in about 2 s with no blocking row for any of them. The gate now gets `upload_deadline`. That equals `min(upload_deadline, end)` whenever at least 60 s remain before `end` at the start of the uploads, so only a late job changes. Since the gate can now run past `end`, a dashboard GET no longer starts after the gate's deadline, and its socket timeout is `min(60, remaining)` instead of a flat 60 s. Otherwise a request started just before the deadline could wait 3 x 60 s past it in a late job. The gate's waits now end by the same bound as the uploads' 60 s floor. Related: ClickHouse#128236 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A finished
ThreadPooljob woke every thread waiting for a free slot, though only one can take it. Now it wakes one. I found this while testing server startup with 4000 tables: with 1024 loader threads scheduling into a 64-thread pool, these wakeups took half of the CPU, and the change cut startup from 98 s to 73 s.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reduced CPU usage when many threads schedule jobs into a full thread pool, for example while loading many tables at server startup.
Workflow [PR]
Sync PR [sync-upstream/pr/129010]
Version info
26.11.1.1536-master(included in26.11and later)