Commit 79c7865a authored by 董子豪's avatar 董子豪

modify wondow-post bench

parent f36f16c5
use log::info;
use std::collections::BTreeMap;
use std::fs;
use std::path::PathBuf;
use std::time::Instant;
use bincode::deserialize;
use std::str::FromStr;
use filecoin_hashers::{Domain, HashFunction, Hasher, PoseidonArity};
use filecoin_hashers::{HashFunction, Hasher};
use bellperson::bls::Fr;
use fil_proofs_tooling::measure;
......@@ -26,7 +25,7 @@ use storage_proofs_core::merkle::MerkleTreeTrait;
use storage_proofs_core::sector::SectorId;
use storage_proofs_core::cache_key::CacheKey;
const FAKE_RANDOMNESS: [u8; 32] = [10; 32];
// const FAKE_RANDOMNESS: [u8; 32] = [10; 32];
#[allow(clippy::too_many_arguments)]
fn run_agg_proofs<Tree: 'static + MerkleTreeTrait>(
......@@ -123,6 +122,12 @@ fn run_agg_proofs<Tree: 'static + MerkleTreeTrait>(
let ok = verify_aggregate_window_post_proofs::<Tree>(&post_config, PROVER_ID, aggregate_proof.to_vec(), randomnesses.as_slice(), pub_replica_infos.as_slice())?;
let verify_aggregate_proofs_cold_time = start_time.elapsed().as_millis();
if ok {
println!("aggregate proofs(cold) is true");
} else {
println!("aggregate proofs(cold) is false");
}
let start_time = Instant::now();
let aggregate_proof = &aggregate_window_post_proofs::<Tree>(&post_config, randomnesses.as_slice(), proofs.as_slice(), 2)?;
let aggregate_window_post_proofs_hot_time = start_time.elapsed().as_millis();
......@@ -132,9 +137,9 @@ fn run_agg_proofs<Tree: 'static + MerkleTreeTrait>(
let verify_aggregate_proofs_hot_time = start_time.elapsed().as_millis();
if ok {
println!("aggregate proofs is true");
println!("aggregate proofs(hot) is true");
} else {
println!("aggregate proofs is false");
println!("aggregate proofs(hot) is false");
}
println!("#################################################");
......
use std::collections::BTreeMap;
use std::fs::{create_dir, read, read_to_string, remove_dir_all, File, OpenOptions};
use std::io::{stdout, Seek, SeekFrom, Write};
use std::io::{/*stdout,*/ Seek, SeekFrom, Write};
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH};
use std::time::Instant;
use bellperson::bls::Fr;
// use bellperson::bls::Fr;
use anyhow::{ensure, Context};
use bincode::{deserialize, serialize};
use fil_proofs_tooling::measure::FuncMeasurement;
use fil_proofs_tooling::shared::{PROVER_ID, RANDOMNESS, TICKET_BYTES};
use fil_proofs_tooling::{measure, Metadata};
use fil_proofs_tooling::{measure/*, Metadata*/};
use filecoin_proofs::constants::{
POREP_PARTITIONS, WINDOW_POST_CHALLENGE_COUNT, WINDOW_POST_SECTOR_COUNT,
};
use filecoin_proofs::types::{
PaddedBytesAmount, PieceInfo, PoRepConfig, PoRepProofPartitions, PoStConfig,
SealCommitPhase1Output, SealPreCommitOutput, SealPreCommitPhase1Output, SectorSize,
UnpaddedBytesAmount, UnpaddedByteIndex, ChallengeSeed,
UnpaddedBytesAmount, /*UnpaddedByteIndex,*/ ChallengeSeed,
};
use filecoin_proofs::{
add_piece, /*generate_piece_commitment,*/ unseal_range, generate_window_post, seal_commit_phase1,
add_piece, /*generate_piece_commitment,*/ /*unseal_range,*/ generate_window_post, seal_commit_phase1,
seal_commit_phase2, seal_pre_commit_phase1, seal_pre_commit_phase2, validate_cache_for_commit,
validate_cache_for_precommit_phase2, verify_window_post, with_shape, PoStType,
validate_cache_for_precommit_phase2, /*verify_window_post,*/ with_shape, PoStType,
PrivateReplicaInfo, PublicReplicaInfo, aggregate_window_post_proofs, verify_aggregate_window_post_proofs,
get_window_post_inputs,
/*get_window_post_inputs,*/
};
use log::info;
use serde::{Deserialize, Serialize};
......@@ -33,13 +33,13 @@ use storage_proofs_core::merkle::MerkleTreeTrait;
use storage_proofs_core::sector::SectorId;
const SECTOR_ID: u64 = 0;
// const SECTOR_ID: u64 = 0;
const PIECE_FILE: &str = "piece-file";
const PIECE_INFOS_FILE: &str = "piece-infos-file";
const STAGED_FILE: &str = "staged-file";
const SEALED_FILE: &str = "sealed-file";
const UNSEALED_FILE: &str = "unsealed-file";
// const UNSEALED_FILE: &str = "unsealed-file";
const PRECOMMIT_PHASE1_OUTPUT_FILE: &str = "precommit-phase1-output";
const PRECOMMIT_PHASE2_OUTPUT_FILE: &str = "precommit-phase2-output";
const COMMIT_PHASE1_OUTPUT_FILE: &str = "commit-phase1-output";
......@@ -71,20 +71,20 @@ struct Outputs {
verify_window_post_wall_time_ms: u64,
}
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
struct Report {
inputs: Inputs,
outputs: Outputs,
}
impl Report {
/// Print all results to stdout
pub fn print(&self) {
let wrapped = Metadata::wrap(&self).expect("failed to retrieve metadata");
serde_json::to_writer(stdout(), &wrapped).expect("cannot write report JSON to stdout");
}
}
// #[derive(Serialize, Deserialize)]
// #[serde(rename_all = "kebab-case")]
// struct Report {
// inputs: Inputs,
// outputs: Outputs,
// }
// impl Report {
// /// Print all results to stdout
// pub fn print(&self) {
// let wrapped = Metadata::wrap(&self).expect("failed to retrieve metadata");
// serde_json::to_writer(stdout(), &wrapped).expect("cannot write report JSON to stdout");
// }
// }
fn get_porep_config(sector_size: u64, api_version: ApiVersion) -> PoRepConfig {
let arbitrary_porep_id = [99; 32];
......@@ -387,12 +387,12 @@ pub fn run_window_post_bench<Tree: 'static + MerkleTreeTrait>(
create_dir(&cache_dir)?;
}
let (
(seal_pre_commit_phase1_cpu_time_ms, seal_pre_commit_phase1_wall_time_ms),
(_seal_pre_commit_phase1_cpu_time_ms, _seal_pre_commit_phase1_wall_time_ms),
(
validate_cache_for_precommit_phase2_cpu_time_ms,
validate_cache_for_precommit_phase2_wall_time_ms,
_validate_cache_for_precommit_phase2_cpu_time_ms,
_validate_cache_for_precommit_phase2_wall_time_ms,
),
(seal_pre_commit_phase2_cpu_time_ms, seal_pre_commit_phase2_wall_time_ms),
(_seal_pre_commit_phase2_cpu_time_ms, _seal_pre_commit_phase2_wall_time_ms),
) = if skip_precommit_phase1 && skip_precommit_phase2 {
// generate no-op measurements
Ok(((0, 0), (0, 0), (0, 0)))
......@@ -441,7 +441,7 @@ pub fn run_window_post_bench<Tree: 'static + MerkleTreeTrait>(
let seed = [0u8; 32];
let comm_r = seal_pre_commit_output.comm_r;
let comm_d = seal_pre_commit_output.comm_d;
let _comm_d = seal_pre_commit_output.comm_d;
let sector_id = SectorId::from(index);
let porep_config = get_porep_config(sector_size, api_version);
......@@ -449,10 +449,10 @@ pub fn run_window_post_bench<Tree: 'static + MerkleTreeTrait>(
let sealed_file_path = cache_dir.join(SEALED_FILE);
let (
validate_cache_for_commit_cpu_time_ms,
validate_cache_for_commit_wall_time_ms,
seal_commit_phase1_cpu_time_ms,
seal_commit_phase1_wall_time_ms,
_validate_cache_for_commit_cpu_time_ms,
_validate_cache_for_commit_wall_time_ms,
_seal_commit_phase1_cpu_time_ms,
_seal_commit_phase1_wall_time_ms,
) = if skip_commit_phase1 {
// generate no-op measurements
(0, 0, 0, 0)
......@@ -504,7 +504,7 @@ pub fn run_window_post_bench<Tree: 'static + MerkleTreeTrait>(
)
};
let (seal_commit_phase2_cpu_time_ms, seal_commit_phase2_wall_time_ms) = if skip_commit_phase2 {
let (_seal_commit_phase2_cpu_time_ms, _seal_commit_phase2_wall_time_ms) = if skip_commit_phase2 {
// generate no-op measurements
(0, 0)
} else {
......@@ -667,12 +667,12 @@ pub fn run_window_post_bench<Tree: 'static + MerkleTreeTrait>(
info!("aggregate proofs is false");
}
// info!("#################################################");
// info!("generate {} window-post using {}", aggregate_count, generate_window_post_time);
// info!("aggregate {} window-post proofs using {}", aggregate_count, aggregate_window_post_proofs_time);
// info!("verify_aggregate {} window-post proofs using {}", aggregate_count, verify_aggregate_proofs_time);
// info!("aggregate proofs size is {}", aggregate_proof.len());
// info!("#################################################");
info!("#################################################");
info!("generate {} window-post using {}", aggregate_count, generate_window_post_time);
info!("aggregate {} window-post proofs using {}", aggregate_count, aggregate_window_post_proofs_time);
info!("verify_aggregate {} window-post proofs using {}", aggregate_count, verify_aggregate_proofs_time);
info!("aggregate proofs size is {}", aggregate_proof.len());
info!("#################################################");
if preserve_cache {
info!("Preserving cache directory {:?}", root_dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment