Ludovic Courtès <[email protected]> writes:

> Hello Tomas!
>
> Tomas Volf <[email protected]> skribis:
>
>>> It’s a feature: use of ‘-L’ or ‘GUIX_PACKAGE_PATH’ disables caching.
>>>
>>> This is because in that case what the manifest and command line refer to
>>> is “uncontrolled”.
>>
>> Is this feature documented somewhere?  Manual page `Invoking guix shell'
>> either does not mention this or I cannot find it (both is possible ^_^).
>>
>> And follow-up question, is there a way to work around this feature,
>> possibly via a command-line option?  I have to admit that having 2s
>> penalty on every guix shell invocation is somewhat frustrating.
>
> Caching is not documented, it’s an “implementation detail”.  There’s no
> way to force the use of the cache (this could be bad since one could
> easily end up caching nonsensical results).

Details of caching are possibly an implementation detail, but the
caching itself very much is documented:

     In most cases, ‘guix shell’ caches the environment so that
     subsequent uses are instantaneous.  Least-recently used cache
     entries are periodically removed.  The cache is also invalidated,
     when using ‘--file’ or ‘--manifest’, anytime the corresponding file
     is modified.

     The ‘--rebuild-cache’ forces the cached environment to be
     refreshed.  This is useful when using ‘--file’ or ‘--manifest’ and
     the ‘guix.scm’ or ‘manifest.scm’ file has external dependencies, or
     if its behavior depends, say, on environment variables.

That is why I opened this bug, since the observed behavior was not
"instantaneous" and the impact of -L was not listed.  Now I understand
it does not belong into the "most cases".

> Maybe you can use a channel instead of -L?

Bit cumbersome, having to deal with time-machine and stuff.  For the
time being I have settled on GUILE_LOAD_PATH instead.

>>> For the same reason, ‘./pre-inst-env guix shell x y z’ in a checkout
>>> does not benefit from caching.
>>>
>>> See uses of ‘cache-is-authoritative?’ in guix/scripts/shell.scm.
>>
>> Thank you for the pointer, I will try to dig around a bit.  This seems
>> to talk about package cache, which is used for the specifications
>> resolving, correct?  Does it have other uses?  Because even when I
>> rewrite the manifest to uses packages->manifest, the shell command is
>> still not caching.  Is the package cache used even for
>> packages->manifest?  I lack knowledge in this area.
>
> The package cache is used to map package specs (name or name+version) to
> variables (like “make” -> (@ (gnu packages base) make)).

Right, and for specifications->manifest I do follow the logic.  But with
packages->manifest I am not doing any such mappings, so I do not
understand why I suffer the penalty from not having the cache.

>
> ‘cache-is-authoritative?’ essentially checks that you’re running from a
> channel without anything that could interfere: no ‘-L’, no
> ‘GUIX_PACKAGE_PATH’.  That’s the only case where we can safely use the
> package cache and, more generally, cache anything that touches packages.

I do follow here, thanks for the explanation.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.



Reply via email to