From e3eb3b2659e0849bbdad099abcd5e2cfee697731 Mon Sep 17 00:00:00 2001 From: qima Date: Thu, 28 Nov 2024 05:28:32 +0800 Subject: [PATCH] chore(node): tuning range based search performance --- sn_networking/src/event/swarm.rs | 2 +- sn_node/src/node.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sn_networking/src/event/swarm.rs b/sn_networking/src/event/swarm.rs index bffdfa425d..e0db094c7a 100644 --- a/sn_networking/src/event/swarm.rs +++ b/sn_networking/src/event/swarm.rs @@ -612,7 +612,7 @@ impl SwarmDriver { // Optionally force remove all the connections for a provided peer. fn remove_outdated_connections(&mut self) { // To avoid this being called too frequenctly, only carry out prunning intervally. - if Instant::now() > self.last_connection_pruning_time + Duration::from_secs(30) { + if Instant::now() < self.last_connection_pruning_time + Duration::from_secs(30) { return; } self.last_connection_pruning_time = Instant::now(); diff --git a/sn_node/src/node.rs b/sn_node/src/node.rs index e73fcde56f..37c90e325d 100644 --- a/sn_node/src/node.rs +++ b/sn_node/src/node.rs @@ -73,7 +73,7 @@ const TIME_STEP: usize = 20; /// Interval to carryout network density sampling /// This is the max time it should take. Minimum interval at any node will be half this -const NETWORK_DENSITY_SAMPLING_INTERVAL_MAX_S: u64 = 180; +const NETWORK_DENSITY_SAMPLING_INTERVAL_MAX_S: u64 = 200; /// Helper to build and run a Node pub struct NodeBuilder { @@ -863,6 +863,8 @@ impl Node { network.add_network_density_sample(distance); } } + // Sleep a short while to avoid causing a spike on resource usage. + std::thread::sleep(std::time::Duration::from_secs(10)); } } }