Skip to content

Provide global back-pressure on mpsc::Sender::send #1671

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

Merged
merged 1 commit into from
Jun 13, 2019

Conversation

0-o-0
Copy link
Contributor

@0-o-0 0-o-0 commented Jun 12, 2019

Previously the bounded mpsc channels don't provide back-pressure for every new cloned sender where the capacity check is bypassed. It's an issue when use it with combinators, like buffer_unordered and causes OOM eventually.
There are great discussions in #984 about global vs local limits and more. From what I can see, it seems we all agree on the solution to call poll_ready in poll_flush so that it does the capacity check in every send call. The fix got merged into 0.1 in 4b0e217 and merged into 0.2 in 62827f1. But the latest 0.3 still has the issue. This PR is to fix that and also add tests to cover the back-pressure cases.

@0-o-0 0-o-0 force-pushed the fix-backpressure branch from 935b8ed to 9478770 Compare June 13, 2019 17:08
@0-o-0 0-o-0 force-pushed the fix-backpressure branch from 9478770 to d9d13ae Compare June 13, 2019 18:03
@cramertj
Copy link
Member

Thanks for the backport! Sorry this got missed.

@cramertj cramertj merged commit 46560aa into rust-lang:master Jun 13, 2019
@0-o-0
Copy link
Contributor Author

0-o-0 commented Jun 13, 2019

@cramertj I followed what you did in 62827f1, but I'm not very confident about the disconnection check in poll_flush because it might hide some real issues. What do you think?

@cramertj
Copy link
Member

That makes sense to me! The only alternative I see would be to return an error.

brunocodutra added a commit to brunocodutra/reducer that referenced this pull request Jul 25, 2019
according to the new global back-pressure of mpsc::Sender::send

rust-lang/futures-rs#1671
brunocodutra added a commit to brunocodutra/reducer that referenced this pull request Jul 31, 2019
according to the new global back-pressure of mpsc::Sender::send

rust-lang/futures-rs#1671
@kurnevsky
Copy link

Should the documentstion about channel's capacity be fixed or it's still correct?

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.

3 participants