Skip to content

perf: pre-allocate HashMap and remove redundant intermediate Vec in multiproof.rs#125

Open
KENILSHAHH wants to merge 1 commit intomegaeth-labs:mainfrom
KENILSHAHH:perf/multiproof-allocation-reduction
Open

perf: pre-allocate HashMap and remove redundant intermediate Vec in multiproof.rs#125
KENILSHAHH wants to merge 1 commit intomegaeth-labs:mainfrom
KENILSHAHH:perf/multiproof-allocation-reduction

Conversation

@KENILSHAHH
Copy link
Copy Markdown

Summary

  • Pre-allocate FxHashMap in group_prover_queries with with_capacity_and_hasher(prover_queries.len(), ...) to avoid repeated rehashing as entries are added
  • Remove intermediate collect into Vec + manual par_chunks(len / num_threads) splitting in MultiPoint::open, replacing with direct into_par_iter().map() which
    eliminates one Vec allocation and lets rayon's work-stealing handle load balancing

Context

Both changes are in ipa-multipoint/src/multiproof.rs, in the MultiPoint::open proof generation hot path.

The HashMap was starting at default capacity and resizing multiple times as queries were inserted. Since we know the number of queries upfront, we pre-allocate.

The old parallelization pattern collected a HashMap into a Vec just to call par_chunks() with a manually computed chunk size. This added an unnecessary allocation and
rigid equal-sized splitting. Rayon's into_par_iter() on HashMap already provides parallel iteration with work-stealing, which handles uneven workloads better than fixed
chunking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant