-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(kad): Limit number of active outbound streams #3287
feat(kad): Limit number of active outbound streams #3287
Conversation
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.
👍
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.
lgtm
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.
Thanks for looking into this @nazar-pc!
Note that in my opinion we should get rid of the manually written state machines long-term in |
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.
Simplified implementation a bit based on review comments
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.
LGTM
A few minor suggestions but not blocking!
Thanks, this is good to merge from my end. We will have to wait until the interoperability tests are fixed. See libp2p/test-plans#99 (comment). |
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.
Wonderful. This looks good to me. Thanks for the work. Thanks for the follow-ups.
Next step would be to propagate backpressure to the NetworkBehaviour
implementation. Let me know in case you are interested in implementing that. I would expect this patch alone to suffice for the issues (#3236) you are facing.
Approvals have been dismissed because the PR was updated after the send-it
label was applied.
Once #3331 is merged we can proceed here. |
On our small testnet results are very promising so far |
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.
Let's go!
@Mergifyio refresh |
✅ Pull request refreshed |
Seems like Mergify is stuck on the initial failure on the interoperability tests. They are green on the second run. Will merge |
Approvals have been dismissed because the PR was updated after the send-it
label was applied.
Description
Limit number of active outbound streams to not exceed configured number of streams.
Resolves #3236.
Notes
The approach taken here restricts number of active outbound substreams and all extra are put into the queue.
Since some outbounds streams might not actually exist in the handler temporarily if request for outbound stream was issued, a separate variable is used to keep track of those as well.
As the result we maintain a bounded number of outbound streams that matches the limit for inbound streams on the other side.
Links to any relevant issues
#3235
#3236
Open Questions
Not entirely sure how to test higher-level behavior here as I'm new to the codebase, though changes are somewhat straightforward.
Also there is no support for cancelling of outbound streams, though it didn't seem to be possible before either, so reasonable timeouts before retries are your friends.
Change checklist