Skip to content

Cherry pick #125901 to 26.8: Start executor threads for CPU slots granted after the request - #129526

Merged
robot-clickhouse-ci-2 merged 20 commits into
backport/26.8/125901from
cherrypick/26.8/125901
Nov 8, 2026
Merged

robot-clickhouse-ci-2 merged 20 commits into
backport/26.8/125901from
cherrypick/26.8/125901

Conversation

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

Original pull-request #125901

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

serxa and others added 19 commits October 14, 2026 23:01
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]>
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]>
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]>
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]>
A thread waits for a task only when the queues are empty, so no queued task is left
for the requested threads. `upscale` drops them only when the pipeline width is reached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`pushTasks` raises the `setMax` target itself after releasing its mutex and returns nothing,
so the executor only starts threads for granted slots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The target is raised under `ExecutorTasks::mutex`; `setMax` is called with the latest target under
a separate mutex, since the allocation calls `resume` under its own lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An idle thread drops the requested threads only if no asynchronous task is pending either:
the tasks that become ready later need the threads.

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

Start executor threads for CPU slots granted after the request
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Nov 5, 2026
@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Dear @serxa, @Michicosun, this cherry-pick PR has not been updated for 3d0h6m28s. Please resolve the conflicts to backport #125901, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

Resolve conflicts for 26.8: no `SCOPE_EXIT` in `finalizeExecution`, `ExecutionStatus` instead of
`CancelReason`, push tasks on `UpdateNodeStatus::Done`, keep `yield` on downscale. Adapt the gtest
to the 26.8 executor (no `Runtime::V1` namespace, `ExecutorTasks::init` signature, task queues of
graph nodes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 merged commit c50f4fe into backport/26.8/125901 Nov 8, 2026
2 checks passed
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 deleted the cherrypick/26.8/125901 branch November 8, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants