unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Christopher Baines <mail@cbaines.net>
Cc: 68266@debbugs.gnu.org
Subject: [bug#68266] [PATCH 1/7] gnu: Memozise make-ld-wrapper results.
Date: Wed, 10 Jan 2024 00:10:04 +0100	[thread overview]
Message-ID: <87plyaw1bn.fsf@gnu.org> (raw)
In-Reply-To: <878r4zr6a0.fsf@cbaines.net> (Christopher Baines's message of "Mon, 08 Jan 2024 19:01:58 +0000")

[-- Attachment #1: Type: text/plain, Size: 712 bytes --]

Hi,

Christopher Baines <mail@cbaines.net> skribis:

> I believe the reason packages from make-ld-wrapper were showing up
> multiple times in the cache for me is linked to it's use in the
> cross-base module, as part of the cross-gcc procedure.
>
> A later commit does change cross-gcc to return a single package record
> for some given arguments, so that probably resolves the biggest misuse
> of make-ld-wrapper.

Oh, I see.

Before resorting to memoization (which doesn’t come for free), we can
for instance make sure we do not create new package records from inputs
fields (since they are thunked, a fresh record would be created each
time the field is accessed).  Here’s an example:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1398 bytes --]

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 6ee7b315d8..ca3b41a4c7 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -306,6 +306,11 @@ (define* (cross-gcc target
 XGCC as the base compiler.  Use XBINUTILS as the associated cross-Binutils.
 If LIBC is false, then build a GCC that does not target a libc; otherwise,
 target that libc."
+  (define ld-wrapper
+    (make-ld-wrapper (string-append "ld-wrapper-" target)
+                     #:target (const target)
+                     #:binutils xbinutils))
+
   (package
     (inherit xgcc)
     (name (string-append "gcc-cross-"
@@ -313,8 +318,7 @@ (define* (cross-gcc target
                          target))
     (source
      (origin
-       (inherit
-        (package-source xgcc))
+       (inherit (package-source xgcc))
        (patches
         (append
          (origin-patches (package-source xgcc))
@@ -353,10 +357,7 @@ (define* (cross-gcc target
        ,@(cross-gcc-arguments target xgcc libc)))
 
     (native-inputs
-     `(("ld-wrapper-cross" ,(make-ld-wrapper
-                             (string-append "ld-wrapper-" target)
-                             #:target (const target)
-                             #:binutils xbinutils))
+     `(("ld-wrapper-cross" ,ld-wrapper)
        ("binutils-cross" ,xbinutils)
 
        ,@(let ((inputs (append (package-inputs xgcc)

[-- Attachment #3: Type: text/plain, Size: 1227 bytes --]


This particular one doesn’t have a huge impact on simple cases but it
might pay off for bigger graphs:

--8<---------------cut here---------------start------------->8---
$ GUIX_PROFILING=object-cache ./pre-inst-env guix build hello --target=aarch64-linux-gnu --no-grafts -d
/gnu/store/i8x1gg73x3fvxn4lrrgbcb97sz4qq1yx-hello-2.12.1.drv
Object Cache:
  fresh caches:    20
  lookups:       5514
  hits:          5008 (90.8%)
  cache size:     505 entries
$ # before:
$ GUIX_PROFILING=object-cache ./pre-inst-env guix build hello --target=aarch64-linux-gnu --no-grafts -d
/gnu/store/kdnh9bwg874aq8bvvw9y2vkl7z94icqa-hello-2.12.1.drv
Object Cache:
  fresh caches:    20
  lookups:       5406
  hits:          4907 (90.8%)
  cache size:     498 entries
--8<---------------cut here---------------end--------------->8---

> I think there's other cases (in the llvm and mold modules) where it
> looks like it's called multiple times with the same arguments, so maybe
> that's an argument for having memoization around make-ld-wrapper even
> though it's not needed for all uses.

On guix-devel, Efraim mentioned cargo-build-system packages.  Is that
related?

Thanks for looking into this!

Ludo’.

  reply	other threads:[~2024-01-09 23:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 16:35 [bug#68266] [PATCH 0/7] Memoize packages associated with cross building Christopher Baines
2024-01-05 16:40 ` [bug#68266] [PATCH 1/7] gnu: Memozise make-ld-wrapper results Christopher Baines
2024-01-05 16:40   ` [bug#68266] [PATCH 2/7] gnu: Memozise cross-binutils results Christopher Baines
2024-01-05 16:40   ` [bug#68266] [PATCH 3/7] gnu: Memozise cross-gcc results Christopher Baines
2024-01-05 16:40   ` [bug#68266] [PATCH 4/7] gnu: Memozise cross-kernel-headers results Christopher Baines
2024-01-05 16:40   ` [bug#68266] [PATCH 5/7] gnu: Memozise cross-mig results Christopher Baines
2024-01-05 16:40   ` [bug#68266] [PATCH 6/7] gnu: Memozise cross-libc results Christopher Baines
2024-01-05 16:40   ` [bug#68266] [PATCH 7/7] packages: rust: Memoize make-rust-sysroot results Christopher Baines
2024-01-12 14:13     ` Ludovic Courtès
2024-01-12 17:57       ` Christopher Baines
2024-01-13 16:15         ` Efraim Flashner
2024-01-15 16:54         ` Ludovic Courtès
2024-01-08 17:22   ` [bug#68266] [PATCH 1/7] gnu: Memozise make-ld-wrapper results Ludovic Courtès
2024-01-08 19:01     ` Christopher Baines
2024-01-09 23:10       ` Ludovic Courtès [this message]
2024-01-10 12:28         ` Christopher Baines
2024-01-10 12:57 ` [bug#68266] [PATCH v2] guix: store: Add report-object-cache-duplication Christopher Baines
2024-01-12 14:22   ` Ludovic Courtès
2024-01-12 18:26     ` Christopher Baines

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=87plyaw1bn.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=68266@debbugs.gnu.org \
    --cc=mail@cbaines.net \
    /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).