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

opam install should cleanup the build directory right after a successful install instead of waiting until the end of the command #5884

Open
kit-ty-kate opened this issue Mar 17, 2024 · 1 comment

Comments

@kit-ty-kate
Copy link
Member

When installing certain number of packages from opam-repository, the size of the $OPAMROOT/<switch>/.opam-switch/build/ directory can become very large by the end of the command as each package's tarballs get extracted before they are built.

For example, when building async.v0.16.0, the directory reaches 2.8GB.
This is an issue for tools such as opam-health-check-ng, for which a common technique to improve its performance is to mount /var/lib/docker/ into tmpfs, which moves $OPAMROOT into RAM. RAM can be limited on some system and keeping all the build directories until the end makes the RAM usage much bigger than it should.

Code-wise, I believe that this code should be moved further up:

OpamFilename.rmdir build_dir

As a side-note, on Windows removing all the directories all at once at the end can take some time. If the removal were to be parallelized while other packages are being installed, it would be a good boost to performance.

@kit-ty-kate
Copy link
Member Author

It looks like the implementation of this feature request would be impeded by the <pkg>:build variable (see https://opam.ocaml.org/doc/Manual.html#pkgvar-build). Is this used anywhere? If not I feel like there is very little use for it apart from _:build and we might want to remove it (at least the cross-packages version of it). Furthermore I believe this variable is currently broken when the dependency hasn't been installed at the same time as the package using the variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant