Skip to content

Optimize thread spawning in PipelineExecutor - #79570

Merged
serxa merged 7 commits into
masterfrom
optimize-idle-threads
May 29, 2025
Merged

serxa merged 7 commits into
masterfrom
optimize-idle-threads

Conversation

@serxa

@serxa serxa commented Apr 25, 2025

Copy link
Copy Markdown
Member

Two optimizations:

  1. Do not use atomic counter for idle threads (and do not lock the mutex more times than before). Status is checked while we are under lock and returned.
  2. Do not spawn threads if there are no tasks to execute. Rationale: Spawning threads is like waking an idle thread, but also has additional cost. We do not wake threads if there is no work to do, so there is no reason to spawn a thread in that case too.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Apr 25, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f4740d1]

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Apr 25, 2025
@nickitat nickitat self-assigned this Apr 25, 2025
@serxa
serxa added this pull request to the merge queue May 29, 2025
Merged via the queue into master with commit f72ad38 May 29, 2025
@serxa
serxa deleted the optimize-idle-threads branch May 29, 2025 11:45
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label May 29, 2025
@Algunenano

Copy link
Copy Markdown
Member

This is great and I'm pretty sure this is a performance improvement in many cases, so I'd suggest changing the tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants