From patchwork Fri Oct 7 22:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark H Weaver X-Patchwork-Id: 43216 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 A072827BBEA; Fri, 7 Oct 2022 23:06:31 +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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable 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 4659127BBE9 for ; Fri, 7 Oct 2022 23:06:31 +0100 (BST) Received: from localhost ([::1]:49032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogvUE-0003Oh-EN for patchwork@mira.cbaines.net; Fri, 07 Oct 2022 18:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogvTm-0003OR-Vl for guix-patches@gnu.org; Fri, 07 Oct 2022 18:06:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogvTm-0003vp-2o for guix-patches@gnu.org; Fri, 07 Oct 2022 18:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogvTl-0001iw-ME for guix-patches@gnu.org; Fri, 07 Oct 2022 18:06:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57788] [PATCH] gnu: rust: Disable debug info to reduce build requirements Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Oct 2022 22:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57788 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Efraim Flashner Cc: 57788@debbugs.gnu.org Received: via spool by 57788-submit@debbugs.gnu.org id=B57788.16651803376592 (code B ref 57788); Fri, 07 Oct 2022 22:06:01 +0000 Received: (at 57788) by debbugs.gnu.org; 7 Oct 2022 22:05:37 +0000 Received: from localhost ([127.0.0.1]:37619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogvTM-0001iG-RR for submit@debbugs.gnu.org; Fri, 07 Oct 2022 18:05:37 -0400 Received: from world.peace.net ([64.112.178.59]:35682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogvTK-0001i3-VM for 57788@debbugs.gnu.org; Fri, 07 Oct 2022 18:05:35 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogvTD-0003r1-HA; Fri, 07 Oct 2022 18:05:27 -0400 From: Mark H Weaver In-Reply-To: References: <874jxahlpi.fsf@netris.org> Date: Fri, 07 Oct 2022 18:04:24 -0400 Message-ID: <877d1buw70.fsf@netris.org> MIME-Version: 1.0 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" X-getmail-retrieved-from-mailbox: Patches Hi Efraim, Efraim Flashner writes: > On Tue, Sep 13, 2022 at 07:56:46PM -0400, Mark H Weaver wrote: >> The following patch, which I've tested only on my private branch of >> Guix, dramatically reduces the amount of memory and time required to >> build Rust. >> >> With this patch applied, I'm able to build Rust on a Thinkpad X200 with >> only 4 GB of RAM using both cores. Without it, I'm unable to build Rust >> at all, even with parallel builds disabled, running in a bare text-only >> terminal, and with every nonessential daemon stopped. When I tried, a >> single compiler process used more than 9 GB of virtual memory with heavy >> thrashing before the OOM killer finally put it out of its misery. > > Your x200 is an x86_64? Yes, with only 4 GB of RAM. > How much RAM+swap did you end up using with this patch? During the times when I was monitoring it, the build process with parallel build enabled (2 parallel jobs) fit entirely within my 4 GB of RAM, while also running a modest X session with Emacs. >> Moreover, with this patch the builds are dramatically faster than I've >> previously observed. In my earlier bootstraps of Rust (up to >> rust-1.51), it took about 5 hours to build each compiler on my machine. >> Now it takes only about 2 hours per compiler, except for the initial >> bootstrap (1.54) which takes about 4 hours. > > I tested it out on my machine, it brought the build time down from 101 > minutes to 71 minutes. Not the same improvement, but still noticeable. I'm glad to hear it! I guess the improvement was more dramatic on my system because it was previously thrashing (lots of swapping due to insufficient RAM), whereas your system probably has enough RAM :-) >> The following patch is meant to be applied to the 'staging' branch, but >> I've only tested it on my own private branch, which is based on very old >> 'master' (April 2021) and is thus quite different by now. >> >> I offer it here in case it might be of interest, although it hasn't been >> tested on contemporary Guix. I'm not subscribed to this mailing list, >> so please make sure to CC me on any replies you'd like me to see. >> >> Regards, >> Mark > > I'm building out to librsvg on staging right now with this patch > applied, so hopefully we'll see that it's good. > > I'm assuming that setting CARGO_PROFILE_DEV_DEBUG to false won't cause > any problems. After writing my previous message, I ended up adding another hunk to my patch, to disable debugging in the final 'rust' compiler: --8<---------------cut here---------------start------------->8--- --8<---------------cut here---------------end--------------->8--- In retrospect, for the post-mrustc compilers, it might have been sufficient to add "debug = false" to the [rust] section of config.toml in the 'rust-1.55' variable. This might also eliminate the need to set CARGO_PROFILE_DEV_DEBUG. However, I haven't tried it. Thanks for working on it, Efraim! Regards, Mark diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index 25295a283e..cf2c66f334 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -704,6 +704,13 @@ (define-public rust (("^python =.*" all) (string-append all "gdb = \"" gdb "/bin/gdb\"\n")))))) + (add-before 'build 'disable-debug + (lambda _ + ;; reduce memory requirements during the build + (setenv "CARGO_PROFILE_DEV_DEBUG" "false") + (substitute* "config.toml" + (("\\[rust\\].*" all) + (string-append all "debug = false\n"))))) (replace 'build ;; Phase overridden to also build rustfmt. (lambda* (#:key parallel-build? #:allow-other-keys)