-
Notifications
You must be signed in to change notification settings - Fork 964
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(swarm): allow configuration to idle connection timeout #4161
feat(swarm): allow configuration to idle connection timeout #4161
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.
Thanks! Looks like a good start!
I'd like us to use this directly in libp2p-swarm-test
and see which tests we can remove keep_alive::Behaviour
from, should be all of them but maybe something else turns up!
a0a5d44
to
073cee1
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Sure! So the context is that with the current code, a connection will be immediately shut down as soon as a In many tests, we only use a single With this new feature, we can delay that shutdown which in turn allows us to remove I'd take the following approach:
Does that make sense? You can try yourself on one or two tests and then push a commit and we can look at it together :) |
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.
Thank you for the help here.
I still wan't to work on this however I am busy in some other work so if anyone wanna take this he can. |
Thank you! No pressure from our end, your help is much appreciated :) |
@startup-dreamer I've pushed some commits that should help move this forward. In particular, I've added the deprecation attribute and converted the first test. Most of the others should be similar :) |
graet help sir will try to move forward from here. |
This comment was marked as outdated.
This comment was marked as outdated.
This pull request has merge conflicts. Could you please resolve them @startup-dreamer? 🙏 |
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.
Looks good so far :)
Looks good so far, you are on the right track :) |
27f2345
to
f91d242
Compare
@mxinden I spent some cycles on this to push it over the finish line as there wasn't much missing. Please review! |
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.
One comment, otherwise this looks good to me.
Let's have this run on am6-rust
(IPFS bootstrap node staging server) once merged into master before cutting a release. Will be deployed automatically via our nightly job once merged.
With or without setting a custom timeout? |
This pull request has merge conflicts. Could you please resolve them @startup-dreamer? 🙏 |
I suggest without, to validate that the status-quo doesn't change. |
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.
Cool. Thank you for the tests!
@thomaseizinger can you address the CI failures? Otherwise this is ready to merge from my side. |
Done! I'll send it then :) |
Previously, a connection would be shut down immediately as soon as its `ConnectionHandler` reports `KeepAlive::No`. As we have gained experience with libp2p, it turned out that this isn't ideal. For one, tests often need to keep connections alive longer than the configured protocols require. Plus, some usecases require connections to be kept alive in general. Both of these needs are currently served by the `keep_alive::Behaviour`. That one does essentially nothing other than statically returning `KeepAlive::Yes` from its `ConnectionHandler`. It makes much more sense to deprecate `keep_alive::Behaviour` and instead allow users to globally configure an `idle_conncetion_timeout` on the `Swarm`. This timeout comes into effect once a `ConnectionHandler` reports `KeepAlive::No`. To start with, this timeout is 0. Together with libp2p#3844, this will allow us to move towards a much more aggressive closing of idle connections, together with a more ergonomic way of opting out of this behaviour. Fixes libp2p#4121. Pull-Request: libp2p#4161.
Previously, a connection would be shut down immediately as soon as its `ConnectionHandler` reports `KeepAlive::No`. As we have gained experience with libp2p, it turned out that this isn't ideal. For one, tests often need to keep connections alive longer than the configured protocols require. Plus, some usecases require connections to be kept alive in general. Both of these needs are currently served by the `keep_alive::Behaviour`. That one does essentially nothing other than statically returning `KeepAlive::Yes` from its `ConnectionHandler`. It makes much more sense to deprecate `keep_alive::Behaviour` and instead allow users to globally configure an `idle_conncetion_timeout` on the `Swarm`. This timeout comes into effect once a `ConnectionHandler` reports `KeepAlive::No`. To start with, this timeout is 0. Together with #3844, this will allow us to move towards a much more aggressive closing of idle connections, together with a more ergonomic way of opting out of this behaviour. Fixes #4121. Pull-Request: #4161.
Description
Previously, a connection would be shut down immediately as soon as its
ConnectionHandler
reportsKeepAlive::No
. As we have gained experience with libp2p, it turned out that this isn't ideal.For one, tests often need to keep connections alive longer than the configured protocols require. Plus, some usecases require connections to be kept alive in general.
Both of these needs are currently served by the
keep_alive::Behaviour
. That one does essentially nothing other than statically returningKeepAlive::Yes
from itsConnectionHandler
.It makes much more sense to deprecate
keep_alive::Behaviour
and instead allow users to globally configure anidle_conncetion_timeout
on theSwarm
. This timeout comes into effect once aConnectionHandler
reportsKeepAlive::No
. To start with, this timeout is 0. Together with #3844, this will allow us to move towards a much more aggressive closing of idle connections, together with a more ergonomic way of opting out of this behaviour.Fixes #4121.
Notes & open questions
am I in the right direction also we might add tests for this feature.Change checklist