unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Efraim Flashner <efraim@flashner.co.il>
To: "Ludovic Courtès" <ludovic.courtes@inria.fr>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: ‘cargo-build-system’ makes everything slow
Date: Thu, 5 Dec 2024 08:32:00 +0200	[thread overview]
Message-ID: <Z1FI4DZxxNmkOAiu@3900XT> (raw)
In-Reply-To: <87ldwy3uhr.fsf@inria.fr>

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

On Mon, Dec 02, 2024 at 05:44:16PM +0100, Ludovic Courtès wrote:
> Hi,
> 
> I was profiling the ‘dependents’ procedure use by the new ‘guix build
> --dependents’ option in (guix scripts build).  Like ‘guix refresh -l’,
> it lowers all the packages to a bag, constructs the graph, and traverses
> all the nodes backward.  And it’s slow (~25s).
> 
> The profile is clear (test program below):
> 
> --8<---------------cut here---------------start------------->8---
> 100.0% with-exception-handler at ice-9/boot-9.scm:1689:4
>   100.0% thunk at guix/store.scm:686:4
>     100.0% run-with-store at guix/store.scm:2196:0
>       100.0% #x7f1cb0ccbeb0 at guix/scripts/build.scm:596:6
>         100.0% #x7f1c9c353ef0 at guix/graph.scm:98:7
>           99.6% #x7f1cb1b61e00 at guix/store.scm:1925:0
>             99.6% loop at guix/store.scm:1925:0
>               99.6% add-edge at guix/graph.scm:92:7
>                 99.6% #x7f1c9c3340bc at guix/scripts/graph.scm:187:10
>                   96.3% #x15d3b3bc
>                     95.8% bag-node-edges at guix/scripts/graph.scm:159:0
>                       93.1% package->bag at guix/packages.scm:1755:0
>                         92.5% thunk at guix/packages.scm:1763:4
>                           89.3% lower at guix/build-system/cargo.scm:305:0
>                             33.5% vhash-assq at ice-9/vlist.scm:539:0
>                               9.4% #x15d3cf98
>                             21.0% #x15d3de90
>                             3.6% vhash-cons at ice-9/vlist.scm:449:0
>                               0.9% #x15d3cf98
>                               0.1% #x15d3b430
>                                 0.1% #x15d3daf4
>                                   0.1% reap-pipes at ice-9/popen.scm:183:0
>                             2.5% filter-map at srfi/srfi-1.scm:681:0
>                               2.0% #x7f1cb0a997f4 at guix/build-system/cargo.scm:298:4
> --8<---------------cut here---------------end--------------->8---
> 
> 89% of the time is spent lowering ‘cargo-build-system’ packages,
> specifically in ‘expand-crate-sources’, which computes more or less the
> same thing over and over again.  (It also returns more than just
> transitive sources of Crates, AFAICS.)
> 
> Problem is little can be done about it, at least not without triggering
> a world rebuild.
> 
> But even then, it would help a lot to just not do that.
> 
> Thoughts?
> 
> Ludo’.

If its a world rebuild through the cargo-build-system its not so bad, CI
and QA build it out pretty quickly.  If it's everything, then yeah,
that's going to be slow.

Can we cache it after the first time like with guix shell?  Or a
hash-table of some sort? (I'm just using big words, I don't remember the
specifics of how the different hashing and caching bits work). Chris
Baines sped up the time to compute derivations for cross-compiling with
something with the make-rust-sysroot.

> (use-modules (statprof)
>              (ice-9 time)
>              (guix)
>              ((gnu packages) #:select (all-packages))
>              ((guix scripts build) #:select (dependents))
>              (gnu packages version-control))
> 
> (time (->bool (all-packages)))                    ;warm up
> 
> (with-store store
>   (statprof
>    (lambda ()
>      (dependents store (list libgit2) 1))
>    #:full-stacks? #t
>    #:display-style 'tree))


-- 
Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2024-12-05  6:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 16:44 ‘cargo-build-system’ makes everything slow Ludovic Courtès
2024-12-02 19:24 ` Ricardo Wurmus
2024-12-05  7:06   ` Efraim Flashner
2024-12-05 10:13     ` How to build Rust packages Ludovic Courtès
2024-12-08  9:20       ` Efraim Flashner
2024-12-08 11:51         ` indieterminacy
2024-12-10  8:15         ` Ludovic Courtès
2024-12-05 11:07     ` ‘cargo-build-system’ makes everything slow Liliana Marie Prikler
2024-12-05  6:32 ` Efraim Flashner [this message]

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=Z1FI4DZxxNmkOAiu@3900XT \
    --to=efraim@flashner.co.il \
    --cc=guix-devel@gnu.org \
    --cc=ludovic.courtes@inria.fr \
    /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).