Subject: Re: [bug#51427] [PATCH] nix: libstore: Do not remove unused links when deleting specific items.

From: Liliana Marie Prikler <[email-masked]>
Date: Sat, 23 Jul 2022 08:52:40 +0200

Am Samstag, dem 23.07.2022 um 01:07 +0200 schrieb Ludovic Courtès:
> Hi,
> 
> Maxime Devos <[email-masked]> skribis:
> 
> > On 22-07-2022 14:14, Ludovic Courtès wrote:
> > > Hi,
> > > 
> > > Liliana Marie Prikler<[email-masked]>  skribis:
> > > 
> > > > I don't think deleting links will ever be fast on that disk. 
> > > > But what I've been saying the whole time is that I don't always
> > > > need the links deleted.  I think adding "expert" switches to
> > > > skip these phases might actually be enough – after all, if I
> > > > ever do want to run a full GC, the information ought to be the
> > > > same, no?
> > > The expert will have to know that skipping that phase will have
> > > the effect of *not* freeing space on the device, so…
> > 
> > I believe the word "expert" implies that the expert knows that,
> 
> Apologies for being elliptic.  My point here, as has been discussed
> earlier in this thread, is that we can’t just skip that phase or we’d
> simply leave files around without actually deleting them.
> 
> Thus, a command-line switch to skip the phase doesn’t seem valuable
> to me because it’d let users run the GC in a way that doesn’t
> actually collect garbage.
> 
> I hope this is clearer!
As noted before, I don't always run GC to free up X amount of space. 
Even if I did, link deletion is greedy and frees up whatever it can. 
So the initial suggestion to only look at what might have been freed in
this gc already makes sense.  However, it was ruled complicated because
the GC is implemented in C++.  

My personal motivation to just skip the phase entirely comes from the
hypothesis that the store is in a sane state even if the links are not
deleted.  Particularly, if I `guix gc broken-item' and `guix build
broken-item', even without deleting links, the broken-item should now
be fixed.  This has practical advantages over `guix build --repair': if
the last `guix package' or `guix system' failed mid-way, any user, not
just root, can simply `guix gc' the broken items.

Now, I understand that as a default, you never want to skip this phase,
because it doesn't actually free up disk space.  But if you have a slow
disk with large space, do you really need to free all that much space,
or would it be fine to delay freeing it until a later date?

Cheers