Skip to content

Commit

Permalink
Add measurement logs
Browse files Browse the repository at this point in the history
  • Loading branch information
spapinistarkware committed Apr 15, 2024
1 parent c8552c4 commit eeb1ad0
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 7 deletions.
194 changes: 191 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ itertools = "0.12.0"
num-traits = "0.2.17"
thiserror = "1.0.56"
bytemuck = { version = "1.14.3", features = ["derive"] }
tracing = "0.1.40"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
rand = { version = "0.8.5", features = ["small_rng"] }
tracing-subscriber = "0.3.18"
test-log = { version = "0.2.15", features = ["trace"] }

[lib]
bench = false
Expand Down
3 changes: 3 additions & 0 deletions avx_benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RUST_LOG_SPAN_EVENTS=enter,close RUST_LOG=info RUST_BACKTRACE=1 \
RUSTFLAGS="-Awarnings -C target-cpu=native -C target-feature=+avx512f -C opt-level=2" \
cargo test test_avx_wide_fib_prove -- --nocapture
2 changes: 2 additions & 0 deletions src/core/air/accumulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! f(p) = sum_i alpha^{N-1-i} u_i(P).

use itertools::Itertools;
use tracing::{span, Level};

use crate::core::backend::{Backend, CPUBackend};
use crate::core::fields::m31::BaseField;
Expand Down Expand Up @@ -114,6 +115,7 @@ impl<B: Backend> DomainEvaluationAccumulator<B> {
0,
"not all random coefficients were used"
);
let _span = span!(Level::INFO, "Constraints interpolation").entered();
let mut res_coeffs = SecureColumn::<B>::zeros(1 << self.log_size());
let res_log_size = self.log_size();

Expand Down
5 changes: 5 additions & 0 deletions src/core/commitment_scheme/prover.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::BTreeMap;

use itertools::Itertools;
use tracing::{span, Level};

use super::super::channel::Blake2sChannel;
use super::super::circle::CirclePoint;
Expand Down Expand Up @@ -147,6 +148,7 @@ impl<B: Backend + MerkleOps<MerkleHasher>> CommitmentTreeProver<B> {
log_blowup_factor: u32,
channel: &mut ProofChannel,
) -> Self {
let span = span!(Level::INFO, "Commitment evaluation").entered();
let evaluations = polynomials
.iter()
.map(|poly| {
Expand All @@ -156,6 +158,9 @@ impl<B: Backend + MerkleOps<MerkleHasher>> CommitmentTreeProver<B> {
})
.collect_vec();

span.exit();

let _span = span!(Level::INFO, "Commitment merkle").entered();
let tree = MerkleProver::commit(evaluations.iter().map(|eval| &eval.values).collect());
channel.mix_digest(tree.root());

Expand Down
2 changes: 2 additions & 0 deletions src/core/commitment_scheme/quotients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::BTreeMap;
use std::iter::zip;

use itertools::{izip, multiunzip, Itertools};
use tracing::{span, Level};

use crate::core::backend::cpu::quotients::{accumulate_row_quotients, quotient_constants};
use crate::core::circle::CirclePoint;
Expand Down Expand Up @@ -76,6 +77,7 @@ pub fn compute_fri_quotients<B: QuotientOps>(
samples: &[Vec<PointSample>],
random_coeff: SecureField,
) -> Vec<SecureEvaluation<B>> {
let _span = span!(Level::INFO, "Compute FRI quotients").entered();
zip(columns, samples)
.sorted_by_key(|(c, _)| Reverse(c.domain.log_size()))
.group_by(|(c, _)| c.domain.log_size())
Expand Down
2 changes: 2 additions & 0 deletions src/core/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::ops::RangeInclusive;
use itertools::Itertools;
use num_traits::Zero;
use thiserror::Error;
use tracing::{span, Level};

use super::backend::CPUBackend;
use super::channel::Channel;
Expand Down Expand Up @@ -149,6 +150,7 @@ impl<B: FriOps + MerkleOps<H>, H: MerkleHasher> FriProver<B, H> {
columns: &[SecureEvaluation<B>],
twiddles: &TwiddleTree<B>,
) -> Self {
let _span = span!(Level::INFO, "FRI commitment").entered();
assert!(!columns.is_empty(), "no columns");
assert!(columns.is_sorted_by_key(|e| Reverse(e.len())), "not sorted");
assert!(columns.iter().all(|e| e.domain.is_canonic()), "not canonic");
Expand Down
2 changes: 2 additions & 0 deletions src/core/proof_of_work.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use thiserror::Error;
use tracing::{span, Level};

use super::channel::Blake2sChannel;
use crate::commitment_scheme::blake2_hash::{Blake2sHash, Blake2sHasher};
Expand All @@ -22,6 +23,7 @@ impl ProofOfWork {
}

pub fn prove(&self, channel: &mut Blake2sChannel) -> ProofOfWorkProof {
let _span = span!(Level::INFO, "Proof of work").entered();
let seed = channel.get_digest().as_ref().to_vec();
let proof = self.grind(seed);
channel.mix_nonce(proof.nonce);
Expand Down
Loading

0 comments on commit eeb1ad0

Please sign in to comment.