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:
- much cheaper in terms of IO
- compatible to all file systems
Disadvantages:
- relies on tools creating gc-roots and keeping them hot -> requires patching of tools
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.
atimemight be disabled on many systems and is also expensive.How about a
gc-roots with prioritiesbased model? Tools like direnv, for example, already create gc-roots. Those could justtouchthe 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/gcrootsand use those to determine theageof a gcroot. But now the downside is that this might require changing the partitioning scheme.