RFC: Store garbage collection
This is a draft design for store garbage collection that I put together during ZuriHac. I admit I haven't explored existing designs.
The recipe is simple and similar to what nix does.
- We keep updated a list of unit-ids that the project plan references just like we do with plan.json
- At the same time we create a backlink from storedir/gc-root to the project dist directory.
This should allow garbage collection later on:
- we check the gc-root directory for old roots and removes them (by checking whether the symlink resolves).
- we traverse the dependency graph and do the proper garbage collection.
- [ ] Patches conform to the coding conventions.
- [ ] Any changes that could be relevant to users have been recorded in the changelog.
- [ ] The documentation has been updated, if necessary.
- [ ] Manual QA notes have been included.
- [ ] Tests have been added. (Ask for help if you don’t know how to write them! Ask for an exemption if tests are too complex for too little coverage!)
Related:
- https://github.com/haskell/cabal/issues/3333
- https://github.com/phadej/cabal-extras/tree/master/cabal-store-gc
I think we also need roots for installed executables
Not only that, but a warning that if you use --install-method=copy, the executable can't be a GC root because we'd need to be able to follow the symlink back to the store entry it roots.
I've had two other thoughts on this:
-
we can in fact track
--install-method=copyif we symlink it into the store separately, possibly with some kind of installed-file manifest -
we should record
--package-envinstalls and treat the environment files as GC roots