-
Notifications
You must be signed in to change notification settings - Fork 984
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: memory based connection limits #4281
feat: memory based connection limits #4281
Conversation
Thank you for testing this out right-away @hanabi1224. Let me know once you would like a review. |
@mxinden It will be great if you can take a quick look and let me know if it's on the right path. The code is done, while docs and tests are still missing |
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 contribution!
I'd like to discuss whether we should extend the existing libp2p-connection-limits
here or create a new crate: libp2p-memory-connection-limits
.
I think there a several arguments for a new crate:
- It means that we have more design freedom in regards to the API and can still release it as a patch-release because it is just additions.
- There isn't actually any shared code between those two. For example, the memory limits don't care about the connection kind at all. Tthe "put together what changes together" mantra also suggests that this should be separate.
- A dedicated
NetworkBehaviour
will be able to make use of thepoll
function to register a timer for refreshing the memory stats. Alternatively, we could simply refresh them on every connection attempt (how expensive is gathering those stats?)
@thomaseizinger Thanks for your feedback, I can make it a new crate. |
Explicitly set `libp2p-kad` `Kademlia::set_mode` to `Mode::Server` to reduce complexity of example, i.e. not having to explicitly set external addresses. Pull-Request: libp2p#4197.
`OutboundQueryCompleted` hasn't been fully replaced by `OutboundQueryProgressed` in kad doc. Pull-Request: libp2p#4257.
`libp2p-relay` crate specifies the `libp2p-swarm/async-std` feature, which causes an `async-std` dependency to always be introduced. Pull-Request: libp2p#4283.
Pull-Request: libp2p#3013.
Pull-Request: libp2p#4288.
move
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! Some suggestions :)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@thomaseizinger Thanks! I've just added 2 unit tests for |
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.
Great progress! I've added some more comments :)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
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.
Great work! Two more comments :)
I pushed some follow-up commits, hope you don't mind :) |
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.
This is ready from my PoV but I've also pushed some commits to this so I'll defer to @mxinden for a final review :)
One more thing: We should add this to the |
Done! |
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 working on this @hanabi1224 and @thomaseizinger!
Approvals have been dismissed because the PR was updated after the send-it
label was applied.
@hanabi1224 No need to manually update the PR once it is queued (i.e. |
Description
Implements memory-based connection limits where the user can specify an absolute or a relative limit of the process' memory usage in relation to the available system memory.
Related: #4252.
TODO list:
connection_limits:Behaviour
to take a genericConnectionLimits
typeConnectionLimits
toStaticConnectionLimits
MemoryBasedConnectionLimits
Notes & open questions
Change checklist