Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions ipa-multipoint/src/multiproof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@
challenges: &'a [Fr],
) -> FxHashMap<usize, Vec<(&'a ProverQuery, &'a Fr)>> {
// We want to group all of the polynomials which are evaluated at the same point together
let mut res = FxHashMap::default();
let mut res: FxHashMap<usize, Vec<(&ProverQuery, &Fr)>> =
FxHashMap::with_capacity_and_hasher(prover_queries.len(), Default::default());

prover_queries
.iter()
.zip(challenges.iter())
.for_each(|(key, val)| {
res.entry(key.point)
.or_insert_with(Vec::new)

Check failure on line 59 in ipa-multipoint/src/multiproof.rs

View workflow job for this annotation

GitHub Actions / Lints

use of `or_insert_with` to construct default value
.push((key, val));
});

Expand All @@ -81,26 +82,17 @@

let grouped_queries = group_prover_queries(&queries, &powers_of_r);

let grouped_queries: Vec<_> = grouped_queries.into_par_iter().collect();

let chunk_size = grouped_queries.len().div_ceil(rayon::current_num_threads());

// aggregate all of the queries evaluated at the same point
let aggregated_queries: Vec<_> = grouped_queries
.par_chunks(chunk_size)
.flat_map(|chunk| {
chunk
.into_par_iter()
.map(|(point, queries_challenges)| {
let aggregated_polynomial = queries_challenges
.iter()
.map(|(point, queries_challenges)| {
let aggregated_polynomial = queries_challenges
.iter()
.map(|(query, challenge)| query.poly.clone() * *challenge)
.reduce(|acc, x| acc + x)
.expect("Failed to aggregate polynomial");

(*point, aggregated_polynomial)
})
.collect::<Vec<_>>()
.map(|(query, challenge)| query.poly.clone() * *challenge)
.reduce(|acc, x| acc + x)
.expect("Failed to aggregate polynomial");

(point, aggregated_polynomial)
})
.collect::<Vec<_>>();

Expand Down
Loading