From ce032cbed76d978e18118d891357f194525b52b1 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Tue, 26 Nov 2024 16:55:20 +0200 Subject: [PATCH 1/2] Improve cluster plotting GPU utilization --- crates/subspace-farmer/src/cluster/plotter.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/subspace-farmer/src/cluster/plotter.rs b/crates/subspace-farmer/src/cluster/plotter.rs index 5398e827f0..6feb812efa 100644 --- a/crates/subspace-farmer/src/cluster/plotter.rs +++ b/crates/subspace-farmer/src/cluster/plotter.rs @@ -31,6 +31,7 @@ use std::time::{Duration, Instant}; use subspace_core_primitives::sectors::SectorIndex; use subspace_core_primitives::PublicKey; use subspace_farmer_components::plotting::PlottedSector; +use subspace_farmer_components::sector::sector_size; use subspace_farmer_components::FarmerProtocolInfo; use tokio::sync::{OwnedSemaphorePermit, Semaphore}; use tokio::time::MissedTickBehavior; @@ -380,7 +381,11 @@ impl ClusterPlotter { } }; - let (mut sector_sender, sector_receiver) = mpsc::channel(1); + // Allow to buffer up to the whole sector in memory to not block plotter on the + // other side + let (mut sector_sender, sector_receiver) = mpsc::channel( + sector_size(pieces_in_sector) / nats_client.approximate_max_message_size(), + ); let mut maybe_sector_receiver = Some(sector_receiver); loop { match tokio::time::timeout(PING_TIMEOUT, response_stream.next()).await { From 4728e4b6cd490ef28d4e498f697a6412fb182456 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Wed, 27 Nov 2024 08:24:49 +0200 Subject: [PATCH 2/2] Ensure channel has a buffer in it --- crates/subspace-farmer/src/cluster/plotter.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/subspace-farmer/src/cluster/plotter.rs b/crates/subspace-farmer/src/cluster/plotter.rs index 6feb812efa..4d67819ed5 100644 --- a/crates/subspace-farmer/src/cluster/plotter.rs +++ b/crates/subspace-farmer/src/cluster/plotter.rs @@ -384,7 +384,8 @@ impl ClusterPlotter { // Allow to buffer up to the whole sector in memory to not block plotter on the // other side let (mut sector_sender, sector_receiver) = mpsc::channel( - sector_size(pieces_in_sector) / nats_client.approximate_max_message_size(), + (sector_size(pieces_in_sector) / nats_client.approximate_max_message_size()) + .max(1), ); let mut maybe_sector_receiver = Some(sector_receiver); loop {