]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
make-debs.sh: Avoid OOM errors during build 65313/head
authorZack Cerza <zack@cerza.org>
Fri, 29 Aug 2025 17:38:40 +0000 (11:38 -0600)
committerZack Cerza <zack@cerza.org>
Fri, 29 Aug 2025 19:52:16 +0000 (13:52 -0600)
This uses the logic from: https://github.com/ceph/ceph-build/blob/f074f1ce7fc05a5ac69e06fa9fa7ae45858b0110/scripts/build_utils.sh#L1411-L1435

Signed-off-by: Zack Cerza <zack@cerza.org>
CEPH-BUILD-JOB: ceph-dev-pipeline
ARCHS: x86_64
DISTROS: jammy noble
FLAVORS: default

make-debs.sh

index 7eaaccdb3dc0d1ac51e160663618774453a1ab32..93f5e1120c8fde677fbd892686f598ce0672f9c9 100755 (executable)
@@ -80,14 +80,22 @@ fi
 # b) do not sign the packages
 # c) use half of the available processors
 #
-: ${NPROC:=$(($(nproc) / 2))}
-if test $NPROC -gt 1 ; then
-    j=-j${NPROC}
+: ${NPROC:=$(nproc)}
+RAM_MB=$(vmstat --stats --unit m | grep 'total memory' | awk '{print $1}')
+if test "$NPROC" -gt 50; then
+    MAX_JOBS=$((${RAM_MB} / 4000))
+else
+    MAX_JOBS=$((${RAM_MB} / 3000))
+fi
+if test "$NPROC" -gt "$MAX_JOBS"; then
+    JOBS_FLAG="-j${MAX_JOBS}"
+else
+    JOBS_FLAG="-j${NPROC}"
 fi
 if [ "$SCCACHE" != "true" ] ; then
     PATH=/usr/lib/ccache:$PATH
 fi
-PATH=$PATH dpkg-buildpackage $j -uc -us
+PATH=$PATH dpkg-buildpackage $JOBS_FLAG -uc -us
 cd ../..
 mkdir -p $VERSION_CODENAME/conf
 cat > $VERSION_CODENAME/conf/distributions <<EOF