diff mbox series

[bug#65352] Fix time-machine and network

Message ID 86a5tqzze6.fsf@gmail.com
State New
Headers show
Series [bug#65352] Fix time-machine and network | expand

Commit Message

Simon Tournier Sept. 13, 2023, 12:32 a.m. UTC
Hi Ludo,

On Wed, 13 Sep 2023 at 22:16, Ludovic Courtès <ludo@gnu.org> wrote:

>> +    (('commit . (? commit-id? commit))
>> +     (let ((oid (string->oid commit)))
>> +       (->bool (commit-lookup repository oid))))
>> +    ((or ('tag . str)
>> +         ('tag-or-commit . str))
>> +     (false-if-git-not-found
>> +      (->bool (resolve-reference repository ref))))
>
> IIUC, the differences compared to what we had are:
>
>   1. 'tag references are now handled on the fast path
>      (‘reference-available?’ can return #t);
>
>   2. short commit strings are now always on the slow path
>      (‘reference-available?’ always returns #f).
>
> Is that correct?

No, or I am missing some details.

> It would be nice to have #1 without #2.

It’s already the case because of that:

         (option '("commit") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'ref `(tag-or-commit . ,arg) result)))

Currently, the heuristic to determine if it is a tag or a commit is
implemented by ’resolve-reference’.

Somehow, considering the command-line parser, the alternative is:

    #1 and #2 on the fast path (the patch)
 or
    #1 and #2 on the slow path (the current implementation)

Let ’pk’ (see below) to convince you. :-)

Before the proposed patch:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix time-machine --commit=v1.4.0 -- describe

;;; (ref (tag-or-commit . "v1.4.0"))

;;; (reference-available? #f)

;;; (remote-fetch NETWORK)
  C-c C-c

$ ./pre-inst-env guix time-machine --commit=8e2f32c -- describe

;;; (ref (tag-or-commit . "8e2f32c"))

;;; (reference-available? #f)

;;; (remote-fetch NETWORK)
  C-c C-c
--8<---------------cut here---------------end--------------->8---

After the proposed patch:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix time-machine --commit=v1.4.0 -- describe

;;; (ref (tag-or-commit . "v1.4.0"))

;;; (reference-available? #t)
  guix 8e2f32c
    repository URL: https://git.savannah.gnu.org/git/guix.git
    commit: 8e2f32cee982d42a79e53fc1e9aa7b8ff0514714

$ ./pre-inst-env guix time-machine --commit=8e2f32c -- describe

;;; (ref (tag-or-commit . "8e2f32c"))

;;; (reference-available? #t)
  guix 8e2f32c
    repository URL: https://git.savannah.gnu.org/git/guix.git
    commit: 8e2f32cee982d42a79e53fc1e9aa7b8ff0514714
--8<---------------cut here---------------end--------------->8---


Cheers,
simon

--8<---------------cut here---------------start------------->8---
--8<---------------cut here---------------end--------------->8---

Comments

Ludovic Courtès Sept. 14, 2023, 8:50 a.m. UTC | #1
Hi,

Simon Tournier <zimon.toutoune@gmail.com> skribis:

> On Wed, 13 Sep 2023 at 22:16, Ludovic Courtès <ludo@gnu.org> wrote:
>
>>> +    (('commit . (? commit-id? commit))
>>> +     (let ((oid (string->oid commit)))
>>> +       (->bool (commit-lookup repository oid))))
>>> +    ((or ('tag . str)
>>> +         ('tag-or-commit . str))
>>> +     (false-if-git-not-found
>>> +      (->bool (resolve-reference repository ref))))
>>
>> IIUC, the differences compared to what we had are:
>>
>>   1. 'tag references are now handled on the fast path
>>      (‘reference-available?’ can return #t);
>>
>>   2. short commit strings are now always on the slow path
>>      (‘reference-available?’ always returns #f).
>>
>> Is that correct?
>
> No

Sorry, could you explain what the difference is then on the hunk I
quoted?

  https://issues.guix.gnu.org/65352#34-lineno11

I see different treatment of short commit IDs and tags, and no
difference for full commit IDs.

Thanks,
Ludo’.
Ludovic Courtès Sept. 14, 2023, 9:04 a.m. UTC | #2
Hi again,

Simon Tournier <zimon.toutoune@gmail.com> skribis:

> Let ’pk’ (see below) to convince you. :-)
>
> Before the proposed patch:
>
> $ ./pre-inst-env guix time-machine --commit=v1.4.0 -- describe
>
> ;;; (ref (tag-or-commit . "v1.4.0"))
>
> ;;; (reference-available? #f)
>
> ;;; (remote-fetch NETWORK)
>   C-c C-c
>
> $ ./pre-inst-env guix time-machine --commit=8e2f32c -- describe
>
> ;;; (ref (tag-or-commit . "8e2f32c"))
>
> ;;; (reference-available? #f)
>
> ;;; (remote-fetch NETWORK)
>   C-c C-c

Yes this seems to confirm what I thought.

So anyway, go for it!

Great that you’re improving performance here.

Ludo’.
Simon Tournier Sept. 14, 2023, 9:42 a.m. UTC | #3
Hi,

On Thu, 14 Sept 2023 at 11:04, Ludovic Courtès <ludo@gnu.org> wrote:

> Yes this seems to confirm what I thought.

Hum, maybe we have miscommunicated because we were speaking on
different levels, I guess. :-)

By 'tag references, you meant (tag . "foo") right?  And that case is
not possible from the command-line and even I am not sure about the
use-case of passing (tag . "foo") to reference-available?.  Another
story.

Reconsidering your question, yes the case (tag . "foo") is currently
on the fast path and will stay on the fast path.

I have read "tag references" as the user is passing a Git tag.  Which
is currently managed the same way as short commit ID.

Hence my previous answer. :-)

> So anyway, go for it!

Cool!  I will proceed.

> Great that you’re improving performance here.

Now, we can give a look to bug#65787 [1]. ;-)

1: bug#65787: time-machine is doing too much network requests
Simon Tournier <zimon.toutoune@gmail.com>
Mon, 11 Sep 2023 11:41:54 +0200
id:87tts1jbbx.fsf@gmail.com
https://yhetil.org/guix/87tts1jbbx.fsf@gmail.com
https://issues.guix.gnu.org/msgid/87tts1jbbx.fsf@gmail.com

Cheers,
simon
Simon Tournier Sept. 22, 2023, 1:54 p.m. UTC | #4
Hi,

On Thu, 14 Sep 2023 at 11:42, Simon Tournier <zimon.toutoune@gmail.com> wrote:

>> So anyway, go for it!
>
> Cool!  I will proceed.

Done with 6d33c1f8061e86d63ab5c9ec75df9c58130c7264.

Cheers,
simon
diff mbox series

Patch

diff --git a/guix/git.scm b/guix/git.scm
index 1cb87a45607b..c927555cce18 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -481,6 +481,8 @@  (define* (update-cached-checkout url
                              (repository-open cache-directory)
                              (clone/swh-fallback url ref cache-directory))))
      ;; Only fetch remote if it has not been cloned just before.
+     (pk 'ref ref)
+     (pk 'reference-available? (reference-available? repository ref))
      (when (and cache-exists?
                 (not (reference-available? repository ref)))
        (remote-fetch (remote-lookup repository "origin")