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

deps: bump sysinfo from 0.29.11 to 0.30.5 #5061

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 28 additions & 21 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion misc/memory-connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ memory-stats = { version = "1", features = ["always_use_statm"] }
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true, features = ["peerid"] }
sysinfo = "0.29"
sysinfo = "0.30"
tracing = { workspace = true }
void = "1"

Expand Down
9 changes: 6 additions & 3 deletions misc/memory-connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::{
task::{Context, Poll},
time::{Duration, Instant},
};
use sysinfo::MemoryRefreshKind;

/// A [`NetworkBehaviour`] that enforces a set of memory usage based limits.
///
Expand Down Expand Up @@ -90,10 +91,12 @@ impl Behaviour {
///
/// New inbound and outbound connections will be denied when the threshold is reached.
pub fn with_max_percentage(percentage: f64) -> Self {
use sysinfo::{RefreshKind, SystemExt};
use sysinfo::{RefreshKind, System};

let system_memory_bytes =
sysinfo::System::new_with_specifics(RefreshKind::new().with_memory()).total_memory();
let system_memory_bytes = System::new_with_specifics(
RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()),
)
.total_memory();

Self::with_max_bytes((system_memory_bytes as f64 * percentage).round() as usize)
}
Expand Down
6 changes: 4 additions & 2 deletions misc/memory-connection-limits/tests/max_percentage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use libp2p_core::Multiaddr;
use libp2p_identity::PeerId;
use libp2p_memory_connection_limits::*;
use std::time::Duration;
use sysinfo::{RefreshKind, SystemExt};
use sysinfo::{MemoryRefreshKind, RefreshKind};
use util::*;

use libp2p_swarm::{
Expand All @@ -36,7 +36,9 @@ use libp2p_swarm_test::SwarmExt;
#[test]
fn max_percentage() {
const CONNECTION_LIMIT: usize = 20;
let system_info = sysinfo::System::new_with_specifics(RefreshKind::new().with_memory());
let system_info = sysinfo::System::new_with_specifics(
RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()),
);

let mut network = Swarm::new_ephemeral(|_| TestBehaviour {
connection_limits: Behaviour::with_max_percentage(0.1),
Expand Down
Loading