Skip to content

PS-10083-[8.4] Add more statistics for threadpool#5876

Open
lukin-oleksiy wants to merge 4 commits intopercona:8.4from
lukin-oleksiy:PS-10083-8.4-add_threadpool_statistics
Open

PS-10083-[8.4] Add more statistics for threadpool#5876
lukin-oleksiy wants to merge 4 commits intopercona:8.4from
lukin-oleksiy:PS-10083-8.4-add_threadpool_statistics

Conversation

@lukin-oleksiy
Copy link
Copy Markdown
Contributor

Add more statistics for threadpool: average queue wait time, requests waiting in queues, requests not entered queue

https://perconadev.atlassian.net/browse/PS-10083

Added highly optimized class for live statistic calculation in multi-threaded environment.

Added new status varables:

mysql> show status like "Thread%";
+-----------------------------------------+----------------------------------------------------------------+
| Variable_name                           | Value                                                          |
+-----------------------------------------+----------------------------------------------------------------+
| Threadpool_average_hp_queue_wait_us     | avg: 0.000, min: 0.000, max: 0.000, dev: 0.000, cnt: 0         |
| Threadpool_average_queue_wait_us        | avg: 590.000, min: 470.000, max: 736.000, dev: 110.266, cnt: 5 |
| Threadpool_idle_threads                 | 9                                                              |
| Threadpool_requests_not_entered_queue   | 0                                                              |
| Threadpool_requests_waiting_in_hp_queue | 0                                                              |
| Threadpool_requests_waiting_in_queue    | 0                                                              |
| Threadpool_threads                      | 10                                                             |
| Threads_cached                          | 0                                                              |
| Threads_connected                       | 1                                                              |
| Threads_created                         | 10                                                             |
| Threads_running                         | 2                                                              |
+-----------------------------------------+----------------------------------------------------------------+

@lukin-oleksiy lukin-oleksiy requested a review from dlenev March 17, 2026 09:59
@lukin-oleksiy lukin-oleksiy self-assigned this Mar 17, 2026
…, requests waiting in queues, requests not entered queue

https://perconadev.atlassian.net/browse/PS-10083

Added highly optimized class for live statistic calculation in multi-threaded environment.

Added new status variables:

mysql> show status like "Thread%";
+-----------------------------------------+----------------------------------------------------------------+
| Variable_name                           | Value                                                          |
+-----------------------------------------+----------------------------------------------------------------+
| Threadpool_average_hp_queue_wait_us     | avg: 0.000, min: 0.000, max: 0.000, dev: 0.000, cnt: 0         |
| Threadpool_average_queue_wait_us        | avg: 590.000, min: 470.000, max: 736.000, dev: 110.266, cnt: 5 |
| Threadpool_idle_threads                 | 9                                                              |
| Threadpool_requests_not_entered_queue   | 0                                                              |
| Threadpool_requests_waiting_in_hp_queue | 0                                                              |
| Threadpool_requests_waiting_in_queue    | 0                                                              |
| Threadpool_threads                      | 10                                                             |
| Threads_cached                          | 0                                                              |
| Threads_connected                       | 1                                                              |
| Threads_created                         | 10                                                             |
| Threads_running                         | 2                                                              |
+-----------------------------------------+----------------------------------------------------------------+
@lukin-oleksiy lukin-oleksiy force-pushed the PS-10083-8.4-add_threadpool_statistics branch from d97f573 to 1d0c888 Compare March 17, 2026 10:04
Copy link
Copy Markdown
Contributor

@dlenev dlenev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Oleksiy!

Here are some comments about your patch.

I think the first/most important thing for us is to agree whether we really need such a non-trivial infrastructure for gathering those aggregated stats. See below.

}

/* Count requests not entered a queue yet*/
int tp_get_requests_not_entered_queue_count() noexcept {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a problem with this value...
When there are too many busy threads each connection from the low priority queue will be counted twice,
once by tp_get_requests_waiting_in_queue_count() and then in tp_get_requests_not_entered_queue_count(). To me counting the same connection as being in queue and not entered in queue yet looks wrong.

Perhaps we need to invent some other way/status variable to make saturation situation visible? Or invent better name for this one? What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the real question I do not have answer yet also.

@lukin-oleksiy lukin-oleksiy force-pushed the PS-10083-8.4-add_threadpool_statistics branch from 7cc3d7c to 59af7f6 Compare April 1, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants