From 0b7738a9eb977be1c5f1478e0ea3b0fcfacfcff8 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 10 Mar 2024 07:43:41 +0200 Subject: [PATCH] Debug Windows --- .../subspace-farmer/src/single_disk_farm.rs | 91 ++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/crates/subspace-farmer/src/single_disk_farm.rs b/crates/subspace-farmer/src/single_disk_farm.rs index b014b13c961..f7bdaca43cc 100644 --- a/crates/subspace-farmer/src/single_disk_farm.rs +++ b/crates/subspace-farmer/src/single_disk_farm.rs @@ -1090,6 +1090,7 @@ impl SingleDiskFarm { .spawn_handler(tokio_rayon_spawn_handler()) .build() .map_err(SingleDiskFarmError::FailedToCreateThreadPool)?; + println!("Testing unbuffered"); let farming_plot = farming_thread_pool.install(|| { #[cfg(windows)] { @@ -1115,6 +1116,90 @@ impl SingleDiskFarm { faster_read_sector_record_chunks_mode(&*plot_file, &farming_plot, sector_size) })? }; + if cfg!(windows) { + farming_thread_pool.install(|| { + let plot_audit = PlotAudit::new(&farming_plot); + { + let options = farming::PlotAuditOptions:: { + public_key: &public_key, + reward_address: &reward_address, + slot_info: subspace_rpc_primitives::SlotInfo { + slot_number: 0, + global_challenge: rand::random(), + // Solution is guaranteed to be found + solution_range: subspace_core_primitives::SolutionRange::MAX, + // Solution is guaranteed to be found + voting_solution_range: subspace_core_primitives::SolutionRange::MAX, + }, + sectors_metadata: §ors_metadata.read_blocking(), + kzg: &kzg, + erasure_coding: &erasure_coding, + maybe_sector_being_modified: None, + read_sector_record_chunks_mode, + table_generator: &Mutex::new(PosTable::generator()), + }; + + let mut audit_results = plot_audit.audit(options).unwrap(); + let start = std::time::Instant::now(); + audit_results.pop().unwrap().1.next(); + println!("Proved in {:?}", start.elapsed()); + } + }); + } + println!("Testing regular"); + let farming_plot = farming_thread_pool.install(|| { + // #[cfg(windows)] + // { + // RayonFiles::open_with( + // &directory.join(Self::PLOT_FILE), + // UnbufferedIoFileWindows::open, + // ) + // } + // #[cfg(not(windows))] + { + RayonFiles::open(&directory.join(Self::PLOT_FILE)) + } + })?; + + let read_sector_record_chunks_mode = { + // Error doesn't matter here + let _permit = faster_read_sector_record_chunks_mode_concurrency + .acquire() + .await; + farming_thread_pool.install(|| { + faster_read_sector_record_chunks_mode(&*plot_file, &farming_plot, sector_size) + })? + }; + if cfg!(windows) { + farming_thread_pool.install(|| { + let plot_audit = PlotAudit::new(&farming_plot); + { + let options = farming::PlotAuditOptions:: { + public_key: &public_key, + reward_address: &reward_address, + slot_info: subspace_rpc_primitives::SlotInfo { + slot_number: 0, + global_challenge: rand::random(), + // Solution is guaranteed to be found + solution_range: subspace_core_primitives::SolutionRange::MAX, + // Solution is guaranteed to be found + voting_solution_range: subspace_core_primitives::SolutionRange::MAX, + }, + sectors_metadata: §ors_metadata.read_blocking(), + kzg: &kzg, + erasure_coding: &erasure_coding, + maybe_sector_being_modified: None, + read_sector_record_chunks_mode, + table_generator: &Mutex::new(PosTable::generator()), + }; + + let mut audit_results = plot_audit.audit(options).unwrap(); + let start = std::time::Instant::now(); + audit_results.pop().unwrap().1.next(); + println!("Proved in {:?}", start.elapsed()); + } + }); + } let farming_join_handle = tokio::task::spawn_blocking({ let erasure_coding = erasure_coding.clone(); @@ -2110,6 +2195,8 @@ where })?; let elapsed = start.elapsed(); + println!("Chunks in {elapsed:?}"); + if fastest_time > elapsed { fastest_mode = ReadSectorRecordChunksMode::ConcurrentChunks; fastest_time = elapsed; @@ -2121,6 +2208,8 @@ where farming_plot.read_at(&mut sector_bytes, 0)?; let elapsed = start.elapsed(); + println!("Whole sector in {elapsed:?}"); + if fastest_time > elapsed { fastest_mode = ReadSectorRecordChunksMode::WholeSector; fastest_time = elapsed; @@ -2128,7 +2217,7 @@ where } } - debug!(?fastest_mode, "Faster proving method found"); + info!(?fastest_mode, "Faster proving method found"); Ok(fastest_mode) }