Skip to content
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

don't replace mapped files during nix-store --optimise #4756

Open
pennae opened this issue Apr 29, 2021 · 3 comments
Open

don't replace mapped files during nix-store --optimise #4756

pennae opened this issue Apr 29, 2021 · 3 comments

Comments

@pennae
Copy link
Contributor

pennae commented Apr 29, 2021

Is your feature request related to a problem? Please describe.
nix-store --optimise can replace a file that is currently gc-rooted by a running process with a hardlink to a file with the same contents. this doesn't save the space of the replaced copy until the process that uses the copy is restarted, and shows up with "executable was deleted" markers in process monitors like htop.

Describe the solution you'd like
don't replace files that are currently mapped by executables unless every copy is in use.

Describe alternatives you've considered
leaving things as is would probably be fine? that delays some of the space savings reported by the optimisation process though, and is pretty confusing at first glance.

@edolstra
Copy link
Member

Not sure this is a good idea. As you point out, the space savings eventually happen, and detecting whether a file is open sounds tricky and subject to race conditions.

@pennae
Copy link
Contributor Author

pennae commented Apr 29, 2021

to not confuse process monitors it would probably be sufficient to not replace executables/libraries that are currently mapped, and we do track those as gc roots. does that sound better?

if the current behaviour stays it might be a good idea to add a sentence about it to the documentation, eg "This operation may replace executable or library paths of running processes with hardlinks, making them show up as deleted in /proc." certainly confused me when we first saw it happen.

@stale
Copy link

stale bot commented Oct 30, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Oct 30, 2021
@stale stale bot removed the stale label Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants