From 88f528442228a3a9efdae7f49f602488fc917796 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 9 Jun 2022 19:09:43 +0200 Subject: [PATCH] Massage MAKE_JOBS for sys/debian.sh too ##build --- .github/workflows/ci.yml | 4 ++++ sys/build.sh | 46 +------------------------------------- sys/debian.sh | 9 +++----- sys/make-jobs.inc.sh | 48 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 51 deletions(-) create mode 100644 sys/make-jobs.inc.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f28627a0da..cb37218142 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,10 @@ jobs: run: | cp -f dist/plugins-cfg/plugins.nocs.cfg plugins.cfg ./configure --without-capstone && make -j + - name: Building muon/samu + run: | + r2pm -gci muon samu + muon m && samu -C m -j5 build-acr-gperf: name: linux-acr-gperf runs-on: ubuntu-20.04 diff --git a/sys/build.sh b/sys/build.sh index 8c2fc4825b..90667f3200 100755 --- a/sys/build.sh +++ b/sys/build.sh @@ -1,51 +1,8 @@ #!/bin/sh -GetPlatform() { - # Get OS and platform to decide if we need to limit memory usage - # during the build - PLATFORM=$(uname -a) - case "$PLATFORM" in - "Linux raspberrypi"*) MAX_MEM_PER_JOB=300000;; - "Linux"*) MAX_MEM_PER_JOB=150000;; - *) MAX_MEM_PER_JOB=200000 # If platform is not Linux (fallback value) - esac -} - -BuildJobsThrottler(){ - echo "Building on Linux : computing number of allowed parallel jobs." - echo "Maximum allowed RAM memory per job is $MAX_MEM_PER_JOB kB." - - # Get number of CPUs on this target - # getconf does not exit on Darwin. Use sysctl on Darwin machines. - CPU_N=$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu) - printf "Number of CPUs is %s and " "$CPU_N" - - # Get remaining RAM that could be used for this build - FREE_RAM=$(grep MemAvailable /proc/meminfo | sed 's/[^0-9]//g') - - DEFAULT_MAX_MEM_PER_JOB=200000 - [ -z "${MAX_MEM_PER_JOB}" ] && MAX_MEM_PER_JOB="$DEFAULT_MAX_MEM_PER_JOB" # Defensive, prevent devision by 0 - - # Assuming we may have many 300MB compilation jobs running in parallel - MEM_ALLOWED_JOBS=$((FREE_RAM / MAX_MEM_PER_JOB)) - echo "current free RAM allows us to run $MEM_ALLOWED_JOBS jobs in parallel." - - # Set number of build jobs to be run in parallel as the minimum between $MEM_ALLOWED_JOBS and $CPU_N - MAKE_JOBS=$((MEM_ALLOWED_JOBS/dev/null || sysctl -n hw.ncpu) + printf "Number of CPUs is %s and " "$CPU_N" + + # Get remaining RAM that could be used for this build + FREE_RAM=$(grep MemAvailable /proc/meminfo | sed 's/[^0-9]//g') + + DEFAULT_MAX_MEM_PER_JOB=200000 + [ -z "${MAX_MEM_PER_JOB}" ] && MAX_MEM_PER_JOB="$DEFAULT_MAX_MEM_PER_JOB" # Defensive, prevent devision by 0 + + # Assuming we may have many 300MB compilation jobs running in parallel + MEM_ALLOWED_JOBS=$((FREE_RAM / MAX_MEM_PER_JOB)) + echo "current free RAM allows us to run $MEM_ALLOWED_JOBS jobs in parallel." + + # Set number of build jobs to be run in parallel as the minimum between $MEM_ALLOWED_JOBS and $CPU_N + export MAKE_JOBS=$((MEM_ALLOWED_JOBS