Skip to content

Commit

Permalink
feat: better initialization for permutation mapping components (#10750)
Browse files Browse the repository at this point in the history
Constructing the permutation argument polynomials (sigmas/ids) involves
constructing an intermediate object of type `PermutationMapping` which
contains information about the copy constraints in the circuit. The
initialization of this object was inefficient in two ways: (1) the
components were zero initialized only to be immediately initialized to
non-zero values, and (2) the initialization was not multithreaded. This
PR introduces a minor refactor of the underlying structures in
`PermutationMapping` so that the zero initialization can be avoided
altogether and the initialization to non-zero values can be done in
parallel. (In particular instead of vectors of a struct with components
{uint32_t, uint8_t, bool, bool}, we now have shared pointers to arrays
of the corresponding type {*uint32_t[], *uint8_t[], *bool[], *bool[]}.
This structure allows for efficient use of the slab allocator and
removes the need to default zero initialize).

Benchmark highlights for the case of 2^17 circuits in a 2^20 trace:

Master:
```
ClientIVCBench/Full/6      24684 ms        20203 ms
DeciderProvingKey(Circuit&)(t)          2365
compute_permutation_argument_polynomials(t)=912.772M
```

Branch:
```
ClientIVCBench/Full/6      23955 ms        19680 ms
DeciderProvingKey(Circuit&)(t)          1834     8.02%
compute_permutation_argument_polynomials(t)=437.54M
```
  • Loading branch information
ledwards2225 authored Dec 17, 2024
1 parent 9cce2c6 commit 1516d7f
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PROGRAM=assert_statement
# the program containing the recursive verifier
RECURSIVE_PROGRAM=verify_honk_proof

./reset_acir_tests.sh --rebuild-nargo --programs "$PROGRAM"
./reset_acir_tests.sh --programs "$PROGRAM"
cd "acir_tests/$PROGRAM"

TOML_DIR=../../../../noir/noir-repo/test_programs/execution_success/"$RECURSIVE_PROGRAM"
Expand Down
15 changes: 8 additions & 7 deletions barretenberg/acir_tests/reset_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ set -e
# Run from within barretenberg/acir_tests

# Initialize variables for flags
REBUILD_NARGO_FLAG=""
REBUILD_NARGO_FLAG=true
PROGRAMS=""

# Parse the arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--rebuild-nargo)
REBUILD_NARGO_FLAG="--rebuild-nargo"
--no-rebuild-nargo)
REBUILD_NARGO_FLAG=false
;;
--programs)
shift
Expand All @@ -26,12 +26,13 @@ while [[ "$#" -gt 0 ]]; do
shift
done

# Clean and rebuild noir, then compile the test programs if --rebuild-nargo flag is set
cd ../../noir/noir-repo

if [[ -n "$REBUILD_NARGO_FLAG" ]]; then
cd ../../noir/noir-repo
# Clean and rebuild noir unless --no-rebuild-nargo is specified, then compile the test programs
if [[ "$REBUILD_NARGO_FLAG" == true ]]; then
cargo clean
noirup -p .
else
echo "Skipping noir nargo build."
fi

# Rebuild test programs with rebuild.sh
Expand Down
Loading

0 comments on commit 1516d7f

Please sign in to comment.