Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a yield to prevent Processor from hogging redis connections #44

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

spencewenski
Copy link
Contributor

Problem

When there are no sidekiq jobs available in redis, there are no awaits between when brpopreturns and when the next connection is acquired from the pool. This means tokio's task scheduler doesn't have a chance to switch to another task that's waiting for a connection.

Solution

Add a tokio::task::yield_now().await in the case where there is no actual job to handle. This allows tokio's task scheduler to wake up a different task that's waiting for a connection.

#43

Problem
-------
When there are no sidekiq jobs available in redis, there are no `await`s
between when `brpop`returns and when the next connection is acquired
from the pool. This means tokio's task scheduler doesn't have a chance
to switch to another task that's waiting for a connection.

Solution
--------
Add a `tokio::task::yield_now().await` in the case where there is no
actual job to handle. This allows tokio's task scheduler to wake up a
different task that's waiting for a connection.

film42#43
@film42 film42 merged commit bb1d625 into film42:master Apr 25, 2024
1 check passed
@film42
Copy link
Owner

film42 commented Apr 25, 2024

Released as version v0.10.4 ❤️ !

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