@@ -10,6 +10,7 @@ use subspace_core_primitives::crypto::kzg::{embedded_kzg_settings, Kzg};
10
10
use subspace_core_primitives:: { Record , SolutionRange } ;
11
11
use subspace_erasure_coding:: ErasureCoding ;
12
12
use subspace_farmer:: single_disk_farm:: farming:: rayon_files:: RayonFiles ;
13
+ use subspace_farmer:: single_disk_farm:: farming:: unbuffered_io_file_windows:: UnbufferedIoFileWindows ;
13
14
use subspace_farmer:: single_disk_farm:: farming:: { PlotAudit , PlotAuditOptions } ;
14
15
use subspace_farmer:: single_disk_farm:: { SingleDiskFarm , SingleDiskFarmSummary } ;
15
16
use subspace_farmer_components:: sector:: sector_size;
@@ -161,12 +162,48 @@ fn audit(
161
162
)
162
163
} ) ;
163
164
}
165
+ if cfg ! ( windows) {
166
+ let plot = RayonFiles :: open_with (
167
+ & disk_farm. join ( SingleDiskFarm :: PLOT_FILE ) ,
168
+ UnbufferedIoFileWindows :: open,
169
+ )
170
+ . map_err ( |error| anyhow:: anyhow!( "Failed to open plot: {error}" ) ) ?;
171
+ let plot_audit = PlotAudit :: new ( & plot) ;
172
+
173
+ group. bench_function ( "plot/rayon/unbuffered" , |b| {
174
+ b. iter_batched (
175
+ rand:: random,
176
+ |global_challenge| {
177
+ let options = PlotAuditOptions :: < PosTable > {
178
+ public_key : single_disk_farm_info. public_key ( ) ,
179
+ reward_address : single_disk_farm_info. public_key ( ) ,
180
+ slot_info : SlotInfo {
181
+ slot_number : 0 ,
182
+ global_challenge,
183
+ // No solution will be found, pure audit
184
+ solution_range : SolutionRange :: MIN ,
185
+ // No solution will be found, pure audit
186
+ voting_solution_range : SolutionRange :: MIN ,
187
+ } ,
188
+ sectors_metadata : & sectors_metadata,
189
+ kzg : & kzg,
190
+ erasure_coding : & erasure_coding,
191
+ maybe_sector_being_modified : None ,
192
+ table_generator : & table_generator,
193
+ } ;
194
+
195
+ black_box ( plot_audit. audit ( black_box ( options) ) )
196
+ } ,
197
+ BatchSize :: SmallInput ,
198
+ )
199
+ } ) ;
200
+ }
164
201
{
165
202
let plot = RayonFiles :: open ( & disk_farm. join ( SingleDiskFarm :: PLOT_FILE ) )
166
203
. map_err ( |error| anyhow:: anyhow!( "Failed to open plot: {error}" ) ) ?;
167
204
let plot_audit = PlotAudit :: new ( & plot) ;
168
205
169
- group. bench_function ( "plot/rayon" , |b| {
206
+ group. bench_function ( "plot/rayon/regular " , |b| {
170
207
b. iter_batched (
171
208
rand:: random,
172
209
|global_challenge| {
@@ -252,7 +289,7 @@ fn prove(
252
289
. open ( disk_farm. join ( SingleDiskFarm :: PLOT_FILE ) )
253
290
. map_err ( |error| anyhow:: anyhow!( "Failed to open plot: {error}" ) ) ?;
254
291
let plot_audit = PlotAudit :: new ( & plot) ;
255
- let options = PlotAuditOptions :: < PosTable > {
292
+ let mut options = PlotAuditOptions :: < PosTable > {
256
293
public_key : single_disk_farm_info. public_key ( ) ,
257
294
reward_address : single_disk_farm_info. public_key ( ) ,
258
295
slot_info : SlotInfo {
@@ -267,7 +304,7 @@ fn prove(
267
304
kzg : & kzg,
268
305
erasure_coding : & erasure_coding,
269
306
maybe_sector_being_modified : None ,
270
- table_generator : & table_generator ,
307
+ table_generator : & Mutex :: new ( PosTable :: generator ( ) ) ,
271
308
} ;
272
309
273
310
let mut audit_results = plot_audit. audit ( options) . unwrap ( ) ;
@@ -279,12 +316,60 @@ fn prove(
279
316
return result;
280
317
}
281
318
319
+ options. slot_info . global_challenge = rand:: random ( ) ;
320
+ audit_results = plot_audit. audit ( options) . unwrap ( ) ;
321
+
322
+ audit_results. pop ( ) . unwrap ( )
323
+ } ,
324
+ |( _sector_index, mut provable_solutions) | {
325
+ while black_box ( provable_solutions. next ( ) ) . is_none ( ) {
326
+ // Try to create one solution and exit
327
+ }
328
+ } ,
329
+ BatchSize :: SmallInput ,
330
+ )
331
+ } ) ;
332
+ }
333
+ if cfg ! ( windows) {
334
+ let plot = RayonFiles :: open_with (
335
+ & disk_farm. join ( SingleDiskFarm :: PLOT_FILE ) ,
336
+ UnbufferedIoFileWindows :: open,
337
+ )
338
+ . map_err ( |error| anyhow:: anyhow!( "Failed to open plot: {error}" ) ) ?;
339
+ let plot_audit = PlotAudit :: new ( & plot) ;
340
+ let mut options = PlotAuditOptions :: < PosTable > {
341
+ public_key : single_disk_farm_info. public_key ( ) ,
342
+ reward_address : single_disk_farm_info. public_key ( ) ,
343
+ slot_info : SlotInfo {
344
+ slot_number : 0 ,
345
+ global_challenge : rand:: random ( ) ,
346
+ // Solution is guaranteed to be found
347
+ solution_range : SolutionRange :: MAX ,
348
+ // Solution is guaranteed to be found
349
+ voting_solution_range : SolutionRange :: MAX ,
350
+ } ,
351
+ sectors_metadata : & sectors_metadata,
352
+ kzg : & kzg,
353
+ erasure_coding : & erasure_coding,
354
+ maybe_sector_being_modified : None ,
355
+ table_generator : & table_generator,
356
+ } ;
357
+ let mut audit_results = plot_audit. audit ( options) . unwrap ( ) ;
358
+
359
+ group. bench_function ( "plot/rayon/unbuffered" , |b| {
360
+ b. iter_batched (
361
+ || {
362
+ if let Some ( result) = audit_results. pop ( ) {
363
+ return result;
364
+ }
365
+
366
+ options. slot_info . global_challenge = rand:: random ( ) ;
282
367
audit_results = plot_audit. audit ( options) . unwrap ( ) ;
283
368
284
369
audit_results. pop ( ) . unwrap ( )
285
370
} ,
286
371
|( _sector_index, mut provable_solutions) | {
287
- while ( provable_solutions. next ( ) ) . is_none ( ) {
372
+ while black_box ( provable_solutions. next ( ) ) . is_none ( ) {
288
373
// Try to create one solution and exit
289
374
}
290
375
} ,
@@ -296,7 +381,7 @@ fn prove(
296
381
let plot = RayonFiles :: open ( & disk_farm. join ( SingleDiskFarm :: PLOT_FILE ) )
297
382
. map_err ( |error| anyhow:: anyhow!( "Failed to open plot: {error}" ) ) ?;
298
383
let plot_audit = PlotAudit :: new ( & plot) ;
299
- let options = PlotAuditOptions :: < PosTable > {
384
+ let mut options = PlotAuditOptions :: < PosTable > {
300
385
public_key : single_disk_farm_info. public_key ( ) ,
301
386
reward_address : single_disk_farm_info. public_key ( ) ,
302
387
slot_info : SlotInfo {
@@ -315,19 +400,20 @@ fn prove(
315
400
} ;
316
401
let mut audit_results = plot_audit. audit ( options) . unwrap ( ) ;
317
402
318
- group. bench_function ( "plot/rayon" , |b| {
403
+ group. bench_function ( "plot/rayon/regular " , |b| {
319
404
b. iter_batched (
320
405
|| {
321
406
if let Some ( result) = audit_results. pop ( ) {
322
407
return result;
323
408
}
324
409
410
+ options. slot_info . global_challenge = rand:: random ( ) ;
325
411
audit_results = plot_audit. audit ( options) . unwrap ( ) ;
326
412
327
413
audit_results. pop ( ) . unwrap ( )
328
414
} ,
329
415
|( _sector_index, mut provable_solutions) | {
330
- while ( provable_solutions. next ( ) ) . is_none ( ) {
416
+ while black_box ( provable_solutions. next ( ) ) . is_none ( ) {
331
417
// Try to create one solution and exit
332
418
}
333
419
} ,
0 commit comments