From patchwork Tue Apr 1 13:58:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Hogan X-Patchwork-Id: 41126 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0DD5927BBEA; Tue, 1 Apr 2025 15:03:06 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6355027BBE2 for ; Tue, 1 Apr 2025 15:03:05 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzcBJ-0006s9-Hk; Tue, 01 Apr 2025 10:01:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tzcB4-0006Rg-CQ for guix-patches@gnu.org; Tue, 01 Apr 2025 10:01:19 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tzcB2-0000Lg-70; Tue, 01 Apr 2025 10:01:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=j5EDOcgy8k9S0j8UZ+vRQFMa6qu1kd1hn/m6n2lmqWU=; b=ge/tXAWIA5ih8rtM6c2gtKE5eu1qc3Aff4LLAiDialhVfAmmsvpWqEinLk3ZB3ZWA6YSV3pY4zx4swZ41pm4hC+vzwCOAOxeAbqF85TC8LDE2BRcDa6Fwg/A77RfR1ZHHWCQNBX6s0cI7xpO+QsReOLahFuL2chsqgOZMyWOhs701tFiGQ2ts0NCF4JvyTIlq6RDu/bQ5ZhbndGfcQHf0ftYla/nzgijrXmOWRz4ORXZl9TQfMeuN+P5/1qLxvLLK7uSa8+K2+dLeomBWmB24wnmR9xNrXLlsN4AEnHs3qPXklLtSNvJ8plPIAwZzVO2XNR5wG7A+EWJ+igzodRy5g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tzcAy-0001D1-Gt; Tue, 01 Apr 2025 10:01:12 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77432] [PATCH core-packages-team] build-system/gnu: Limit load average. Resent-From: Greg Hogan Original-Sender: "Debbugs-submit" Resent-CC: andreas@enge.fr, janneke@gnu.org, ludo@gnu.org, z572@z572.online, guix-patches@gnu.org Resent-Date: Tue, 01 Apr 2025 14:01:11 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 77432 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77432@debbugs.gnu.org Cc: Greg Hogan , Andreas Enge , Janneke Nieuwenhuizen , Ludovic =?utf-8?q?Court=C3=A8s?= , Zheng Junjie X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Andreas Enge , Janneke Nieuwenhuizen , Ludovic =?utf-8?q?Court=C3=A8s?= , Zheng Junjie Received: via spool by submit@debbugs.gnu.org id=B.17435160334108 (code B ref -1); Tue, 01 Apr 2025 14:01:11 +0000 Received: (at submit) by debbugs.gnu.org; 1 Apr 2025 14:00:33 +0000 Received: from localhost ([127.0.0.1]:47282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzcAD-00012X-DV for submit@debbugs.gnu.org; Tue, 01 Apr 2025 10:00:31 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33638) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tzc9z-0000y5-9C for submit@debbugs.gnu.org; Tue, 01 Apr 2025 10:00:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tzc9Q-0003YQ-EN for guix-patches@gnu.org; Tue, 01 Apr 2025 09:59:42 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tzc9M-0008QD-84 for guix-patches@gnu.org; Tue, 01 Apr 2025 09:59:34 -0400 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-4769f3e19a9so38794531cf.0 for ; Tue, 01 Apr 2025 06:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greghogan-com.20230601.gappssmtp.com; s=20230601; t=1743515970; x=1744120770; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=j5EDOcgy8k9S0j8UZ+vRQFMa6qu1kd1hn/m6n2lmqWU=; b=ykbSWmfqD+j1YOagU5dbv7cM42Dp0A1pPwwPoET5RZAGOwm0NXEHOqbhbzopj94213 IwnmIqLRk9SfIGI8qc6h3L3xlMw/yXDLm6y6LGhCGzozzfOGuzhbh8qBv2SNqtJqkUrl B4bOAzqRLCXUy1z/lQYn+m2q9LwQ0Hv2LxgvcgRj2nrF13gb4qBvm7pzUoK6ze+00Edt qDeDOaRtjPQeKunfurlr+oWWleu24tQdRiWC26mHSdtsSAuXU1PvHmyEH5PsBYW9QSOB SqNv1awjuXpsDXELhngTAE0C59fCv/PXkrlyoMa8TbF1xTMAg9evzVQ06S84JqQUr5tN G/jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743515970; x=1744120770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j5EDOcgy8k9S0j8UZ+vRQFMa6qu1kd1hn/m6n2lmqWU=; b=Fh6Wcg4kvnlHpmgNA+Ug6pkrpfo84Nc4t3Aq/mfyMY27fuEnnJroIraMrnwAsamyY/ wyo1Y8wIMgkKYw9O2yYk/T5z+1nY8ErZVqbgEcstIpa25hzv33fFQCEp20vA7pHkKJ4c 4hHDXSmYMIB3mN2Q+o20ve96p0DBu2296bK/V/XQGR3e2AehkSRNIW/o9QZjUSsnX+h+ 3sMNH5eaDQHgelNCe4hnwNq6nFsLF0bEsw7+TpVuLMJj0yUS78C5GG82rNZcRy0wUm3f wM4mHh5iiYuPAhMWEQ+pjbHX402ng9EKbUWTDd8WKWejvEIdKw82nvzybsXldNDRpzV5 jdmA== X-Gm-Message-State: AOJu0YxdzdwZO1x0jHFOXpt3/qWFRKe/VqFY5sxRFKxjtR4zzYqiO21N u1pH0Yr/U1eP3Knc4KgVLPKULo32XYzeNLBxAQcBBIUTR/S0vdX+ckqfHmVTdsSxJTV5hKg6T6s W X-Gm-Gg: ASbGncu9w1QiFRbcZOPyMJNDGiQnbVErpmSspGbbOQKgN2be7hIITWwOROxZUhE1xNT hDItUpkM7aTXJF3ifsb0apbZ34WltitTKeFqrWjrABbzEqv1fyekYw0SpIXXpB+u0tbwBnqqy81 edoPN8PTtF5ak8PUg27KOakZ7YoldyUTOjuumPrHjqlikOyTn63cA0QDWmImWXHK8RP05/lO36X dxiLNPUtjdtvS1+WUDmWTiCz0/qursRUi6nH+OBhHfbcVW2+zfMfYPiON/4NECqWWWcxNb+0tO+ KqfrKVZWgtPu1/Jd/T8heAiAQsq17JdhgAetn6SsrOCjRiEk1R5bxWnHq4a7p35TECZcJ3nSsDj ab+Qkt4N6d+vzlH4upeFW0tR60bbtjxBcX77Rnfwlc5GV X-Google-Smtp-Source: AGHT+IHko8dDisZpUFW1GuRSZ8GozbIerud0xhKNF0YQwY3oRSiPrGeq8DhZdyW021ZvuTM95MKuZg== X-Received: by 2002:ac8:5856:0:b0:476:add4:d2c3 with SMTP id d75a77b69052e-477f79d41e8mr167849531cf.38.1743515969841; Tue, 01 Apr 2025 06:59:29 -0700 (PDT) Received: from ip-10-117-149-49.evoforge.org (ec2-52-70-167-183.compute-1.amazonaws.com. [52.70.167.183]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-478b26f3968sm51775541cf.41.2025.04.01.06.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:59:29 -0700 (PDT) From: Greg Hogan Date: Tue, 1 Apr 2025 13:58:17 +0000 Message-ID: <8f564ac84639c8ff547e94843415744e7ca4ac12.1743512359.git.code@greghogan.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::833; envelope-from=code@greghogan.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches A nice feature of offload builds is that Guix will throttle the start of new jobs based on the overload-threshold. There is no equivalent for local builds, so one must either run builds in serial (--max-jobs=1) and endure single-threaded builds or run concurrent builds and watch the system overload as it runs multiple multi-threaded builds. I have been testing this "max-load" setting in both the gnu (attached) and cmake (soon on the c++-team branch) build systems. Both make and ninja will delay starting a new build action when the system is overloaded (the number of running processes is greater than, as configured below, the number of processors). ctest has a similar option "test-load" which compares against system load. From the following benchmark comparing the compilation of concurrent Folly builds, the "max-load" option reduced the overall time by 8.3%. Memory use also drops considerably since we are only running 1/4 of the processes at any time. If this is too late for inclusion in the core-packages-team branch, I would appreciate consideration from the team for inclusion on the c++-team branch. --8<---------------cut here---------------start------------->8--- $ guix shell -D folly $ CONCURRENT=4 $ for i in `seq 1 $CONCURRENT` ; do rm -rf build$i ; mkdir build$i ; cd build$i ; cmake ../folly & cd .. ; done ; wait $ time bash -c 'for i in `seq 1 '$CONCURRENT'` ; do cd build$i ; make -j`nproc` -l`nproc` & cd .. ; done ; wait' real 2m18.669s user 28m41.383s sys 4m35.790s $ for i in `seq 1 $CONCURRENT` ; do rm -rf build$i ; mkdir build$i ; cd build$i ; cmake ../folly & cd .. ; done ; wait $ time bash -c 'for i in `seq 1 '$CONCURRENT'` ; do cd build$i ; make -j`nproc`& cd .. ; done ; wait' real 2m31.158s user 30m44.591s sys 4m34.438s --8<---------------cut here---------------end--------------->8--- * guix/build/gnu-build-system.scm (build, check): Set max load. Change-Id: I97f1e3e59880b6ed23faed2038eb5279415e9c95 --- guix/build/gnu-build-system.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) base-commit: eb04a0d2c955f5fa9a721537c8202fc5c5959b19 diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index 0b94416a8d..e324c3488c 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -28,6 +28,7 @@ (define-module (guix build gnu-build-system) #:use-module (ice-9 regex) #:use-module (ice-9 format) #:use-module (ice-9 ftw) + #:use-module (ice-9 threads) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-34) @@ -385,7 +386,9 @@ (define* (build #:key (make-flags '()) (parallel-build? #t) #:allow-other-keys) (apply invoke "make" `(,@(if parallel-build? - `("-j" ,(number->string (parallel-job-count))) + `("-j" ,(number->string (parallel-job-count)) + ,(string-append "--max-load=" + (number->string (total-processor-count)))) '()) ,@make-flags))) @@ -424,7 +427,9 @@ (define* (check #:key target (make-flags '()) (tests? (not target)) (raise c))) (apply invoke "make" test-target `(,@(if parallel-tests? - `("-j" ,(number->string (parallel-job-count))) + `("-j" ,(number->string (parallel-job-count)) + ,(string-append "--max-load=" + (number->string (total-processor-count)))) '()) ,@make-flags))) (format #t "test suite not run~%")))