Skip to content

Commit

Permalink
Prevent executor stalling during plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jul 3, 2024
1 parent db239f3 commit 8da255b
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions crates/subspace-farmer/src/plotter/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,26 +327,24 @@ where
let thread_pools = plotting_thread_pool_manager.get_thread_pools().await;

let plotting_fn = || {
tokio::task::block_in_place(|| {
let mut sector = Vec::new();

let plotted_sector = encode_sector::<PosTable>(
downloaded_sector,
EncodeSectorOptions {
sector_index,
erasure_coding: &erasure_coding,
pieces_in_sector,
sector_output: &mut sector,
table_generators: &mut (0..record_encoding_concurrency.get())
.map(|_| PosTable::generator())
.collect::<Vec<_>>(),
abort_early: &abort_early,
global_mutex: &global_mutex,
},
)?;

Ok((sector, plotted_sector))
})
let mut sector = Vec::new();

let plotted_sector = encode_sector::<PosTable>(
downloaded_sector,
EncodeSectorOptions {
sector_index,
erasure_coding: &erasure_coding,
pieces_in_sector,
sector_output: &mut sector,
table_generators: &mut (0..record_encoding_concurrency.get())
.map(|_| PosTable::generator())
.collect::<Vec<_>>(),
abort_early: &abort_early,
global_mutex: &global_mutex,
},
)?;

Ok((sector, plotted_sector))
};

let thread_pool = if replotting {
Expand All @@ -370,7 +368,8 @@ where

let encoding_start = Instant::now();

let plotting_result = thread_pool.install(plotting_fn);
let plotting_result =
tokio::task::block_in_place(|| thread_pool.install(plotting_fn));

match plotting_result {
Ok(plotting_result) => {
Expand Down

0 comments on commit 8da255b

Please sign in to comment.