MergeTree: reduce mutex lock critical section in MergeTreeReadPool#74202
Merged
nickitat merged 2 commits intoClickHouse:masterfrom Jan 6, 2025
Merged
MergeTree: reduce mutex lock critical section in MergeTreeReadPool#74202nickitat merged 2 commits intoClickHouse:masterfrom
nickitat merged 2 commits intoClickHouse:masterfrom
Conversation
Contributor
|
This is an automated comment for commit 2ad6daa with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
nickitat
approved these changes
Jan 6, 2025
Member
|
|
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For given query, usually threads will share the same MergeTreeReadPool. When the threads try to get task (
MergeTreeReadPool::getTask), it is guarded by a mutex, if one thread is in the critical section, the others need to wait.From our profiling, most of the cycles in
getTask()is consumed bycreateTask()(about 70%), but it does NOT need mutex protection.If we move
createTask()out of the critical section, we see ~5% QPS gain in ClickBench Q1 & Q2 (Tested in Xeon 8380, 160 vCPUs, 2 sockets).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Reduce critical section in
MergeTreeReadPool.Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing)
All builds in Builds_1 and Builds_2 stages are always mandatory
and will run independently of the checks below: