Repository navigation
Start executor threads for CPU slots granted after the request - #125901
Conversation
A thread requested by `ExecutorTasks::pushTasks` was dropped if no CPU slot was granted at that moment, so a slot granted later stayed unused until the pipeline pushed new tasks again. `ExecutorTasks` now keeps such requests in `threads_to_spawn`, and every thread starts threads for granted slots after each task while it is non-zero. Remove `spawn_mutex` with the `pending_demand` spin loop: spawning is safe from any thread, and `desired_threads` is an atomic that only grows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [016fb17] Summary: ✅
AI ReviewSummary
Missing context / blind spots
Final VerdictStatus: ✅ Approve. No additional code changes requested; current-head CI results remain pending. |
After the slots are released, every step waits until all threads are in it, instead of counting steps until they all ran one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A thread stops when its preempted CPU lease is not granted back in time. It was started again only when new tasks were pushed; now `ExecutorTasks::downscale` adds a requested thread, so it starts as soon as the slot is granted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Related: #125394 fixes the same problem, CPU slots granted to a running query that no thread picks up. It keeps the current spawning code and retries This PR deals with it where the requests are made instead. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test is taken from #129072 by Melvyn Peignon. Co-Authored-By: Melvyn Peignon <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
#129072 fixes the same problem, found from a production case (an object storage scan that kept 3 threads after the other queries released their slots). Its integration test is now part of this PR, in b35bff9: it passes here and fails on master (the query finishes 2.6 s after the release, the limit is 1.5 s). |
The signature of `init` differs on release branches, so this keeps backports free of conflicts in `ExecutorTasks`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Wait for the released slots to be acquired instead of checking how long the query takes, bound every wait, and kill both queries on any failure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ExecutorTasks::downscale` keeps its meaning; `executeStepImpl` requests the thread where it stops. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A workload limits the query to fewer CPU slots than threads, so every thread checks for granted slots after each step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pawn-without-mutex
|
A known limitation, unchanged from master: the |
|
@groeneai, please investigate the failure and provide a fix in a separate PR, or link an existing one if already in progress. Performance Comparison (amd_release, master_head, 4/6): server crashed during the test run ( |
|
The server did not crash. Each The check failed on
This is the class from #124574, which was closed as not planned today, so there is no fix PR to link and nothing to fix in the C++ code. cc @egor-click: the placement reruns change only the stack/TLS placement, so a code-placement artifact passes them, and the tier stayed |
Backport #125901 to 26.10: Start executor threads for CPU slots granted after the request
Cherry pick #125901 to 26.8: Start executor threads for CPU slots granted after the request
Cherry pick #125901 to 26.9: Start executor threads for CPU slots granted after the request
Backport #125901 to 26.8: Start executor threads for CPU slots granted after the request
Backport #125901 to 26.9: Start executor threads for CPU slots granted after the request
A query that starts while CPU slots are busy gets fewer threads than it asked for. When other queries release their slots, the slots are granted to this query, but it did not start threads for them:
PipelineExecutoracquired slots only right after a step pushed tasks to the shared queue, and a thread that keeps running its own chain of tasks does that only after 128 local tasks in a row. Until then the granted slots stayed unused, by this query and by every other one.ExecutorTasksnow keeps the requested threads that found no slot (threads_to_spawn, at most the pipeline width). Every thread checks it after each task, without a lock, and starts a thread for each slot granted since. Requests come frompushTasks(unchanged demand, sosetMaxgrows as before), from the initial tasks, and in place of a thread downscaled because its preempted CPU lease was not granted back in time, so that thread is started again once the slot is.spawn_mutexis removed with thepending_demandcounter and the spin loop around it.tryAcquire,ExecutorTasks::upscaleand the thread pool are thread-safe, so any thread can start threads for the slots it acquired;ExecutorTasksnow raises thesetMaxtarget itself as it requests threads, sopushTasksreturns nothing; the target only grows, andsetMaxis called with the latest target under a separate mutex, so concurrent calls can't leave the allocation below it.Tests: gtests for a slot granted while the pipeline runs (lazy and eager allocation) and for a downscaled thread, integration tests where another query releases the slots under
concurrent_threads_soft_limit_numand where a worker downscaled by CPU preemption is replaced once the competing query finishes, and a performance test where a workload gives a query fewer CPU slots than threads.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A query that started while CPU slots were busy, or whose threads were stopped by CPU preemption, now starts threads for the slots granted to it later as soon as they are granted. Previously such slots could stay unused for seconds, and other queries could not use them either.
Workflow [PR]
Sync PR [sync-upstream/pr/125901]
Version info
26.11.1.1421-master(included in26.11and later)