Skip to content

Commit

Permalink
Debug Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Mar 12, 2024
1 parent 5d8b657 commit 0b7738a
Showing 1 changed file with 90 additions and 1 deletion.
91 changes: 90 additions & 1 deletion crates/subspace-farmer/src/single_disk_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
{
Expand All @@ -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::<PosTable> {
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: &sectors_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::<PosTable> {
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: &sectors_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();
Expand Down Expand Up @@ -2110,6 +2195,8 @@ where
})?;
let elapsed = start.elapsed();

println!("Chunks in {elapsed:?}");

if fastest_time > elapsed {
fastest_mode = ReadSectorRecordChunksMode::ConcurrentChunks;
fastest_time = elapsed;
Expand All @@ -2121,14 +2208,16 @@ 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;
}
}
}

debug!(?fastest_mode, "Faster proving method found");
info!(?fastest_mode, "Faster proving method found");

Ok(fastest_mode)
}

0 comments on commit 0b7738a

Please sign in to comment.