Skip to content

Commit

Permalink
chore: fallback to building barretenberg targets sequentially when RA…
Browse files Browse the repository at this point in the history
…M constrained (#5426)

Attempting to run `bootstrap.sh full` locally results in my computer
freezing due to the amount of memory which building the three
barretenberg targets in parallel. I've added a quick check on the amount
of available memory and if it's below 32GB then we fall back to building
sequentially.
  • Loading branch information
TomAFrench authored Mar 26, 2024
1 parent 8ea6946 commit 29588e0
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,26 @@ b="\033[34m" # Blue
p="\033[35m" # Purple
r="\033[0m" # Reset

(build_native > >(awk -v g="$g" -v r="$r" '{print g "native: " r $0}')) &
(build_wasm > >(awk -v b="$b" -v r="$r" '{print b "wasm: " r $0}')) &
(build_wasm_threads > >(awk -v p="$p" -v r="$r" '{print p "wasm_threads: "r $0}')) &

for job in $(jobs -p); do
wait $job || exit 1
done
AVAILABLE_MEMORY=$(awk '/MemFree/ { printf $2 }' /proc/meminfo)
# This value may be too low.
# If builds fail with an amount of free memory greater than this value then it should be increased.
MIN_PARALLEL_BUILD_MEMORY=32000000

if [[ AVAILABLE_MEMORY -lt MIN_PARALLEL_BUILD_MEMORY ]]; then
echo "System does not have enough memory for parallel builds, falling back to sequential"
build_native
build_wasm
build_wasm_threads
else
(build_native > >(awk -v g="$g" -v r="$r" '{print g "native: " r $0}')) &
(build_wasm > >(awk -v b="$b" -v r="$r" '{print b "wasm: " r $0}')) &
(build_wasm_threads > >(awk -v p="$p" -v r="$r" '{print p "wasm_threads: "r $0}')) &

for job in $(jobs -p); do
wait $job || exit 1
done
fi

if [ ! -d ./srs_db/grumpkin ]; then
# The Grumpkin SRS is generated manually at the moment, only up to a large enough size for tests
Expand Down

0 comments on commit 29588e0

Please sign in to comment.