connection_pool: fix excessive idle CPU usage while waiting for requests#336
Open
ThCompiler wants to merge 2 commits into
Open
connection_pool: fix excessive idle CPU usage while waiting for requests#336ThCompiler wants to merge 2 commits into
ThCompiler wants to merge 2 commits into
Conversation
DifferentialOrange
approved these changes
Jun 22, 2026
Comment on lines
-663
to
+666
| if not unit.input_queue.empty(): | ||
| task = unit.input_queue.get() | ||
| try: | ||
| task = unit.input_queue.get(timeout=self.refresh_delay) | ||
| except queue.Empty: | ||
| task = None |
Member
There was a problem hiding this comment.
Seems like a nice fix, let's add a CHANGELOG entry about its effect.
Author
There was a problem hiding this comment.
Added entry about changes to CHANGELOG.
| while unit.request_processing_enabled: | ||
| if not unit.input_queue.empty(): | ||
| task = unit.input_queue.get() | ||
| try: |
Member
There was a problem hiding this comment.
Commit message codestyle should be something like
connection_pool: fix cpu overload if stale
Author
There was a problem hiding this comment.
Updated commit message in accordance with code style.
oleg-jukovec
requested changes
Jun 22, 2026
oleg-jukovec
left a comment
Contributor
There was a problem hiding this comment.
Please, update the commit message (see above) and add a new entry to the CHANGELOG.md.
Author
|
I had to update the build os version for the plugin to 24.04, as it stopped supporting 20.04. 24.04 was selected based on a similar version update in #330. |
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.
While using
ConnectionPool, it was found that it uses 100% cpu for its threads when at rest. After examining its operation, it was realized that the_request_process_loopruns in an infinite loop, without blocking on waiting for the next request. To reduce the load, I suggest using already implemented wait for the next element in the queue's from packagequeue.To check the solution, I implemented a simple test that calculates the n-th element of the Fibonacci sequence using a
ConnectionPoolrunning in the background:I ran the test with the changes and the old ConnectionPool behavior. So i got the following test results:

I also looked at the distribution of processor activity using py-spy for each of the tests:
As you can see from the py-spy snapshots, after the change, the processor is almost fully used for calculating Fibonacci sequence, while with the current behavior, most of the time is spent on
_request_process_loop.