-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Introduce multicore parallelism for 40% speed-up on presenting opam install
plan
#5877
base: master
Are you sure you want to change the base?
Conversation
This is very interesting! Just as a brief note for now, if you move |
Nice. moved to patches! |
We had a look during the dev meeting and this change looks good and extremely welcome. We are currently concentrating our efforts on the release of 2.2.0 but we'll give a more serious look after the release. As a pre-review, we were wondering if the diff could be reduced by moving the thread pool into Out of curiosity, do you have the benchmark result before and after changing dose3 by any chance? As for making opam OCaml 5.0 only, we could always simply create our own shim that would make pre-5.0 uses sequential or simply use |
Glad it was well received. Some thoughts.
|
For the diff size, you could replace
```ocaml
OpamMulticore.run_with_task_pool
(fun task_pool -> …
```
with
```ocaml
OpamMulticore.run_with_task_pool @@ fun task_pool ->
…
```
which doesn't affect indentation.
|
good idea, @c-cube! done in last push dev-team: let me know if the resultant diff is easier on the eyes |
My comment was less about the diff in a visual sense and more about whether the API changes or not, as outside users do use the API through the opam-state/opam-client/... packages. But indeed we didn't think
With debug-level 1 and up you can see how long does dose3 alone take overall with these two lines:
|
It does. I thought you were asking about micro-benchmarking portions of dose3. (FWIW: Not every portion benefitted from being parallelized so I didn't do them, and some parts could probably benefit from parallelization if the algorithms were re-worked. I may swing into that in the future.) |
I made an experiment trying to parallelize another part of the code in #5966. If we want to head to a future where the opam internals are fully parallelisable we probably want to pull both your PR and mine in some capacity (I'm planning to split mine into smaller chunks once 2.2.0 is out). Btw, I'm not sure if it was available at the time but the TSan option in OCaml 5.2 was extremely useful to detect data races, in case you or someone else wants to try and parallelize another part of opam in the future. |
Hello! This PR is humbly submitted for your consideration.
This is a PR that introduces multicore parallelism to try to reduce opam wall-clock time.
The opam solver and job scheduler have had a lot of heroic work done on them to make them blazingly fast. This is not a PR for that stuff.
Instead, this PR tries to parallelize a lot of the bootstrapping that's done before we get to the solver. On typical workstations,
opam install
can spend 6-10 seconds loading everything needed to run on the solver and present the final list of packages that it would install.This patch speeds that interactive step up by about 40% by recruiting more cores.
It does so by embracing OCaml 5.0 and also domainslib.
Anticipated questions
Q: Doesn't requiring OCaml 5.0 reduce the population of people that can build this? Most major users are still on 4.x, right?
A: Kind of, but is that a huge issue? Most users of opam install from binary. Distributing an opam binary build against OCaml 5.0 doesn't stop users from using it on their OCaml 4.x projects.
Q: Is this worth it? Surely the important part is making opam install your packages faster, not the 10 seconds of bootstrapping in the beginning?
A: Actually installing the packages is important, sure, but the interactive part of opam is waiting to see the list of what can be installed and I think making that faster pays dividends too. Once you decide to install a huge list of packages you can just hit enter and go grab a coffee (er, I mean, task switch to some other productive endeavor). But before that moment, you are busy-waiting on opam to get back to you. This patch hopefully improves quality of life there.
How to run it
./configure --with-vendored-deps
make
./opam
Your thoughts are kindly requested. Thanks!