Subject: Re: bug#64746: [PATCH 2/2] scripts: time-machine: Error when attempting to visit too old commits.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 15 Aug 2023 18:14:51 +0200

Hello,

Maxim Cournoyer <[email-masked]> skribis:

> @@ -139,9 +149,20 @@ (define-command (guix-time-machine . args)
>      (with-git-error-handling
>       (let* ((opts         (parse-args args))
>              (channels     (channel-list opts))
> +            (guix-channel (find guix-channel? channels))
>              (command-line (assoc-ref opts 'exec))
> +            (ref          (assoc-ref opts 'ref))
> +            (checkout commit relation (update-cached-checkout
> +                                       (channel-url guix-channel)
> +                                       #:ref (or ref '())
> +                                       #:starting-commit
> +                                       %oldest-possible-commit))
>              (substitutes?  (assoc-ref opts 'substitutes?))
>              (authenticate? (assoc-ref opts 'authenticate-channels?)))

Following your question earlier today on IRC, I realized that this would
unconditionally add a Git checkout update every time ‘time-machine’ is
started.

This would noticeably degrade performance in the cache-hit case (when
running a cached channel set).  Currently, on cache hits,
‘cached-channel-instance’ directly returns ~/.cache/guix/profiles/xyz
without performing any Git or (guix store) operation.

This is important because it guarantees that one can run ‘guix
time-machine -C channels.scm -- COMMAND’ at pretty much the same speed
as ‘guix COMMAND’.

Perhaps the solution would be for ‘cached-channel-instance’ to have a
new #:validate-channel procedure (or similar) that would be passed
channel/commit/relation and would have the opportunity to validate,
before the thing is in cache.

How does that sound?

Ludo’.