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

Many uses of unbounded queues (TQueue) #12

Open
infinity0 opened this issue Nov 24, 2020 · 1 comment
Open

Many uses of unbounded queues (TQueue) #12

infinity0 opened this issue Nov 24, 2020 · 1 comment

Comments

@infinity0
Copy link

There are many uses of TQueue in this codebase, which is an unbounded queue. This effectively negates flow-control, as the consumer has no way to tell the producer to slow down, and the queue grows without bound by design.

You might not notice any problems during most normal system loads, but it can cause hard-to-debug problems during heavy load - the scheduler generally cannot figure out which consumers need to be run more often than which producers to keep the queue sizes down and so the queues may run out of memory.

The solution is not simple; generally one ought to replace the queue with a bounded queue, but depending on the relationship between the producers and consumers setting the appropriate bound is not obvious and case-dependent. If it is set too low, deadlocks can occur, e.g. if two threads have two queues between them in opposite directions, this is a cyclic relationship and can deadlock depending precisely on how the production / consumption depend on each other.

@infinity0
Copy link
Author

A nonblocking implementation as described in #11 (comment) avoids this entirely, since it does not need to use blocking queues.

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

No branches or pull requests

1 participant