@@ -20,7 +20,6 @@ cmd=${1:-}
2020
2121export RAYON_NUM_THREADS=${RAYON_NUM_THREADS:- 16}
2222export HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:- 16}
23- export PARALLELISM=${PARALLELISM:- 16}
2423export PLATFORM_TAG=any
2524
2625export BB=${BB:- ../ ../ barretenberg/ cpp/ build/ bin/ bb}
@@ -38,6 +37,13 @@ function on_exit() {
3837trap on_exit EXIT
3938mkdir -p $tmp_dir
4039
40+ # Set flags for parallel
41+ export PARALLELISM=${PARALLELISM:- 16}
42+ export PARALLEL_FLAGS=" -j$PARALLELISM --halt now,fail=1"
43+ if [[ -n " ${MEMSUSPEND-} " ]]; then
44+ export PARALLEL_FLAGS=" $PARALLEL_FLAGS --memsuspend $MEMSUSPEND "
45+ fi
46+
4147# This computes a vk and adds it to the input function json if it's private, else returns same input.
4248# stdin has the function json.
4349# stdout receives the function json with the vk added (if private).
@@ -117,7 +123,7 @@ function compile {
117123 # .[1 ] is the updated functions on stdin (-)
118124 # * merges their fields.
119125 jq -c '.functions[]' $json_path | \
120- parallel -j $PARALLELISM --keep-order -N1 --block 8 M --pipe --halt now,fail= 1 process_function | \
126+ parallel $PARALLEL_FLAGS --keep-order -N1 --block 8 M --pipe process_function | \
121127 jq -s '{functions: .}' | jq -s '.[0 ] * {functions: .[1 ].functions}' $json_path - > $tmp_dir /$filename
122128 mv $tmp_dir /$filename $json_path
123129}
@@ -132,7 +138,7 @@ function build {
132138 set +e
133139 echo_stderr "Compiling contracts (bb-hash: $BB_HASH )..."
134140 grep -oP '(?<=contracts/)[^"]+' Nargo.toml | \
135- parallel -j $PARALLELISM --joblog joblog.txt -v --line-buffer --tag --halt now,fail= 1 compile {}
141+ parallel $PARALLEL_FLAGS --joblog joblog.txt -v --line-buffer --tag compile {}
136142 code=$?
137143 cat joblog.txt
138144 return $code
@@ -164,7 +170,7 @@ function test {
164170 done
165171
166172 echo " Starting test run..."
167- test_cmds | (cd $root ; NARGO_FOREIGN_CALL_TIMEOUT=300000 parallel --bar --halt now,fail=1 ' dump_fail {} >/dev/null' )
173+ test_cmds | (cd $root ; NARGO_FOREIGN_CALL_TIMEOUT=300000 parallel --bar $PARALLEL_FLAGS ' dump_fail {} >/dev/null' )
168174}
169175
170176case " $cmd " in
0 commit comments