-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
idea: nix-collect-garbage option to also respect creation date of a derivation #2793
Comments
I don't think Nix keeps track of creation date for derivations. ctime should always be 0. Perhaps with something like FUSE we could keep track of that or even things like last access time: https://groups.google.com/forum/#!searchin/nix-devel/nix-collect-garbage%7Csort:date/nix-devel/ej-21kuvCyw/0huYqAosBQAJ |
There is an SQLite database, maybe that keeps track of this? |
Yes, the SQLite database keeps track of the "registration time", i.e. the time the path was added to the DB:
So the garbage collector could use this. However it's not clear whether this is a good idea because an old path may still be recently used. (Once upon a time the garbage collector used |
Well it will still be an improvement over current behavior which purges these paths anyway. Note I'm not asking to replace current generation check, just add extra requirement before removing (perhaps an option to enable/disable it if this ruins someone's workflow). The atime also would be nice to use if available (I don't have way to check right now, but what does system report as atime when it's not available, is it 0, current time, or some other value?) with 0 it would just work without extra code, otherwise we would ignore it. |
I marked this as stale due to inactivity. → More info |
Still important to me. Even if slightly flawed, discarding only what's been added >n days ago would still be very helpful and a nice medium between --gc and --delete. Given that the world is rebuilt every month or so anyways, the chance of discarding recently used output paths is rather slim even with this flawed method. Maybe gc could also differentiate between fixed-output (, CA) and regular drvs. Another useful proprerty to filter for when gc'ing would be drvs that are in the build-time closure of drvs that are supposed to be kept (gcroot'd or added too recently). |
I marked this as stale due to inactivity. → More info |
This may risk going offtopic, but I'd quite like an access-time-basis for prioritizing deletions. Doing quite a lot of nix development, many things I build may not currently be in a gcroot, but it's likely that a new build will want to reference a recently accessed package again. |
@risicle atimes aren't recorded since the Nix store you access as a user is readonly to you. |
Mmmmm atime is certainly updated for me.
|
Ah, might be because of |
An advantage I see of atime is it'll get updated even if your machine is sharing packages over e.g. |
I've been playing with some ideas around this over at https://github.com/risicle/nix-heuristic-gc |
+1 for nix-serve and nix-serve-ng, doing remote copies through |
This is boolean "or", not boolean "and":
So relatime (which is the default on many systems IIRC?) should be well-suited for gc removal? |
I was wondering why things were being deleted! |
garbage collect only works on generations. See: NixOS/nix#2793 Also added perf package
Currently
nix-collect-garbage
has an option to not delete older entries than given amount of time. It looks like that setting only applies to generations. If someone uses nix for development and rarely usesnix-env
calling garbage collection will still wipe most of derivations. If there was an option to also check time when given store path was created and not delete anything recent it would reduce amount of packages that need to be fetched again and it would also reduce amount of data fetched from the caching server.The text was updated successfully, but these errors were encountered: