Skip to content

Commit

Permalink
Merge pull request #2889 from subspace/prevent-executor-stalling-duri…
Browse files Browse the repository at this point in the history
…ng-plotting

Prevent executor stalling during plotting
  • Loading branch information
nazar-pc authored Jul 3, 2024
2 parents 0d990c2 + 8a14453 commit 95b4183
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tempfile::tempdir;
const FAKE_SECTOR_SIZE: usize = 2 * 1024 * 1024;
const TARGET_SECTOR_COUNT: SectorIndex = 5;

#[tokio::test]
#[tokio::test(flavor = "multi_thread")]
async fn basic() {
let dummy_sector_metadata = SectorMetadataChecksummed::from(SectorMetadata {
sector_index: 0,
Expand Down

0 comments on commit 95b4183

Please sign in to comment.