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
local cache of binary packages #629
Comments
Adding the rest of the discussion that happened on the caml-list. Chet Murthy wrote:
Malcolm Matalka wrote:
Chet Murthy wrote:
|
fpm looks extremely interesting: I think OPAM doesn't need to implement everything. The thread had distinct part:
Regards, |
Hello, Can someone provide hints on how to plug fpm into OPAM? Let's say this will be an experimental feature, just try and play with it. I'd like to give a try at it, but no idea on when I'll have time for this in fact. Regards, |
Funnily, on a machine with low RAM (1Gb) and no swap, the compiler cannot be compiled. How is the front of supporting binary packages repositories in OPAM? |
There is a prototype of this using hooks, see https://github.com/ocaml/opam/blob/master/shell/opam-bin-cache.sh |
Is it possible to combine those cache hooks with the sandbox hooks? |
A quick comment to talk about esy too. Don't know if it's the good place. You probably know about it. They have a cache system too which seems to be pretty efficient. But rather than to copy the directories from the cache to the "switch", they put in the environment the paths to all the packages that are required by the switch. I think it also avoid some problems like relocating |
yes, of course
this is where there is quite a bit of difference: IIUC, in esy, every package is installed to its own subtree, which is a nice property that allows easy mix & matching of already compiled packages. It requires quite a bit of cooperation from the underlying systems, though, in this case — correct me if I am wrong — significant ocamlfind hacks. This is a mode that we would definitely be interested in supporting in opam, but it also remains an important part of the project philosophy to be agnostic and pragmatic on what the packages do (hence the simple shell commands for |
@AltGr I would encourage you to publish and promote this caching hook to get feedback. It's a very nice feature and even if it doesn't work perfectly just yet, I'm sure lot's of people would be interested. Enabling it would allow you to get feedback quickly. |
Is there a reason to not release and enable the cache script by default? It seems to work very well. This is definitely something that would push the usage of local switches forward I think. And help to fight the "competition". I understand that for some packages like the ocaml compiler relocation might be a problem. But most of the time it works fine. And it could create motivation to fix this issue.
For people who want to have sandbox and cache at the same time, here is my configuration
https://gist.github.com/Khady/587a5e52679610b6aecfc4dbbd95e54d
|
I have tested it for a while, and while it works correctly at first, once you e.g. remove the original switch the cache was made from, in my experience it doesn't behave well... Of course, there might be progress in ocamlfind configuration since then, that makes this more reliable? You can have more detail at ocaml/opam-repository#10863 |
@Khady thanks for sharing your conf; I could publish a small script to easily enable/disable it, for those interested in testing ? |
@AltGr please do, this is a really good feature and I think it's worth advertising it, even if it's not completely finished. |
I've given this a stab, and it looks like it needs a small tweak for macOS. It's currently causing the failure of any package that's already been installed elsewhere:
macOS nor BSD |
I created a 300 USD bounty for this issue. To be clear, I consider that solving it also requires solving ocaml/opam-repository#10863. Actually most of the work is probably on ocaml/opam-repository#10863 as |
@Khady I'm curious, is this out of your pocket or is this your company/employer? |
Out of my pocket.
|
This has been added directly in dune, see https://dune.readthedocs.io/en/stable/caching.html |
Isn't |
From the front page of opam.ocaml.org since time immemorial: "opam is a source-based package manager for OCaml <...>" (emphasis mine). While we provide hooks for binary caching and reproducibility, it is very unlikely that the opam 2.x series will ever provide binary packages directly as a supported feature. That is down to the creator of the packages to architect, as it is deeply tied into the build mechanism of the package. So, you are welcome to opam package C packages up, as are Coq developers for their tools, and as I do for running various shell scripts, but they all need to sort out their own caching mechanisms using the hooks. Meanwhile, for the common case of compiling OCaml code in the ocaml/opam-repository, dune provides a caching mechanism that works at the level of build rules, and across opam packages. Other OCaml build systems can also provide their own caching; for example distcc-based for Makefiles should work fine. We can revisit this decision for the opam 3.x series, but not unless some compelling new facts or approaches come to light that address @AltGr's comments above. |
Since quite some time now the trend has been to make
Systems like |
At this stage of opam's life, to me the solution would be to extract what esy/nix does and use it as an opam hook. It might require to change opam slightly so that it stores switches in a path of fixed length (switch |
Those are your words; not what I said above at all, and an inaccurate characterisation. I specifically said that the opam 2.x series will not provide binary caching of package descriptions.
I'm aware of that, which is why opam fully supports the interpretation of opam files into being used by these systems, such as via opam2nix and domain specific solvers. The opam 2.x client will not have this support in its core due to its focus on being a source-based and OCaml agnostic engine. @Khady wrote:
@Khady feel free to extract out such logic using the opam hooks, and publish it as an opam plugin. We'd be glad to have that in the opam repository for users to try out as an option. We won't be adding any fixed-length switch hacks to the core client as the issue of relocation has been discussed at the OCaml developers meeting and we'd prefer to use the upstream solution in the opam-repository. However, nothing stops you from imposing a switch-length limit in an opam plugin, in order to activate binary caching for those switches. |
That is my plan. Currently on hold because esy authors are rewriting the part which needs to be extracted. If anyone wants to work on that I could create another bounty. |
Having dune do the caching is unsatisfactory. |
Hello,
It would be nice if I build a package, then uninstall it,
then reinstall it, that the already built one is re-used
instead of recompiling everything again.
Thanks,
F.
The text was updated successfully, but these errors were encountered: