unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* avoid Computing Guix derivation when not necessary
@ 2023-02-10 13:25 Nicolas Graves via Development of GNU Guix and the GNU System distribution.
  2023-02-12  0:10 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Graves via Development of GNU Guix and the GNU System distribution. @ 2023-02-10 13:25 UTC (permalink / raw)
  To: guix-devel


Hi guix!

I found an working solution to avoid waiting for the `Computing Guix
derivation' part when pulling or else.

Here's my snippet:

```
(use-modules
 (git)
 (guix profiles)
 (srfi srfi-1))

(reduce (lambda (x y) (and x y)) #f
        (map
         (lambda (x)
           (let* ((elts (cdadar (manifest-entry-properties x)))
                  (repository (repository-open (car (assoc-ref elts 'url))))
                  (commit (oid->string
                           (object-id
                            (revparse-single repository
                                             (car (assoc-ref elts 'branch)))))))
             (string= commit (car (assoc-ref elts 'commit)))))
         (manifest-entries (profile-manifest "./.guix-profile/guix"))))
```

For the moment, I'm using a profile and local development directories to
avoid this recomputation when I need to run guix system and guix home,
but I think this could be included to speed up guix pull when no new
commits are found.

The principle is simple: get commit and directory info from the profile
manifest, compare commits, if commits for all channels are the same, do
not try to update the profile.

It may not be as interessing for guix pull (need to pull anyway to get
the last commit...). If you think this can have some use, I can rework
on it for guix ;)

-- 
Best regards,
Nicolas Graves


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: avoid Computing Guix derivation when not necessary
  2023-02-10 13:25 avoid Computing Guix derivation when not necessary Nicolas Graves via Development of GNU Guix and the GNU System distribution.
@ 2023-02-12  0:10 ` Ludovic Courtès
  2023-02-13 10:37   ` zimoun
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2023-02-12  0:10 UTC (permalink / raw)
  To: Nicolas Graves via Development of GNU Guix and the GNU System distribution.
  Cc: Nicolas Graves

Hi Nicolas!

Nicolas Graves via "Development of GNU Guix and the GNU System
distribution." <guix-devel@gnu.org> skribis:

> I found an working solution to avoid waiting for the `Computing Guix
> derivation' part when pulling or else.
>
> Here's my snippet:
>
> ```
> (use-modules
>  (git)
>  (guix profiles)
>  (srfi srfi-1))
>
> (reduce (lambda (x y) (and x y)) #f
>         (map
>          (lambda (x)
>            (let* ((elts (cdadar (manifest-entry-properties x)))
>                   (repository (repository-open (car (assoc-ref elts 'url))))
>                   (commit (oid->string
>                            (object-id
>                             (revparse-single repository
>                                              (car (assoc-ref elts 'branch)))))))
>              (string= commit (car (assoc-ref elts 'commit)))))
>          (manifest-entries (profile-manifest "./.guix-profile/guix"))))
> ```
>
> For the moment, I'm using a profile and local development directories to
> avoid this recomputation when I need to run guix system and guix home,
> but I think this could be included to speed up guix pull when no new
> commits are found.

Wait, ‘guix system’ and ‘guix home’ do not do the infamous “Computing
Guix derivation” step; that’s only for ‘guix pull’, ‘guix time-machine’,
and inferiors.

What are you doing exactly?  :-)

> The principle is simple: get commit and directory info from the profile
> manifest, compare commits, if commits for all channels are the same, do
> not try to update the profile.
>
> It may not be as interessing for guix pull (need to pull anyway to get
> the last commit...). If you think this can have some use, I can rework
> on it for guix ;)

I don’t fully understand the use case yet, but who knows!

One marginal improvement would be sharing the cache that ‘time-machine’
uses with ‘guix pull’.  Last I looked it wasn’t as easy as one might
hope, but I forgot the details.

Thanks,
Ludo’.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: avoid Computing Guix derivation when not necessary
  2023-02-12  0:10 ` Ludovic Courtès
@ 2023-02-13 10:37   ` zimoun
  0 siblings, 0 replies; 3+ messages in thread
From: zimoun @ 2023-02-13 10:37 UTC (permalink / raw)
  To: Ludovic Courtès,
	Nicolas Graves via Development of GNU Guix and the GNU System distribution.
  Cc: Nicolas Graves

Hi,

On Sun, 12 Feb 2023 at 01:10, Ludovic Courtès <ludo@gnu.org> wrote:

>> The principle is simple: get commit and directory info from the profile
>> manifest, compare commits, if commits for all channels are the same, do
>> not try to update the profile.

Indeed, some improvements could be done in that direction.  For
instance,

--8<---------------cut here---------------start------------->8---
$ guix describe
Generation 89   Jan 17 2023 15:20:08    (current)
  guix 29efa27
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 29efa2791dafb042ca8ace77bcf8538fb404d492

$ guix pull --commit=29efa27
Updating channel 'guix' from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
Building from this channel:
  guix      https://git.savannah.gnu.org/git/guix.git   29efa27
Computing Guix derivation for 'x86_64-linux'... |
[...]
--8<---------------cut here---------------end--------------->8---

Going from one commit to the exact same commit should not trigger some
intensive «Computing Guix derivation».

Note that if I run “guix pull --commit=29efa27” two times in row, the
second one it displays: «nothing to be done» after «Computing Guix
derivation».

Last, note that:

    /var/guix/profiles/per-user/simon/current-guix -> current-guix-90-link

and

--8<---------------cut here---------------start------------->8---
$ /var/guix/profiles/per-user/simon/current-guix-90-link/bin/guix describe
  guix 29efa27
    repository URL: https://git.savannah.gnu.org/git/guix.git
    commit: 29efa2791dafb042ca8ace77bcf8538fb404d492

$ /var/guix/profiles/per-user/simon/current-guix-89-link/bin/guix describe
  guix 29efa27
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 29efa2791dafb042ca8ace77bcf8538fb404d492

$ readlink -f /var/guix/profiles/per-user/simon/current-guix-90-link
/gnu/store/g32zjrbr40fzp1rj5i6gx7hal20myfyv-profile

$ readlink -f /var/guix/profiles/per-user/simon/current-guix-89-link
/gnu/store/pk1i1dsagdby5pqydmvfbffg0i80wwvy-profile

$ diff -r --no-dereference \
  /gnu/store/g32zjrbr40fzp1rj5i6gx7hal20myfyv-profile/manifest \
  /gnu/store/pk1i1dsagdby5pqydmvfbffg0i80wwvy-profile/manifest
12c12
<       "/gnu/store/96bibk75vy5yvmilnycd8pl0l2bydcww-guix-29efa2791"
---
>       "/gnu/store/ldp0snjsac6hp1fikk5b8413pihm77di-guix-29efa2791"
20c20
<             (branch #f)
---
>             (branch "master")
--8<---------------cut here---------------end--------------->8---

Hum, maybe I have something twisted somewhere in my configuration.  From
my understanding, it comes from (guix scripts pull):

--8<---------------cut here---------------start------------->8---
        (match (find guix-channel? channels)
          ((? channel? guix)
           ;; Apply '--url', '--commit', and '--branch' to the 'guix' channel.
           (let ((url (or url (channel-url guix))))
             (cons (match ref
                     (('commit . commit)
                      (channel (inherit guix)
                               (url url) (commit commit) (branch #f)))
--8<---------------cut here---------------end--------------->8---

where ’branch’ should not be #f but instead inherit from ’guix’.  I
remember discussing this but I do not find where. :-)


> One marginal improvement would be sharing the cache that ‘time-machine’
> uses with ‘guix pull’.  Last I looked it wasn’t as easy as one might
> hope, but I forgot the details.

It could be nice! :-)  Last time I gave a look, I had an headache. ;-)

Cheers,
simon


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-13 10:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10 13:25 avoid Computing Guix derivation when not necessary Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2023-02-12  0:10 ` Ludovic Courtès
2023-02-13 10:37   ` zimoun

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).