Skip to content

Take into account the number of available threads before posting work to the thread pool - #23

Merged
rosa merged 3 commits into
mainfrom
check-available-threads
Aug 10, 2023
Merged

Take into account the number of available threads before posting work to the thread pool#23
rosa merged 3 commits into
mainfrom
check-available-threads

Conversation

@rosa

@rosa rosa commented Aug 10, 2023

Copy link
Copy Markdown
Member

Before this PR, we'd just post all available jobs to the pool regardless of whether there were threads available

Otherwise, we risk having all jobs in memory waiting for available threads. Then, if the worker is shutdown, these would be left unclaimed in limbo until manually released.

This made a new scenario possible: if we have many fast jobs available, we'd be sleeping for the whole polling interval waiting for threads to be available, even if the jobs are very fast, and that happens way before the polling interval is over. To avoid this, we allow the pool to wake up the worker when new threads become available.

rosa added 3 commits August 10, 2023 15:46
Otherwise we risk having all jobs in memory waiting for available threads,
that will be lost if the worker is shutdown, and will be left claimed in
limbo.
To prevent sleeping for the whole polling interval if there are jobs
waiting but there weren't any available threads to take them.
@rosa
rosa force-pushed the check-available-threads branch from 84b4318 to 3430c0c Compare August 10, 2023 16:57
@rosa
rosa merged commit 6bad40c into main Aug 10, 2023
@rosa
rosa deleted the check-available-threads branch August 10, 2023 17:43
hms pushed a commit to ikyn-inc/solid_queue that referenced this pull request Aug 5, 2024
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.

1 participant