Skip to content
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

Merged
merged 41 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
90cd7d6
feat: memory based connection limits
hanabi1224 Aug 1, 2023
5014500
sets system ram
hanabi1224 Aug 1, 2023
e5519d7
code golf
hanabi1224 Aug 1, 2023
024da42
fix(examples/file-sharing): set Kademlia `Mode::Server`
mxinden Aug 1, 2023
065efb1
docs: fix last OutboundQueryCompleted in kad doc
thomas-senechal Aug 2, 2023
2a8e371
fix(relay): remove unconditional `async-std` dependency
quininer Aug 2, 2023
94dc11b
deps(yamux): update yamux to `v0.12`
thomaseizinger Aug 2, 2023
51a91b7
deps: bump Swatinem/rust-cache from 2.5.1 to 2.6.0
dependabot[bot] Aug 3, 2023
6581822
move to new crate
hanabi1224 Aug 3, 2023
1106ad7
Merge remote-tracking branch 'origin/master' into memory-based-connec…
hanabi1224 Aug 3, 2023
6066b2e
doc
hanabi1224 Aug 3, 2023
1fa32f0
lock
hanabi1224 Aug 3, 2023
05cbf5e
doc and tests
hanabi1224 Aug 3, 2023
e308be7
Merge branch 'master' into memory-based-connection-limits
hanabi1224 Aug 3, 2023
7d05ee5
Apply suggestions from code review
hanabi1224 Aug 3, 2023
9ba799e
hide MemoryUsageBasedConnectionLimits
hanabi1224 Aug 3, 2023
b8a9916
update MemoryUsageLimitExceeded fmt as suggested
hanabi1224 Aug 3, 2023
f43fed5
fix clippy
hanabi1224 Aug 3, 2023
9a66866
fix rustdoc
hanabi1224 Aug 3, 2023
7990be6
Update misc/memory-connection-limits/src/lib.rs
hanabi1224 Aug 4, 2023
07e30bb
resolve comments
hanabi1224 Aug 4, 2023
6adf21f
Make MemoryUsageLimitExceeded fields private
hanabi1224 Aug 4, 2023
a720f64
Merge branch 'master' into memory-based-connection-limits
hanabi1224 Aug 7, 2023
803d8f5
Pre-calculate max_allowed_bytes
hanabi1224 Aug 7, 2023
f60cfb0
refresh interval
hanabi1224 Aug 7, 2023
259f038
Don't use `update` functions in tests
thomaseizinger Aug 7, 2023
c5e103c
Remove inner `Option`
thomaseizinger Aug 7, 2023
5c63b87
Don't make refresh interval configurable
thomaseizinger Aug 7, 2023
dee261c
Update docs
thomaseizinger Aug 7, 2023
1b7fb24
Remove refresh-interval field
thomaseizinger Aug 7, 2023
280d13a
Use early return to reduce indentation
thomaseizinger Aug 7, 2023
aadad16
Only set timestamp if we actually refreshed the data
thomaseizinger Aug 7, 2023
2875817
Use early return instead of else
thomaseizinger Aug 7, 2023
800d501
Make tests for stable
hanabi1224 Aug 7, 2023
7331b8f
Add docs to constant
thomaseizinger Aug 7, 2023
a1d0b55
Sort functions are per trait definition
thomaseizinger Aug 7, 2023
9da8e1e
Merge branch 'memory-connection-limits-thomas' into memory-based-conn…
thomaseizinger Aug 7, 2023
b24fb86
Re-export from libp2p meta crate
hanabi1224 Aug 7, 2023
14f0866
Merge branch 'master' into memory-based-connection-limits
hanabi1224 Aug 7, 2023
9eeee38
Update libp2p/CHANGELOG.md
thomaseizinger Aug 7, 2023
13f09a8
Merge branch 'master' into memory-based-connection-limits
hanabi1224 Aug 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"misc/allow-block-list",
"misc/connection-limits",
"misc/keygen",
"misc/memory-connection-limits",
"misc/metrics",
"misc/multistream-select",
"misc/quick-protobuf-codec",
Expand Down Expand Up @@ -75,6 +76,7 @@ libp2p-identify = { version = "0.43.0", path = "protocols/identify" }
libp2p-identity = { version = "0.2.2" }
libp2p-kad = { version = "0.44.4", path = "protocols/kad" }
libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
libp2p-memory-connection-limits = { version = "0.1.0", path = "misc/memory-connection-limits" }
libp2p-metrics = { version = "0.13.1", path = "misc/metrics" }
libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" }
libp2p-muxer-test-harness = { path = "muxers/test-harness" }
Expand Down
4 changes: 4 additions & 0 deletions libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
- Add `json` feature which exposes `request_response::json`.
See [PR 4188].

- Add `libp2p-memory-connection-limits` providing memory usage based connection limit configurations.
See [PR 4281].

[PR 4188]: https://github.com/libp2p/rust-libp2p/pull/4188
[PR 4217]: https://github.com/libp2p/rust-libp2p/pull/4217
[PR 4281]: https://github.com/libp2p/rust-libp2p/pull/4281

## 0.52.1

Expand Down
3 changes: 3 additions & 0 deletions libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ full = [
"kad",
"macros",
"mdns",
"memory-connection-limits",
"metrics",
"noise",
"ping",
Expand Down Expand Up @@ -65,6 +66,7 @@ json = ["libp2p-request-response?/json"]
kad = ["dep:libp2p-kad", "libp2p-metrics?/kad"]
macros = ["libp2p-swarm/macros"]
mdns = ["dep:libp2p-mdns"]
memory-connection-limits = ["dep:libp2p-memory-connection-limits"]
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
metrics = ["dep:libp2p-metrics"]
noise = ["dep:libp2p-noise"]
ping = ["dep:libp2p-ping", "libp2p-metrics?/ping"]
Expand Down Expand Up @@ -124,6 +126,7 @@ pin-project = "1.0.0"
libp2p-deflate = { workspace = true, optional = true }
libp2p-dns = { workspace = true, optional = true }
libp2p-mdns = { workspace = true, optional = true }
libp2p-memory-connection-limits = { workspace = true, optional = true }
libp2p-tcp = { workspace = true, optional = true }
libp2p-tls = { workspace = true, optional = true }
libp2p-uds = { workspace = true, optional = true }
Expand Down
5 changes: 5 additions & 0 deletions libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ pub use libp2p_kad as kad;
#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
#[doc(inline)]
pub use libp2p_mdns as mdns;
#[cfg(feature = "memory-connection-limits")]
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(docsrs, doc(cfg(feature = "memory-connection-limits")))]
#[doc(inline)]
pub use libp2p_memory_connection_limits as memory_connection_limits;
#[cfg(feature = "metrics")]
#[doc(inline)]
pub use libp2p_metrics as metrics;
Expand Down
3 changes: 3 additions & 0 deletions misc/memory-connection-limits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1.0 - unreleased

- Initial release.
26 changes: 26 additions & 0 deletions misc/memory-connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "libp2p-memory-connection-limits"
edition = "2021"
rust-version = { workspace = true }
description = "Memory usage based connection limits for libp2p."
version = "0.1.0"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[dependencies]
memory-stats = { version = "1", features = ["always_use_statm"] }
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true, features = ["peerid"] }
log = "0.4"
sysinfo = "0.29"
void = "1"

[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }
libp2p-identify = { workspace = true }
libp2p-swarm-derive = { path = "../../swarm-derive" }
libp2p-swarm-test = { path = "../../swarm-test" }
rand = "0.8.5"
Loading