public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jesus Checa Hidalgo <jchecahi@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/rust] main: rpm-rebuild/stratisd: limit paralellism
Date: Mon, 24 Aug 2026 17:23:23 GMT	[thread overview]
Message-ID: <178759220342.1.7602526321647950159.tests-rust-1ce23fd6bd0f@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/rust
            Branch : main
            Commit : 1ce23fd6bd0f20f4445482bc771d94a87285cbf0
            Author : Jesus Checa Hidalgo <jchecahi@redhat.com>
            Date   : 2026-08-14T11:49:52+02:00
            Stats  : +39/-4 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/rust/c/1ce23fd6bd0f20f4445482bc771d94a87285cbf0?branch=main

            Log:
            rpm-rebuild/stratisd: limit paralellism

Newer versions of stratisd have an obscene memory consumption,
reaching peaks of >5GiB in some rustc calls. This commit adds
logic to calculate a ratio of MiB per core in the system running
the test, then apply that number of cores to RPM_BUILD_NCPUS.
Start using 4GiB for building stratisd.
Older versions (RHEL 9 and older) are not affected

---
diff --git a/tests/Sanity/rpm-rebuild/runtest.sh b/tests/Sanity/rpm-rebuild/runtest.sh
index f3537b0..261766f 100755
--- a/tests/Sanity/rpm-rebuild/runtest.sh
+++ b/tests/Sanity/rpm-rebuild/runtest.sh
@@ -2,6 +2,10 @@
 # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
 . /usr/share/beakerlib/beakerlib.sh || exit 1
 
+# Available environment variables to configure
+# PKG_TO_BUILD (mandatory): rpm packages to run rpmbuild on.
+# MB_PER_CPU (optional): How many MB of ram per number of cpus should have.
+
 # Analyze build failure and determine if it's a resource issue or real failure
 analyze_build_failure() {
     local logfile="$1"
@@ -38,6 +42,25 @@ analyze_build_failure() {
     fi
 }
 
+function get_memory_limited_cores() {
+    # Return the number of cores in a way that each core has access to at least
+    # the specified MB of physical RAM (default 1024MB).
+    # Swap is not counted to avoid severe performance degradation.
+    local mb_ram="$(free -m | awk '/Mem:/ {print $2}')"
+    local cores="$(nproc)"
+    local mb_per_core="${1:-1024}"
+
+    local max_cores=$((mb_ram / mb_per_core))
+
+    if [ "$max_cores" -le "0" ]; then
+        echo "1"
+    elif [ "$max_cores" -lt "$cores" ]; then
+        echo "$max_cores"
+    else
+        echo "$cores"
+    fi
+}
+
 PACKAGE="$(rpm -qf "$(which rustc)")"
 
 rlJournalStart
@@ -59,6 +82,12 @@ rlJournalStart
             rlDie "The package must be passed over PKG_TO_BUILD environment variable."
         fi
 
+        if [[ -n "${MB_PER_CPU}" ]]; then
+            MAX_CPUS=$(get_memory_limited_cores "$MB_PER_CPU")
+            rlLog "Running rpmbuild with max cores: $MAX_CPUS"
+            export RPM_BUILD_NCPUS="$MAX_CPUS"
+        fi
+
         # Log basic system resources. If we start seeing failures due to disk
         # out of space, timeouts, or OOMs this will help identifying where
         # the issue might be.
@@ -95,13 +124,13 @@ rlJournalStart
     rlPhaseStartTest
         set -o pipefail
         LOGFILE="${SRPM}_rpmbuild.log"
-        BUILD_CMD="rpmbuild -bb ${SPECDIR}/${SPECNAME}"
+        BUILD_CMD=(rpmbuild -bb "${SPECDIR}"/"${SPECNAME}")
 
         # Log the command being executed (for visibility in test output)
-        rlLog "Executing: $BUILD_CMD"
+        rlLog "Executing: ${BUILD_CMD[*]}"
 
         # Execute rpmbuild silently, saving complete log to file
-        if $BUILD_CMD &> "$LOGFILE"; then
+        if "${BUILD_CMD[@]}" &> "$LOGFILE"; then
             rlPass "rpmbuild succeeded"
         else
             # Analyze cause of failure

diff --git a/tests/Sanity/rpm-rebuild/stratisd.fmf b/tests/Sanity/rpm-rebuild/stratisd.fmf
index b3698fe..e01d5b4 100644
--- a/tests/Sanity/rpm-rebuild/stratisd.fmf
+++ b/tests/Sanity/rpm-rebuild/stratisd.fmf
@@ -3,7 +3,8 @@ require+:
   - stratisd
 environment+:
   PKG_TO_BUILD: "stratisd"
-duration: 2h
+  MB_PER_CPU: "4096"
+duration: 3h
 tier: 1
 
 tag:
@@ -15,3 +16,8 @@ adjust+:
   - enabled: false
     when: distro == rhel-8 and distro >= rhel-8.9
     continue: false
+
+  # Older stratisd packages (RHEL 9 and older) are much less RAM demanding
+  - environment+:
+      MB_PER_CPU: 2048
+    when: distro < rhel-10

                 reply	other threads:[~2026-08-24 17:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178759220342.1.7602526321647950159.tests-rust-1ce23fd6bd0f@fedoraproject.org \
    --to=jchecahi@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox