Skip to content

Commit

Permalink
Limit build parallelism for github runners
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 15, 2024
1 parent 2d08704 commit 935eaf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/code_sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
- name: Build Tests
id: build
run: ci/build-tests.sh
env:
MAX_BUILD_PARALLELISM: 2 # Limit parallelism to avoid OOM during compilation

- name: Core Tests
if: steps.build.outcome == 'success' && (success() || failure())
Expand Down
18 changes: 13 additions & 5 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,29 @@ ${CMAKE_BACKTRACE:-} \
${SRC}

number_of_processors() {
local max_procs=$(nproc)
case "$(uname -s)" in
Linux*)
nproc
Linux*)
max_procs=$(nproc)
;;
Darwin*)
sysctl -n hw.ncpu
Darwin*)
max_procs=$(sysctl -n hw.ncpu)
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo "${NUMBER_OF_PROCESSORS}"
max_procs="${NUMBER_OF_PROCESSORS}"
;;
*)
echo "Unknown OS"
exit 1
;;
esac

# If MAX_BUILD_PARALLELISM is set and less than the number of processors, use it instead
if [[ ! -z ${MAX_BUILD_PARALLELISM:-} ]] && [[ "$MAX_BUILD_PARALLELISM" -lt "$max_procs" ]]; then
echo "$MAX_BUILD_PARALLELISM"
else
echo "$max_procs"
fi
}

parallel_build_flag() {
Expand Down

0 comments on commit 935eaf8

Please sign in to comment.