[RFC]: Convert to direct-style with Eio#2149
Conversation
cdd06d1 to
ecfabf4
Compare
448d615 to
0b5c73a
Compare
|
Thanks a lot @patricoferris, this is fantastic work! We've rebased your branch and completed the missing libraries using |
|
Awesome! Sorry for the slow reply, please do whatever is easiest (pushing the changes here, new PR etc.) |
ca52020 to
a0e31eb
Compare
|
Thanks a lot for your patience! I've updated your PR with all the work done by @ElectreAAS and @clecat to make So this PR now has feature parity with
WDYT @samoht ? If we can merge this wip, should we add a disclaimer in the readme that the repo is migrating to Eio and that the public API will still change? |
|
Could we add temporary workarounds for the failing tests? I'd be very happy to merge that PR but I also would like to keep the CI green to detect future regressions. |
349bc5c to
66c6144
Compare
|
Sure, that makes sense! I made some adjustments to turn the CI green, the only thing left is adding a Codecov upload token but I have neither access to our Codecov account or to the github secrets management. Can someone lend me the accesses or configure the secret such that I'll be able to update the coverage workflow? Thanks! |
a3acb00 to
aed087e
Compare
|
This should be ready to merge, it will allow to go on with the next PR |
There was a problem hiding this comment.
This is a first review to check dependencies. I caught several useless lwt dependencies. I will push a commit very soon to fix some of it.
Some of my comments and some of the following points may be addressed by the following PRs. Please let's me know if this is the case !
Pin-depends
Pin-depends should as much as possible be removed before merging.
-
progressandterminaldon't require a pin-depend anymore (it will be in my next commit) -
index: pinned to a merge commit.indexneeds a minor release to remove thepin-depend -
irmin-watcher: Will be done in PR#2336Some work to do here. The pin is topatricoferris#eioon which is builtclecat#eio's branch (and PR). Removing this pin requires merging the PR inirmin-watcherand a release of this lib
Lwt deps
Removing as many Lwt dependencies as possible now would be beneficial, especially when they are unnecessary or can be easily removed without changing a lot of code. Here is a summary of the current status of packages regarding dependency on Lwt.
Package with no more deps to Lwt
Nothing needs to be done for these packages regarding the Lwt dependency in this PR.
irminirmin-pack: see PR#2280irmin-pack-tools: same asirmin-packirmin-chunkirmin-fs: see PR#2316irmin-tezos
Packages with a dependency on lwt
The following packages still depend on lwt. For some, it is because they use Lwt-eio, but not for all. It would be helpful to do a check-up here to ensure nothing has been forgotten and summarise the plan (or next to come PR) for these libraries.
Core packages:
irmin-server: the signature ofirmin-serverstill has someLwt.tin it. Is there a plan to change it later, or does this rely too heavily on its dependencies (conduit,cohttp, etc) to change it?irmin-client: same asirmin-serverirmin-cli: depends onirmin-serverirmin-graphql: depends ongraphql-lwt. Nographql-eioexists.irmin-git: usedLwt_eio-> No PR: what is the plan?libirmin: usedLwt_eio-> PR#2318irmin-mirage: no PR -> Is there a plan?
Facultative (as it is okay to install lwt for tests and benches) :
irmin-test: only becausemetrics-unixrequiresLwt(used forMetrics_gnuplot). Should it be removed?irmin-bench:lwtcan be removed in theirmin-bench.opamfile (would still depend onlwtbecauseirmin-testdepends on it)
Unrelated general comments
I could not write these comments in the review (because the code is unchanged). They require minor changes in this PR.
-
odocshould be added to .opam files with {with-doc} -
src/irmin/irmin.mli: examples still useLwt -
src/irmin/indexable_intf.ml: same (lines 39+) -
src/irmin/node_intf.ml: same (lines 124+) -
test/irmin-pack/data/version_1_large/README.md: same
Not working command. I am unsure whether these require changes or not.
-
make benchdoes not work locally (Is it meant for the CI only ?) -
make fuzzdoes not work
|
I added your changes @lyrm, keep me in touch if you want to do additional changes |
|
Thanks! These commits only fix some minor things that I found easier to fix than to comment on. There are still comments that can be addressed now. In addition, my review's message contains tasks and questions to be answered. I have improved it so that what to do is made clearer. Could you take care of it, please? |
|
I have pushed a new commit addressing some of your feedback (mostly functions names *_lwt. As for the rest:
|
There was a problem hiding this comment.
In brief
This PR represents a significant amount of work accumulated over several years. The CI is green, the tests are passing, and no major issues have been found during the reviews. As the goal is to move forward with the Eio migration, the minor issues identified here will be addressed in a follow-up PR. Thanks @clecat for your help with this review!
Introduction
Context of the review
We are currently working on moving Irmin to Eio by merging the corresponding PRs developed last year. This includes at least the following PRs:
- This PR#2149
- PR#2316, which improves the use of Eio in
irmin-fsand introduces EIO capabilities - PR#2280, targeting
irmin-pack
Changes introduced by this PR
The goal of this PR is to make Irmin compatible with multicore OCaml using Eio.
Concretely, it:
- Migrates Irmin to direct-style using Eio
- Adds multicore safety:
- Introduces multicore tests
- Replaces non-atomic mutables with atomics to prevent data races, as identified by TSan
What this PR does not do
- It does not completely remove all dependencies on Lwt: some packages (e.g.,
irmin-git) still rely on libraries that are not Eio-compatible. In such cases,lwt-eiois used to keep the API in direct-style while internally relying on Lwt. - It does not provide the final Eio-based implementation of Irmin. That work is continued in follow-up PRs.
Implications
- Many of the changes in this PR are mechanical (e.g., removing
let*, replacingLwt_resultconstructs, etc.). - This brings Irmin to an intermediate state that will be further refined in subsequent PRs.
Findings
For this second round of review, I went through most commits one by one. Below is a summary of the small changes identified, and follow-up tasks.
Small fixes and cleanups
-
src/irmin-pack/unix/dune:progressshould be removed from dependencies -
src/irmin/metrics.ml: theMutateconstructor of typeupdate_modeis unused and could pose problems in a multicore context -
src/irmin/irmin.ml: the optional argument?lockin the functionbatchappears unused across all backends - Some examples are not up to date with the new API:
src/irmin/irmin.mlisrc/irmin/indexable_intf.ml(lines 39+)src/irmin/node_intf.ml(lines 124+)test/irmin-pack/data/version_1_large/README.md
- (Opt) Remove instances of
| e -> raise e - (Opt) Replace
f () |> functionwithmatch f () with ...for uniformisation
Frightening comments
src/irmin/watch.ml- line 46:
(* Not sure this is right *)
- line 46:
src/irmin/watch_intf.mli- line 85:
(** A terrible hack that will need fixed... *)
- line 85:
Other similar comments might be present and should (probably?) be reviewed and / or removed.
Question: eio_pool
A new file, eio_pool.ml, has been introduced in src/irmin-fs/unix.
Question: Is this file redundant with Eio.Pool ?
Follow-up tasks
The following listing is for tasks that should be
- Multicore safety:
- Review multicore tests and confirm no data races with TSan
- Review use of
Atomic.set(and make sure acompare_and_setis not needed instead) - Add tests for linearizability
- Review LRU changes (note: could be done by reviewing PR#2281 where the lru is fully rewritten)
- Remove
pin-depends:-
index -
irmin-watcher: pin removal planned in PR#2336
-
|
Thank you for your work and the reviews |
What's ported?
This draft PR ports parts of Irmin to https://github.com/ocaml-multicore/eio. This includes
irmin,irmin-fs,irmin-pack,irmin-containersandirmin-chunkalong with the tests. Most of the other libraries are not yet ported because of the effort to try and port the dependencies in particulargraphql,ocaml-gitandwebmachine(although I thinkirmin-httpmight be on its way out).I'm opening this draft PR to let people know of the existence of this work (in case they want to do some hacking ;)) and to also let people comment on it. It might be interesting to see if there are impacts on the benchmarks.
Some issues
One problem that has come up a few times, is Irmin's use of top-level values (even if lazy). In the Eio world this becomes a little tricky because they often need either access to some capability or a
Eio.Switch.t. There is a port ofirmin-watcherfor example that requires the installation of a handler in order to be able to get a switch to the hooks.irmin-fsalso requires something similar so that users would have to do this (see the fs unix tests):Which I'm definitely not a fan of! As pointed out in ocaml-multicore/eio#364 (comment) fiber-local storage could be used but comes with it's own problems. The
Irmin_fshandler was more about getting thefscapability to the repo constructor that can only take a configuration because I wasn't sure how to do that otherwise. The only way to get a capability is if it is passed to you from Eio's standard environment.Porting to Eio already is a massive breaking change, so perhaps some of this could be reworked to avoid all of this :)) Would love to know your thoughts?