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

The thread pool can freeze if all the tasks depend on something that's not being executed #22

Open
vittorioromeo opened this issue Jan 5, 2017 · 1 comment

Comments

@vittorioromeo
Copy link
Owner

Assumte that the thread pool has only 4 threads, and that there is a DAG path where 5 systems can be executed in parallel. The thread pool may deadlock as every system is waiting for its subtasks to be completed, but they cannot be enqueued as all threads are occupied.

This would probably be improved by making the DAG execution asynchronous (see #21), but it would be nice to detect this "deadlock" from the thread pool and insert additional temporary "virtual threads" that solve the situation.

@schets
Copy link

schets commented Jan 5, 2017

Looking over the code, it appears as if each task in the DAG is submitted to the global MPMC queue where worker threads are continuously popping from the queue, and this causes deadlock since each task is waiting on other tasks stuck way at the top of the queue.

The simplest way to fix this is probably going to be allowing threads to work on their own tasks so that they can never stall. You can achieve this with a work-stealing style of task scheduling as opposed to this global queue. Doing that will also fix #21 since threads execute their own tasks as opposed to waiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants