-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Unify connection and endpoint drivers #1219
Conversation
33da0d5
to
7a12269
Compare
7a12269
to
cf9eb35
Compare
This could probably use some more iteration, but is now functionally complete. Next step is careful benchmarking. |
01d0a8c
to
79b49a4
Compare
16e1e43
to
589ec83
Compare
b4082d4
to
dffe9ba
Compare
a5e57e5
to
17fd83a
Compare
Is this still waiting for benchmarking? |
Initial results were inconclusive, with increases in ACK frames sent, presumed due to reduced internal buffering. I've therefore been waiting for @Matthias247 to finish his WIP delayed ACK support which should remove that variable. |
17fd83a
to
e80c499
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Makes sense; that's definitely a precious resource! I don't think this is blocking anything immediate; @rrichardson's interest in horizontal scaling as discussed in #914 can be pursued independently at the proto layer. |
👋 rust-libp2p maintainer here, Is there any way I could help move this pull request forward? Ways that come to my mind:
My motivation:
On a general note, thank you for all your work! With the release of QUIC support in rust-libp2p via
|
Is there any evidence that this particular usage of unbounded channels is bad? If you are so worried about this, feel free to submit a PR and we'll consider it. |
The remaining "unbounded" channel introduced in this PR, in fact, bounded by the number of concurrently active connections. It could be replaced with various other sorts of queue to make that more obvious (an intrusive list might be cool), but the behavior would be the same. |
@DemiMarie are you referring to the unbounded channel used by a connection to wake up the endpoint? /// `handle` is sent here when `wake` is called, prompting the endpoint to drive the connection
dirty: mpsc::UnboundedSender<ConnectionHandle>, I don't think this poses any issues. As @Ralith says above, they are bounded by the number of connections. I consider the usage a neat pattern of many-to-wake-one, transporting the id along the way.
In case I am not missing something and indeed we are talking about the In case one would want to ban the usage of unbounded channels across the codebase, one could also use a bounded channel. Given that the sender is cloned for each connection, there is a guaranteed slot per sender, thus always capacity to send, no
https://docs.rs/futures/latest/futures/channel/mpsc/fn.channel.html |
FWIW, clippy can help with this using its disallowed-methods = [
{ path = "futures::channel::mpsc::unbounded", reason = "does not enforce backpressure" },
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small review with small suggestion and question for better understanding.
quinn/src/endpoint.rs
Outdated
// Buffer the list of initially dirty connections, guaranteeing that the connection | ||
// processing loop below takes a predictable amount of time. | ||
while let Poll::Ready(Some(conn_handle)) = self.dirty_recv.poll_recv(cx) { | ||
self.dirty_buffer.push(conn_handle); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that the assumption here is that self.dirty_recv.poll_recv
may fill up faster than the Endpoint
can drive the connection below, thus leading to an endless loop without the here introduced self.dirty_push
intermediary step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, exactly. This initial loop is safe because it doesn't reset is_dirty
.
@mxinden thanks for the careful review! |
Tweaked per @mxinden's feedback (thanks!) and rebased. |
Hey 👋 We're using quinn in iroh. I've run some quick benchmarks with a branch propped up to use this PR. I've noticed a significant drop in throughput (40-50%) when serving data from one node to 2 or more clients. One to one transfers don't seem significantly impacted yet (most probably because other parts of our code don't saturate the pipe). From my observations with the PR the CPU on my test rig seems to peg to around 220% ie 2.2 cores and more clients just keep diluting the throughput between them. The same test when running against Didn't dive too deep into it yet, but my initial guess would be that we have either some mutex locking or polling happening that makes some run loop starve itself. Let me know if there's anything specific you would like me to poke at or test out. |
Interesting, thank you for the report! We should try to understand that, and hopefully mitigate, before merging this. I do think this is an important foundation for an ultimately much more parallel quinn, but undermining our present scalability for a hypothetical future isn't ideal. |
Closing as this is quite stale and understood to be a suboptimal direction due to reduced opportunity for work stealing and parallelism. |
Fixes #914. This is a high-risk change, so we probably don't want it in 0.8, but I'm getting a head start on it all the same.