Skip to content

Commit

Permalink
feat: parallelize mapped parameter loading
Browse files Browse the repository at this point in the history
style: remove verbose logging
  • Loading branch information
cryptonemo committed Mar 9, 2021
1 parent cd5e78e commit 007487f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/groth16/mapped_params.rs
Expand Up @@ -4,6 +4,7 @@ use groupy::{CurveAffine, EncodedPoint};
use crate::SynthesisError;

use memmap::Mmap;
use rayon::prelude::*;

use std::fs::File;
use std::io;
Expand Down Expand Up @@ -59,7 +60,7 @@ impl<'a, E: Engine> ParameterSource<E> for &'a MappedParameters<E> {
fn get_h(&self, _num_h: usize) -> Result<Self::G1Builder, SynthesisError> {
let builder = self
.h
.iter()
.par_iter()
.cloned()
.map(|h| read_g1::<E>(&self.params, h, self.checked))
.collect::<Result<_, _>>()?;
Expand All @@ -70,7 +71,7 @@ impl<'a, E: Engine> ParameterSource<E> for &'a MappedParameters<E> {
fn get_l(&self, _num_l: usize) -> Result<Self::G1Builder, SynthesisError> {
let builder = self
.l
.iter()
.par_iter()
.cloned()
.map(|l| read_g1::<E>(&self.params, l, self.checked))
.collect::<Result<_, _>>()?;
Expand All @@ -85,7 +86,7 @@ impl<'a, E: Engine> ParameterSource<E> for &'a MappedParameters<E> {
) -> Result<(Self::G1Builder, Self::G1Builder), SynthesisError> {
let builder = self
.a
.iter()
.par_iter()
.cloned()
.map(|a| read_g1::<E>(&self.params, a, self.checked))
.collect::<Result<_, _>>()?;
Expand All @@ -102,7 +103,7 @@ impl<'a, E: Engine> ParameterSource<E> for &'a MappedParameters<E> {
) -> Result<(Self::G1Builder, Self::G1Builder), SynthesisError> {
let builder = self
.b_g1
.iter()
.par_iter()
.cloned()
.map(|b_g1| read_g1::<E>(&self.params, b_g1, self.checked))
.collect::<Result<_, _>>()?;
Expand All @@ -119,7 +120,7 @@ impl<'a, E: Engine> ParameterSource<E> for &'a MappedParameters<E> {
) -> Result<(Self::G2Builder, Self::G2Builder), SynthesisError> {
let builder = self
.b_g2
.iter()
.par_iter()
.cloned()
.map(|b_g2| read_g2::<E>(&self.params, b_g2, self.checked))
.collect::<Result<_, _>>()?;
Expand Down
6 changes: 0 additions & 6 deletions src/multicore.rs
Expand Up @@ -88,12 +88,6 @@ impl Worker {
});
} else {
THREAD_POOL.spawn(move || {
trace!(
"[{}] pool is using spawn [current threads {}, threads requested {}]",
thread_index,
THREAD_POOL.current_num_threads(),
WORKER_SPAWN_COUNTER.load(Ordering::SeqCst),
);
let res = f();
sender.send(res).unwrap();
WORKER_SPAWN_COUNTER.fetch_sub(1, Ordering::SeqCst);
Expand Down

0 comments on commit 007487f

Please sign in to comment.