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 |
thomaseizinger
left a comment
There was a problem hiding this comment.
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
NetworkBehaviourwill be able to make use of thepollfunction 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
thomaseizinger
left a comment
There was a problem hiding this comment.
Thanks! Some suggestions :)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@thomaseizinger Thanks! I've just added 2 unit tests for |
thomaseizinger
left a comment
There was a problem hiding this comment.
Great progress! I've added some more comments :)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
thomaseizinger
left a comment
There was a problem hiding this comment.
Great work! Two more comments :)
|
I pushed some follow-up commits, hope you don't mind :) |
thomaseizinger
left a comment
There was a problem hiding this comment.
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! |
mxinden
left a comment
There was a problem hiding this comment.
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:Behaviourto take a genericConnectionLimitstypeConnectionLimitstoStaticConnectionLimitsMemoryBasedConnectionLimitsNotes & open questions
Change checklist