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

dispatcher: lift pipe buffer size restriction #434

Merged

Conversation

Totktonada
Copy link
Member

A task queue dispatcher puts all the tasks to the task queue at startup. Then workers are started and are taking the tasks from it.

If there are many tasks in a task group (which roughly corresponds to a test suite), we can reach the pipe buffer size on putting into the queue, because multiprocessing.SimpleQueue uses a pipe under the hood.

The solution is to use multiprocessing.Queue, which has an intermediate buffer before the underlying pipe and writes to the pipe in a background thread, without blocking a thread that calls <queue>.put().

The Queue API is a superset of the SimpleQueue API, so we can just replace the implementation.

Let's also use Queue for the worker's output queue to be on the safe side and for consistency.

Fixes #287

A task queue dispatcher puts all the tasks to the task queue at startup.
Then workers are started and are taking the tasks from it.

If there are many tasks in a task group (which roughly corresponds to a
test suite), we can reach the pipe buffer size on putting into the
queue, because `multiprocessing.SimpleQueue` uses a pipe under the hood.

The solution is to use `multiprocessing.Queue`, which has an
intermediate buffer before the underlying pipe and writes to the pipe in
a background thread, without blocking a thread that calls
`<queue>.put()`.

The `Queue` API is a superset of the `SimpleQueue` API, so we can just
replace the implementation.

Let's also use `Queue` for the worker's output queue to be on the safe
side and for consistency.

Fixes #287
@Totktonada Totktonada requested a review from ochaplashkin May 29, 2024 11:17
@sergos sergos requested a review from ylobankov May 29, 2024 11:19
@coveralls
Copy link

Coverage Status

coverage: 62.54% (+0.03%) from 62.506%
when pulling 584c128 on Totktonada/gh-287-lift-pipe-buffer-size-restriction
into 1037299 on master.

Copy link
Contributor

@ylobankov ylobankov left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link

@ochaplashkin ochaplashkin left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@ylobankov ylobankov merged commit 81259c4 into master May 29, 2024
19 checks passed
@ylobankov ylobankov deleted the Totktonada/gh-287-lift-pipe-buffer-size-restriction branch May 29, 2024 11:28
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.

Run many tasks on one worker
4 participants