Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upChannel refactor #985
Conversation
cramertj
requested a review
from
aturon
Apr 24, 2018
cramertj
reviewed
Apr 24, 2018
| @@ -401,7 +401,8 @@ fn stress_close_receiver_iter() { | |||
| Some(r) => assert!(i == r), | |||
| None => { | |||
| let unwritten = unwritten_rx.recv().expect("unwritten_rx"); | |||
| assert_eq!(unwritten, i); | |||
| assert!(unwritten <= i + 1); | |||
This comment has been minimized.
This comment has been minimized.
cramertj
Apr 24, 2018
Author
Collaborator
This is necessary in order to prevent this test from flaking due to the race condition when writing into a closed channel.
This comment has been minimized.
This comment has been minimized.
carllerche
Apr 24, 2018
Contributor
I assume that this is the race that you mentioned in gitter and you are punting on a fix? If so, could you add a TODO referencing the issue?
This comment has been minimized.
This comment has been minimized.
carllerche
Apr 24, 2018
Contributor
Skimming over it looks like the unbounded variant also has the same issue?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Could you explain the reasoning behind splitting up the unbounded & bounded implementations? |
This comment has been minimized.
This comment has been minimized.
|
It's a pretty large diff and hard for me to reason about due to how terminology changes are mixed with code and behavior changes. |
This comment has been minimized.
This comment has been minimized.
Sure! I thought it was clearer and easier to read with them split up this way, and seemed like it might be more performant since there are fewer queues, atomics, and other checks needed to supply simple receiver wakeups than the comparatively complex sender wakeup semantics. |
cramertj
force-pushed the
cramertj:channel-backpressure
branch
from
8fcfc9c
to
822061b
Apr 24, 2018
This comment has been minimized.
This comment has been minimized.
|
Before this PR:
After this PR:
|
This comment has been minimized.
This comment has been minimized.
|
The main argument against duplicating code is that it introduces more locations for bugs. For example, the close race bug is now duplicated in two code locations. I would suggest that, if performance is the driver, at the very least benchmarks illustrating the performance difference should be present and probably at least a basic tuning pass of the bounded mpsc should be done (given that none have been done to date). |
This comment has been minimized.
This comment has been minimized.
|
At the end of the day, you are the ones who have to maintain it, so feel free to do whatever. |
aturon
approved these changes
Apr 25, 2018
|
LGTM modulo nit. |
| } | ||
| }; | ||
| // Return the message | ||
| // Try to read a message off of the message queue. |
This comment has been minimized.
This comment has been minimized.
aturon
Apr 25, 2018
Collaborator
Seems worth factoring this out into its own method, since the code is repeated verbatim below.
cramertj commentedApr 24, 2018
Refactors channels to use "waker" terminology rather than "parking"
Splits unbounded channels into a separate, simplified underlying type
Calls poll_ready in poll_flush impl for bounded channels in order to
provide backpressure on ::send.
Replacement for #984.
Fix #800
Fix rustasync/team#11
cc @danburkert, @seanmonstar, @carllerche