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

[RFC]: Convert to direct-style with Eio #2149

Open
wants to merge 99 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
00ee488
Convert Irmin from Lwt to direct-style with Eio
patricoferris Jun 5, 2022
6379145
Restore Test_tree.clear tree size
patricoferris Jun 5, 2022
4bc33c4
Fix map_p, filter_map_p and convert irmin-fs
patricoferris Jun 5, 2022
9bc6ab8
Add eio to opam file
patricoferris Jun 5, 2022
cfc7faf
Convert irmin-pack to direct-style
patricoferris Jun 5, 2022
4eb665f
Update to latest eio
patricoferris Sep 2, 2022
e9088a5
Working FS unix backend
patricoferris Oct 8, 2022
94233d2
Convert irmin-containers to direct-style
patricoferris Oct 8, 2022
99142a8
Remove pin-depends for eio
patricoferris Nov 29, 2022
169de7c
Fix irmin-fs file info
patricoferris Nov 29, 2022
ec6f097
Fix ignoring commit in store
patricoferris Nov 29, 2022
1a2a318
Fix generic-key tests
patricoferris Nov 29, 2022
adfa85e
Remove traceln
patricoferris Dec 9, 2022
0d484c1
Update to eio.0.7 and catch IO errors
patricoferris Jan 10, 2023
a077d36
Fix after rebase
art-w May 31, 2023
8fac611
Fix irmin-pack bench
art-w May 31, 2023
96af869
Fix irmin-pack examples
art-w May 31, 2023
536e7eb
Fix irmin-http using lwt_eio
art-w Jun 1, 2023
ed2cbd6
Fix irmin-graphql using lwt_eio
art-w Jun 2, 2023
c93a6e1
Fix irmin-git using lwt_eio
art-w Jun 2, 2023
7f4d26c
Fix irmin-cli using lwt_eio
art-w Jun 2, 2023
331095b
Fix irmin-mirage using lwt_eio
art-w Jun 2, 2023
1a5f58a
Fix examples using lwt_eio
art-w Jun 2, 2023
cee443f
Fix for libirmin
art-w Jun 5, 2023
e6da5e2
Fix opam dependencies to lwt_eio
art-w Jun 29, 2023
b30c33a
Add multicore tests
ElectreAAS Jun 5, 2023
426b76a
Add lock on branch
ElectreAAS May 30, 2023
151c25c
Fix LRU hashtable with a mutex
ElectreAAS Jun 5, 2023
2204a24
Fixed data race in stat counting
ElectreAAS Jun 5, 2023
791695a
Fixed data race in tree counters
ElectreAAS Jun 5, 2023
6afc95c
Fixed again stats, this time not in unix
ElectreAAS Jun 5, 2023
5b055c7
Update multicore testing
ElectreAAS Jun 12, 2023
2c2dffe
Added locks on unix/pack-store, in Tbl
ElectreAAS Jun 19, 2023
878983c
Added locks in irmin-pack atomic_write
ElectreAAS Jun 19, 2023
cff02a6
Added locks in control-file
ElectreAAS Jun 19, 2023
0043f79
Remove unsafe index stats in irmin-pack io
ElectreAAS Jun 19, 2023
df498e4
Added locks in store
ElectreAAS Jun 19, 2023
1a3678d
Safe pack_key promotion
art-w Jun 21, 2023
7972f9d
Optimize control file payload
art-w Jun 22, 2023
ea06897
Remove unsafe usage of Index.Stats
art-w Jun 22, 2023
c90c059
Fix Tree findv_cache
art-w Jun 23, 2023
37086e6
Fix Tree value cache
art-w Jun 23, 2023
8aeb8b8
Remove spinlock on Tree stats
art-w Jun 23, 2023
8bcd565
Fix irmin-pack inode partial_ptr
art-w Jun 23, 2023
37b211f
irmin-pack: add multicore unit tests
art-w Jul 3, 2023
ff6e5cd
Fix alcotest dependency
art-w Jul 3, 2023
d980b06
Fix irmin Tree lazy length
art-w Jul 3, 2023
55dcad5
Fix irmin Tree Contents mutables
art-w Jul 3, 2023
3607a58
Fix irmin proof
art-w Jul 3, 2023
bbaf30b
Fix irmin Tree add and remove
art-w Jul 3, 2023
c3cf319
Fix irmin-pack Append_only_file buffer length
art-w Jul 3, 2023
427a919
Fix irmin-pack Gc cancellation on close
art-w Jul 3, 2023
1a3249e
Fix irmin-pack Async Gc status handling
art-w Jul 3, 2023
f3a2c5c
Fix for append_only_file buffer length
art-w Jul 4, 2023
52969d9
Fix index-unix flushing from another thread
art-w Jul 4, 2023
c889be6
Fix irmin-pack Gc locks
art-w Jul 4, 2023
4f1b3da
Add commit unit test
art-w Jul 4, 2023
a888e7d
Fix irmin-pack batch in batch test
art-w Jul 4, 2023
1634e90
Fix irmin store mutable tree
art-w Jul 4, 2023
7b12d9f
Fix commit write lock
art-w Jul 5, 2023
c26e8eb
Fix parallel tree hash computation
art-w Jul 5, 2023
d086dad
irmin-pack: Add Store.Tree.list test
clecat Jul 5, 2023
24c3edd
irmin-pack: Add tests on commits for of_hash & parents
clecat Jul 5, 2023
dd1c41f
irmin-pack: Add Commit.v test & fix it with a lock
clecat Jul 5, 2023
17da4c8
Fix libirmin: at_exit executes outside of eio
art-w Jul 5, 2023
3d6dea1
Add half and full diamond multicore benchmarks
art-w Jul 10, 2023
5b9c002
Optimize Tree findv_cache for add/remove
art-w Jul 10, 2023
a1150e8
Fix formatting and remove old tests
art-w Jul 10, 2023
5404045
Fix irmin_fsck
art-w Jul 12, 2023
734d6e2
Fix opam dependencies
art-w Jul 12, 2023
1b959e9
eio: irmin-server using lwt_eio
art-w Aug 24, 2023
4f2d16a
irmin-pack: remove Io.Unix constraint
art-w Aug 21, 2023
dabb1fd
upgrade to eio.0.12
art-w Sep 4, 2023
5f550c7
irmin-pack: generic io lib without unix dependency
art-w Sep 6, 2023
b2f32d8
irmin-pack: extract unix Async
art-w Sep 6, 2023
a664ac8
irmin-pack: extract remaining Unix functions
art-w Sep 6, 2023
161310b
irmin-pack: fix Gc.on_finalise
art-w Sep 6, 2023
e42fb19
mirage: irmin-pack.unix is optional
art-w Sep 8, 2023
26a1497
irmin-pack.io: remove rusage dependency
art-w Sep 8, 2023
6e17751
mirage: remove dependency to fmt_tty
art-w Sep 8, 2023
ce0b76f
mirage: remove dependency to mtime.clock.os
art-w Sep 11, 2023
59deb7c
mirage: remove dependency to progress
art-w Sep 11, 2023
2fdb257
fix progress dependency injection
art-w Sep 20, 2023
62051a7
irmin-pack: use checkseum.c
art-w Oct 7, 2023
18af5b0
Update opam dependencies
art-w Sep 20, 2023
855be85
Fix irmin-client tests
art-w Feb 21, 2024
1e87714
Simplify concurrent list operations
art-w Feb 28, 2024
c7b22e3
Fix CI opam dependencies
art-w Mar 5, 2024
05a4af3
Upgrade dune and fix new warnings
art-w Mar 5, 2024
95b8a53
macos: reduce number of open files in unix-client test to avoid EMFIL…
art-w Mar 6, 2024
5905ef5
libirmin: fix compilation on ppc64
art-w Mar 6, 2024
883c706
Upgrade CI coverage to OCaml 5.1.x
clecat Feb 1, 2024
8601dce
Upgrade to Eio 1.0
art-w Mar 26, 2024
3fb0a99
Update CHANGES
art-w Apr 9, 2024
a8263db
Temporarily disable CI for specific platforms issues
art-w Apr 12, 2024
66c6144
Update opam for OCaml 5.1.0
art-w May 6, 2024
49e21c1
Update CI for OCaml 5.2
art-w Jun 25, 2024
7186af2
Fix multicore race in unit test
art-w Jun 25, 2024
aed087e
Fix Codecov CI: add secret token, disable on PRs
art-w Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 10 additions & 24 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
pull_request:
schedule:
# Prime the caches every Monday
- cron: 0 1 * * MON
Expand All @@ -17,9 +16,8 @@ jobs:
matrix:
os:
- ubuntu-latest
packages: [ '.' ]
ocaml-compiler:
- 4.13.x
- 5.1.x

runs-on: ${{ matrix.os }}

Expand All @@ -30,38 +28,26 @@ jobs:
git config --global core.eol lf

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-local-packages: $${ matrix.opam-local-packages }}
opam-depext-flags: --with-test

- name: Pin local packages
run: |
# Pin all local opam files to avoid internal conflicts
#
# TODO: replace with `opam pin --with-version` when Opam 2.1 is
# available via `setup-ocaml`.
find . -maxdepth 1 -name '*.opam' -printf '%P\n' |\
cut -d. -f1 |\
xargs -I{} -n 1 opam pin add {}.dev ./ -n

- name: Install depexts
run: |
find . -maxdepth 1 -name '*.opam' -printf '%P\n' |\
cut -d. -f1 |\
xargs opam depext --update -y

- name: Install Opam dependencies
run: opam install ${{ matrix.packages }} --with-test --deps-only
run: opam install . --with-test --deps-only

- name: Build
run: opam exec -- dune build

- name: Run tests with coverage instrumentation
run: opam exec -- dune runtest --instrument-with bisect_ppx

- name: Send coverage report to Codecov
run: opam exec -- bisect-ppx-report send-to Codecov
run: opam exec -- bisect-ppx-report send-to Codecov --verbose
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.number }}
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 0.26.0
version = 0.26.2
profile = conventional

ocaml-version = 4.08.0
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 4.0.0

### Changed

- Convert to direct-style with Eio (#2149, @patricoferris, @ElectreAAS, @clecat, @art-w)

## 3.9.0 (2023-10-05)

### Added
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ Git-based, filesystem-backed store.

<!-- $MDX file=examples/readme.ml -->
```ocaml
open Lwt.Syntax

(* Irmin store with string contents *)
module Store = Irmin_git_unix.FS.KV (Irmin.Contents.String)

Expand All @@ -192,25 +190,24 @@ let author = "Example <[email protected]>"
(* Commit information *)
let info fmt = Irmin_git_unix.info ~author fmt

let main =
let main () =
(* Open the repo *)
let* repo = Store.Repo.v config in
let repo = Store.Repo.v config in

(* Load the main branch *)
let* t = Store.main repo in
let t = Store.main repo in

(* Set key "foo/bar" to "testing 123" *)
let* () =
Store.set_exn t ~info:(info "Updating foo/bar") [ "foo"; "bar" ]
"testing 123"
in
Store.set_exn t ~info:(info "Updating foo/bar") [ "foo"; "bar" ] "testing 123";

(* Get key "foo/bar" and print it to stdout *)
let+ x = Store.get t [ "foo"; "bar" ] in
let x = Store.get t [ "foo"; "bar" ] in
Printf.printf "foo/bar => '%s'\n" x

(* Run the program *)
let () = Lwt_main.run main
let () =
Eio_main.run @@ fun env ->
Lwt_eio.with_event_loop ~clock:env#clock @@ fun _ -> main ()
```

The example is contained in [examples/readme.ml](./examples/readme.ml) It can
Expand Down
11 changes: 11 additions & 0 deletions bench.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ocaml/opam:debian-ocaml-5.1
RUN sudo ln -sf /usr/bin/opam-2.1 /usr/bin/opam
RUN mkdir bench-dir && chown opam:opam bench-dir
WORKDIR bench-dir
RUN sudo chown opam .
COPY *.opam ./
RUN opam remote add origin https://github.com/ocaml/opam-repository.git && opam update
RUN opam pin -yn --with-version=dev .
RUN opam install -y --deps-only --with-test .
COPY . ./
ENTRYPOINT opam exec -- make bench
16 changes: 8 additions & 8 deletions bench/irmin-pack/bench_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

open Irmin.Export_for_backends
module Mtime = Import.Mtime

let c0 = Mtime_clock.counter ()
let now_us () = Mtime.span_to_us (Mtime_clock.count c0)
Expand Down Expand Up @@ -77,7 +77,7 @@ let prepare_artefacts_dir path =

let with_timer f =
let t0 = Sys.time () in
let+ a = f () in
let a = f () in
let t1 = Sys.time () -. t0 in
(t1, a)

Expand Down Expand Up @@ -163,30 +163,30 @@ struct
let add_chain_trees depth nb tree =
let path = key 2 in
let rec aux i tree =
if i >= nb then Lwt.return tree
if i >= nb then tree
else
let* tree = chain_tree tree depth path in
let tree = chain_tree tree depth path in
aux (i + 1) tree
in
aux 0 tree

let large_tree path tree width =
let rec aux i tree =
if i >= width then Lwt.return tree
if i >= width then tree
else
let k = path @ [ random_key () ] in
let* tree = Store.Tree.add tree k (random_blob ()) in
let tree = Store.Tree.add tree k (random_blob ()) in
aux (i + 1) tree
in
aux 0 tree

let add_large_trees width nb tree =
let path = key 1 in
let rec aux i tree =
if i >= nb then Lwt.return tree
if i >= nb then tree
else
let path = path @ [ random_key () ] in
let* tree = large_tree path tree width in
let tree = large_tree path tree width in
aux (i + 1) tree
in
aux 0 tree
Expand Down
8 changes: 5 additions & 3 deletions bench/irmin-pack/bench_common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

module Mtime : module type of Import.Mtime

val default_artefacts_dir : string
val prepare_artefacts_dir : string -> unit
val reporter : ?prefix:string -> unit -> Logs.reporter
val setup_log : Fmt.style_renderer option -> Logs.level option -> unit
val reset_stats : unit -> unit
val with_timer : (unit -> 'a Lwt.t) -> (float * 'a) Lwt.t
val with_timer : (unit -> 'a) -> float * 'a

val with_progress_bar :
message:string -> n:int -> unit:string -> ((int -> unit) -> 'a) -> 'a
Expand All @@ -40,11 +42,11 @@ end

module Generate_trees
(Store : Irmin.Generic_key.KV with type Schema.Contents.t = bytes) : sig
val add_chain_trees : int -> int -> Store.tree -> Store.tree Lwt.t
val add_chain_trees : int -> int -> Store.tree -> Store.tree
(** [add_chain_trees depth nb tree] adds [nb] random contents to [tree],
depthwise. *)

val add_large_trees : int -> int -> Store.tree -> Store.tree Lwt.t
val add_large_trees : int -> int -> Store.tree -> Store.tree
(** [add_large_trees width nb tree] adds [nb] random contents to [tree],
breadthwise. *)
end
8 changes: 2 additions & 6 deletions bench/irmin-pack/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
(libraries
irmin-pack
irmin-test.bench
lwt
unix
cmdliner
logs
Expand All @@ -21,7 +20,7 @@
(library
(name bench_common)
(public_name irmin-bench.common)
(modules bench_common)
(modules bench_common import)
(libraries irmin-pack irmin-pack.unix irmin-tezos unix progress uuidm)
(preprocess
(pps ppx_irmin.internal))
Expand All @@ -42,15 +41,13 @@
trace_replay
trace_replay_intf
tezos_history_metrics
trace_stat_summary_cb
import)
trace_stat_summary_cb)
(preprocess
(pps ppx_irmin.internal ppx_repr ppx_deriving.enum))
(libraries
irmin
irmin-pack
unix
lwt
repr
ppx_repr
bentov
Expand All @@ -71,7 +68,6 @@
irmin-pack
irmin-pack.mem
irmin-test.bench
lwt
unix
cmdliner
logs
Expand Down
11 changes: 11 additions & 0 deletions bench/irmin-pack/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@
*)

include Irmin.Export_for_backends

module Mtime = struct
include Mtime

module Span = struct
include Mtime.Span

let to_s span = Mtime.Span.to_float_ns span *. 1e-9
let to_us span = Mtime.Span.to_float_ns span *. 1e-3
end
end
18 changes: 8 additions & 10 deletions bench/irmin-pack/trace_collection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

A module [Make_replayable] has yet to be implemented. *)

open Lwt.Syntax
module Mtime = Import.Mtime
module Mtime = Bench_common.Mtime

(** Make state trace collector. *)
module Make_stat (Store : Irmin.Generic_key.KV) = struct
Expand Down Expand Up @@ -201,8 +200,7 @@ module Make_stat (Store : Irmin.Generic_key.KV) = struct

let short_op_end { t0; writer; _ } short_op =
let duration =
Mtime_clock.count t0 |> fun span ->
Mtime.span_to_s span |> Int32.bits_of_float
Mtime_clock.count t0 |> Mtime.span_to_s |> Int32.bits_of_float
in
let op =
match short_op with
Expand All @@ -217,34 +215,34 @@ module Make_stat (Store : Irmin.Generic_key.KV) = struct
Def.append_row writer op

let create_store_before tree =
let+ Store.Tree.{ nodes; leafs; skips; depth; width } =
let Store.Tree.{ nodes; leafs; skips; depth; width } =
Store.Tree.stats ~force:false tree
in
Def.{ nodes; leafs; skips; depth; width }

let create_store_after tree =
let* watched_nodes_length =
Lwt_list.map_s
let watched_nodes_length =
List.map
(fun (_, steps) -> Store.Tree.length tree steps)
Def.step_list_per_watched_node
in
Lwt.return Def.{ watched_nodes_length }
Def.{ watched_nodes_length }

let commit_begin t tree =
short_op_begin t;
let stats_before =
Bag_of_stats.create t.store_path t.prev_merge_durations
in
t.prev_merge_durations <- Index.Stats.((get ()).merge_durations);
let+ store_before = create_store_before tree in
let store_before = create_store_before tree in
t.commit_before <- (stats_before, store_before)

let commit_end t tree =
let duration = Mtime_clock.count t.t0 |> Mtime.span_to_s in
let duration = duration |> Int32.bits_of_float in
let stats_after = Bag_of_stats.create t.store_path t.prev_merge_durations in
t.prev_merge_durations <- Index.Stats.((get ()).merge_durations);
let+ store_after = create_store_after tree in
let store_after = create_store_after tree in
let op =
`Commit
Def.
Expand Down
Loading
Loading