From 4dec0b2c624fbbd54d8ef7a2e8457be5c359b3a5 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Mon, 21 Oct 2024 19:21:56 +0100 Subject: [PATCH] chore: reduce max records cache size Using a larger chunk size resulted in the node having a larger memory footprint due to the size of the records cache. --- sn_networking/src/record_store.rs | 2 +- sn_node/src/bin/safenode/main.rs | 8 ++++++-- sn_node/src/bin/safenode/rpc_service.rs | 9 ++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sn_networking/src/record_store.rs b/sn_networking/src/record_store.rs index 599dee835b..ee4e413c5e 100644 --- a/sn_networking/src/record_store.rs +++ b/sn_networking/src/record_store.rs @@ -57,7 +57,7 @@ use xor_name::XorName; const MAX_RECORDS_COUNT: usize = 16 * 1024; /// The maximum number of records to cache in memory. -const MAX_RECORDS_CACHE_SIZE: usize = 100; +const MAX_RECORDS_CACHE_SIZE: usize = 25; /// File name of the recorded historical quoting metrics. const HISTORICAL_QUOTING_METRICS_FILENAME: &str = "historic_quoting_metrics"; diff --git a/sn_node/src/bin/safenode/main.rs b/sn_node/src/bin/safenode/main.rs index dd328b14b2..1b18429e89 100644 --- a/sn_node/src/bin/safenode/main.rs +++ b/sn_node/src/bin/safenode/main.rs @@ -24,7 +24,9 @@ use sn_logging::{Level, LogFormat, LogOutputDest, ReloadHandle}; use sn_node::{Marker, NodeBuilder, NodeEvent, NodeEventsReceiver}; use sn_peers_acquisition::PeersArgs; use sn_protocol::{ - node::get_safenode_root_dir, node_rpc::{NodeCtrl, StopResult}, version::IDENTIFY_PROTOCOL_STR, + node::get_safenode_root_dir, + node_rpc::{NodeCtrl, StopResult}, + version::IDENTIFY_PROTOCOL_STR, }; use std::{ env, @@ -530,7 +532,9 @@ fn monitor_node_events(mut node_events_rx: NodeEventsReceiver, ctrl_tx: mpsc::Se }) .await { - error!("Failed to send node control msg to safenode bin main thread: {err}"); + error!( + "Failed to send node control msg to safenode bin main thread: {err}" + ); break; } } diff --git a/sn_node/src/bin/safenode/rpc_service.rs b/sn_node/src/bin/safenode/rpc_service.rs index eef388b2d5..8d16ba8f3d 100644 --- a/sn_node/src/bin/safenode/rpc_service.rs +++ b/sn_node/src/bin/safenode/rpc_service.rs @@ -202,7 +202,14 @@ impl SafeNode for SafeNodeRpcService { }; let delay = Duration::from_millis(request.get_ref().delay_millis); - match self.ctrl_tx.send(NodeCtrl::Stop { delay, result: StopResult::Success(cause.to_string()) }).await { + match self + .ctrl_tx + .send(NodeCtrl::Stop { + delay, + result: StopResult::Success(cause.to_string()), + }) + .await + { Ok(()) => Ok(Response::new(StopResponse {})), Err(err) => Err(Status::new( Code::Internal,