diff --git a/Cargo.toml b/Cargo.toml index fbd16a70..f6ca4e1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ dusk-bls12_381 = {version = "0.8.0-rc.0", default-features = false, features = [ dusk-jubjub = {version = "0.10.0-rc.0", default-features = false} itertools = {version = "0.9", default-features = false} hashbrown = {version = "0.9", default-features=false, features = ["ahash"]} +rayon = {version = "1.3", optional = true} cfg-if = "1.0" # Dusk related deps for WASMI serde canonical = {version = "0.6", optional = true} @@ -47,7 +48,8 @@ std = [ "dusk-jubjub/default", "itertools/default", "hashbrown/default", - "alloc" + "alloc", + "rayon" ] alloc = ["dusk-bls12_381/alloc"] nightly = [] @@ -55,3 +57,10 @@ trace = [] trace-print = ["trace"] canon = ["dusk-bls12_381/canon", "dusk-jubjub/canon", "canonical", "canonical_derive"] + +[profile.release] +debug = false +panic = 'abort' +lto = true +incremental = false +codegen-units = 1 diff --git a/src/proof_system/quotient_poly.rs b/src/proof_system/quotient_poly.rs index 2bf78c6a..60cd7789 100644 --- a/src/proof_system/quotient_poly.rs +++ b/src/proof_system/quotient_poly.rs @@ -11,6 +11,8 @@ use crate::{ }; use alloc::vec::Vec; use dusk_bls12_381::BlsScalar; +#[cfg(feature = "std")] +use rayon::prelude::*; /// This quotient polynomial can only be used for the standard composer /// Each composer will need to implement their own method for computing the @@ -94,8 +96,13 @@ pub(crate) fn compute( (alpha, beta, gamma), ); - let quotient: Vec<_> = (0..domain_4n.size()) - .into_iter() + #[cfg(not(feature = "std"))] + let range = (0..domain_4n.size()).into_iter(); + + #[cfg(feature = "std")] + let range = (0..domain_4n.size()).into_par_iter(); + + let quotient: Vec<_> = range .map(|i| { let numerator = t_1[i] + t_2[i]; let denominator = prover_key.v_h_coset_4n()[i]; @@ -129,8 +136,13 @@ fn compute_circuit_satisfiability_equation( let domain_4n = EvaluationDomain::new(4 * domain.size()).unwrap(); let pi_eval_4n = domain_4n.coset_fft(pi_poly); - let t: Vec<_> = (0..domain_4n.size()) - .into_iter() + #[cfg(not(feature = "std"))] + let range = (0..domain_4n.size()).into_iter(); + + #[cfg(feature = "std")] + let range = (0..domain_4n.size()).into_par_iter(); + + let t: Vec<_> = range .map(|i| { let wl = &wl_eval_4n[i]; let wr = &wr_eval_4n[i]; @@ -212,8 +224,13 @@ fn compute_permutation_checks( compute_first_lagrange_poly_scaled(domain, alpha.square()); let l1_alpha_sq_evals = domain_4n.coset_fft(&l1_poly_alpha.coeffs); - let t: Vec<_> = (0..domain_4n.size()) - .into_iter() + #[cfg(not(feature = "std"))] + let range = (0..domain_4n.size()).into_iter(); + + #[cfg(feature = "std")] + let range = (0..domain_4n.size()).into_par_iter(); + + let t: Vec<_> = range .map(|i| { prover_key.permutation.compute_quotient_i( i,