Message ID | 877d1buw70.fsf@netris.org |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> 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 <patchwork@mira.cbaines.net>; 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 <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org>) 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 <Debian-debbugs@debbugs.gnu.org>) 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 <Debian-debbugs@debbugs.gnu.org>) 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 <Debian-debbugs@debbugs.gnu.org>) 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 <mhw@netris.org> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Oct 2022 22:06:01 +0000 Resent-Message-ID: <handler.57788.B57788.16651803376592@debbugs.gnu.org> 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 <efraim@flashner.co.il> 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 <debbugs-submit-bounces@debbugs.gnu.org>) 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 <mhw@netris.org>) 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 <mhw@netris.org>) id 1ogvTD-0003r1-HA; Fri, 07 Oct 2022 18:05:27 -0400 From: Mark H Weaver <mhw@netris.org> In-Reply-To: <Y0ABGL/cobN/iYl4@3900XT> References: <874jxahlpi.fsf@netris.org> <Y0ABGL/cobN/iYl4@3900XT> Date: Fri, 07 Oct 2022 18:04:24 -0400 Message-ID: <877d1buw70.fsf@netris.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#57788] gnu: rust: Disable debug info to reduce build requirements
|
|
Commit Message
Mark H Weaver
Oct. 7, 2022, 10:04 p.m. UTC
Hi Efraim, Efraim Flashner <efraim@flashner.co.il> 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
Comments
On Fri, Oct 07, 2022 at 06:04:24PM -0400, Mark H Weaver wrote: > Hi Efraim, > > Efraim Flashner <efraim@flashner.co.il> 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--- > 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) > --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. In my testing I didn't see a significant difference between using CARGO_PROFILE_DEV_DEBUG, debug = false or both. My personal preference would be to use CARGO_PROFILE_DEV_DEBUG for rust-bootstrap and then use debug = false for the rest, since it keeps the config options together in the config.toml file. I did also experiment with parallel-compiler = true to build a multithreaded rustc but I wasn't able to prevent the test suite for rust-1.60 to not error out. I also tried skipping the tests for rust itself and compiling librsvg with it, but they were serious when they said it wasn't ready.
Hi Efraim, I was surprised to see commit 01be1973f464cb81cdece54f7858f0dee46abb50 attributed solely to me, although I did not actually author that commit. In the future, please do not attribute commits to me that I did not write or approve of. At minimum, if you modify a commit that I proposed, please add a "Modified-by" line in the commit log. If you made radical changes to a commit that I proposed, better to list yourself as author and maybe say "based on a proposal by Mark H Weaver" in the commit log. One important modification that got lost in your simplified commit was the change I made to mrustc/tools/minicargo/build.cpp, which I evidently found necessary. Without that change, I do not know if Rust can still be bootstrapped on a small machine such as mine. Anyway, thanks for working on it, and for the other important work you've done on dramatically shortening the Rust bootstrap. Regards, Mark
On Fri, Oct 28, 2022 at 06:40:27AM -0400, Mark H Weaver wrote: > Hi Efraim, > > I was surprised to see commit 01be1973f464cb81cdece54f7858f0dee46abb50 > attributed solely to me, although I did not actually author that commit. > > In the future, please do not attribute commits to me that I did not > write or approve of. At minimum, if you modify a commit that I > proposed, please add a "Modified-by" line in the commit log. If you > made radical changes to a commit that I proposed, better to list > yourself as author and maybe say "based on a proposal by Mark H Weaver" > in the commit log. > > One important modification that got lost in your simplified commit was > the change I made to mrustc/tools/minicargo/build.cpp, which I evidently > found necessary. Without that change, I do not know if Rust can still > be bootstrapped on a small machine such as mine. > > Anyway, thanks for working on it, and for the other important work > you've done on dramatically shortening the Rust bootstrap. > > Regards, > Mark Sorry about that, I was modifying as I went and after updating mrustc to a later commit the "if (true) add '-g'" spots in mrustc got changed to depend on enabling debug, and I found that after removing -g from the makefiles it wasn't being added anymore. I'll make sure to be more careful in the future about commit attribution. About mrustc/tools/minicargo/build.cpp, it looked to me like that was specifically about building mrustc using the codeblocks IDE. I've tried to rebuild rust-1.54 on my pine64, which has 2GB of ram and 4GB of swap and that didn't seem to be enough so I'm retrying that with just 1 core. I'm also trying on my pinebook pro, with 4GB of ram and 6GB of swap and I'll see if it works there or if it needs more tuning.
Hi Efraim, Efraim Flashner <efraim@flashner.co.il> writes: > Sorry about that, I was modifying as I went and after updating mrustc to > a later commit the "if (true) add '-g'" spots in mrustc got changed to > depend on enabling debug, and I found that after removing -g from the > makefiles it wasn't being added anymore. Ah, so perhaps there's no longer any need to modify mrustc/tools/minicargo/build.cpp. So much the better! > I'll make sure to be more careful in the future about commit > attribution. Thank you, Efraim. I'm grateful to you for your work on this. Mark
I'm closing this ticket now. 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)