Skip to content
Discussion options

You must be logged in to vote

Part of your hypothesis is right and part isn't, and the part that isn't matters for choosing the fix. Short version: try_recv does bypass coop, but a 256-item try_recv loop is microseconds of work and can't by itself produce 10–50ms stalls. The LIFO slot is a plausible culprit, but not through the mechanism you describe. And there's a third candidate you haven't ruled out: backpressure on the bounded channel itself.

1. try_recv() and the coop budget

Yes, it bypasses coop. The async path goes through Chan::recv(cx), which starts with:

// tokio/src/sync/mpsc/chan.rs (abridged)
let coop = ready!(crate::runtime::coop::poll_proceed(cx));
// ... pop a value ...
coop.made_progress();

try_recv() …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@skr-0305
Comment options

Comment options

You must be logged in to vote
1 reply
@skr-0305
Comment options

Answer selected by skr-0305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants