Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions ci3/memsuspend_limit
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -eu

# Get the hardware memory in GB, useful for setting the memsuspend limit.
# General rule of thumb:
# - Allocate 1/4 of total hardware memory for the build.
# - Max out at 64GB
if [ -n "${MEMSUSPEND:-}" ]; then
echo $MEMSUSPEND
exit
fi
os=$(uname -s)
total_mem_gb=64 # Default to 64GB

if [[ "$os" == "Darwin" ]]; then
total_mem_bytes=$(sysctl -n hw.memsize)
total_mem_gb=$((total_mem_bytes / 1024 / 1024 / 1024))
elif [[ "$os" == "Linux" ]]; then
total_mem_gb=$(free -g | awk '/^Mem:/ {print $2}')
fi

# Allocate 1/4 of total hardware memory for the build.
total_mem_gb=$((total_mem_gb / 4))

# Max out at 64GB
echo $(( total_mem_gb < 64 ? total_mem_gb : 64 ))G
2 changes: 1 addition & 1 deletion ci3/parallelise
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NO_CD=1 source $(git rev-parse --show-toplevel)/ci3/source

cd $root
jobs=$(get_num_cpus_max ${1:-})
parallel_args="-j$jobs --memsuspend ${MEMSUSPEND:-64G} --line-buffer --joblog joblog.txt"
parallel_args="-j$jobs --memsuspend $(memsuspend_limit) --line-buffer --joblog joblog.txt"

# If not in CI, fail fast.
if [ "$CI" -eq 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/noir-contracts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trap on_exit EXIT
mkdir -p $tmp_dir

# Set common flags for parallel.
export PARALLEL_FLAGS="-j${PARALLELISM:-16} --halt now,fail=1 --memsuspend ${MEMSUSPEND:-64G}"
export PARALLEL_FLAGS="-j${PARALLELISM:-16} --halt now,fail=1 --memsuspend $(memsuspend_limit)"

# This computes a vk and adds it to the input function json if it's private, else returns same input.
# stdin has the function json.
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function build {
echo "$(basename $dir)"
fi
done | \
parallel -v --line-buffer --tag --halt now,fail=1 --memsuspend ${MEMSUSPEND:-64G} \
parallel -v --line-buffer --tag --halt now,fail=1 --memsuspend $(memsuspend_limit) \
--joblog joblog.txt compile {}
code=$?
cat joblog.txt
Expand Down
Loading