From dca983b757a2136f804604ef23e3196f7865abf1 Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Mon, 28 Oct 2024 16:11:33 -0500 Subject: [PATCH] Experiment: removing shrink_to_fit calls to avoid reallocation. --- .../flow_data/flow_analysis/finished_flows.rs | 1 - .../flow_data/flow_analysis/kernel_ringbuffer.rs | 1 - src/rust/lqosd/src/throughput_tracker/tracking_data.rs | 3 --- src/rust/lts_client/src/collector/collation/mod.rs | 1 - src/rust/lts_client/src/submission_queue/queue.rs | 1 - 5 files changed, 7 deletions(-) diff --git a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs index a8803887..2aa8a489 100644 --- a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs +++ b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/finished_flows.rs @@ -60,7 +60,6 @@ impl TimeBuffer { let one_minute_ago = now - 60; let mut buffer = self.buffer.lock().unwrap(); buffer.retain(|v| v.time > one_minute_ago); - buffer.shrink_to_fit(); } } diff --git a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/kernel_ringbuffer.rs b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/kernel_ringbuffer.rs index 388531ad..ed9ca2ee 100644 --- a/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/kernel_ringbuffer.rs +++ b/src/rust/lqosd/src/throughput_tracker/flow_data/flow_analysis/kernel_ringbuffer.rs @@ -164,7 +164,6 @@ impl FlowActor { let since_boot = Duration::from(now); let expire = (since_boot - Duration::from_secs(30)).as_nanos() as u64; flows.flow_rtt.retain(|_, v| v.last_seen > expire); - flows.flow_rtt.shrink_to_fit(); } } Ok(FlowCommands::RttMap(reply)) => { diff --git a/src/rust/lqosd/src/throughput_tracker/tracking_data.rs b/src/rust/lqosd/src/throughput_tracker/tracking_data.rs index dab784ad..b8825483 100644 --- a/src/rust/lqosd/src/throughput_tracker/tracking_data.rs +++ b/src/rust/lqosd/src/throughput_tracker/tracking_data.rs @@ -344,7 +344,6 @@ impl ThroughputTracker { let _ = sender.send((key.clone(), (d.0.clone(), d.1.clone()))); } } - all_flows_lock.shrink_to_fit(); let ret = lqos_sys::end_flows(expired_keys); if let Err(e) = ret { @@ -355,7 +354,6 @@ impl ThroughputTracker { // Cleaning run all_flows_lock.retain(|_k,v| v.0.last_seen >= expire); expire_rtt_flows(); - self.raw_data.shrink_to_fit(); } } @@ -405,7 +403,6 @@ impl ThroughputTracker { pub(crate) fn next_cycle(&self) { self.cycle.fetch_add(1, std::sync::atomic::Ordering::Relaxed); - self.raw_data.shrink_to_fit(); } pub(crate) fn bits_per_second(&self) -> DownUpOrder { diff --git a/src/rust/lts_client/src/collector/collation/mod.rs b/src/rust/lts_client/src/collector/collation/mod.rs index d02ba6df..5d5978e1 100644 --- a/src/rust/lts_client/src/collector/collation/mod.rs +++ b/src/rust/lts_client/src/collector/collation/mod.rs @@ -144,5 +144,4 @@ pub(crate) async fn collate_stats(comm_tx: Sender) { // Clear the collection buffer writer.clear(); - writer.shrink_to_fit(); } diff --git a/src/rust/lts_client/src/submission_queue/queue.rs b/src/rust/lts_client/src/submission_queue/queue.rs index 21c2ffae..738f429f 100644 --- a/src/rust/lts_client/src/submission_queue/queue.rs +++ b/src/rust/lts_client/src/submission_queue/queue.rs @@ -98,7 +98,6 @@ pub(crate) async fn send_queue(stream: &mut TcpStream) -> Result<(), QueueError> } lock.clear(); - lock.shrink_to_fit(); Ok(()) }