risicle / nix-heuristic-gc

A more discerning cousin of nix-collect-garbage
GNU Lesser General Public License v2.1
57 stars 1 forks source link

Proposal: use ctime of gc-roots instead of atime #3

Open DavHau opened 1 year ago

DavHau commented 1 year ago

atime might be disabled on many systems and is also expensive.

How about a gc-roots with priorities based model? Tools like direnv, for example, already create gc-roots. Those could just touch the roots on each use. The garbage collector then just needs to delete all gc-root which haven't been used since 30days and do a standard garbage collect.

Advantages:

Disadvantages:

Alternatives:

An alternative approach that doesn't have the disadvantage mentioned above: Enable atime only on /nix/var/nix/gcroots and use those to determine the age of a gcroot. But now the downside is that this might require changing the partitioning scheme.

risicle commented 1 year ago

Am I missing something here? If a package has a gcroot, it is not garbage and thus can't be collected.

I'm not really wanting to get into the business of removing gcroots. That is basically what nix-collect-garbage's --delete-older-than option does, and not particularly what I was trying to achieve.