unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Efraim Flashner <efraim@flashner.co.il>
Cc: 57788@debbugs.gnu.org
Subject: [bug#57788] [PATCH] gnu: rust: Disable debug info to reduce build requirements
Date: Fri, 07 Oct 2022 18:04:24 -0400	[thread overview]
Message-ID: <877d1buw70.fsf@netris.org> (raw)
In-Reply-To: <Y0ABGL/cobN/iYl4@3900XT>

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.

Thanks for working on it, Efraim!

      Regards,
        Mark

-- 
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>.




  reply	other threads:[~2022-10-07 22:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 23:56 [bug#57788] [PATCH] gnu: rust: Disable debug info to reduce build requirements Mark H Weaver
2022-10-07 10:36 ` Efraim Flashner
2022-10-07 22:04   ` Mark H Weaver [this message]
2022-10-12 10:45     ` Efraim Flashner
2022-10-28 10:40       ` Mark H Weaver
2022-10-29 19:39         ` Efraim Flashner
2022-11-01  5:11           ` Mark H Weaver
2022-11-01  5:13           ` bug#57788: " Mark H Weaver
2022-10-09 12:38   ` [bug#57788] " Efraim Flashner

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=877d1buw70.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=57788@debbugs.gnu.org \
    --cc=efraim@flashner.co.il \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).