cabal icon indicating copy to clipboard operation
cabal copied to clipboard

RFC: Store garbage collection

Open andreabedini opened this issue 1 year ago • 4 comments

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!)

andreabedini avatar Jun 19 '24 10:06 andreabedini

Related:

  • https://github.com/haskell/cabal/issues/3333
  • https://github.com/phadej/cabal-extras/tree/master/cabal-store-gc

andreabedini avatar Jun 19 '24 10:06 andreabedini

I think we also need roots for installed executables

fgaz avatar Jun 19 '24 11:06 fgaz

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.

geekosaur avatar Nov 18 '24 23:11 geekosaur

I've had two other thoughts on this:

  • we can in fact track --install-method=copy if 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

geekosaur avatar Oct 06 '25 18:10 geekosaur