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

Add a cache system #75

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "scache"]
path = scache
url = https://github.com/moyodiallo/scache.git
branch = master
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM ocaml/opam:debian-12-ocaml-5.1 AS build
RUN sudo apt-get update && sudo apt-get install libev-dev capnproto m4 pkg-config libsqlite3-dev libgmp-dev libzstd-dev -y --no-install-recommends
RUN cd ~/opam-repository && git fetch -q origin master && git reset --hard b61304c6db353e679a36720d8b914b029d6fbc0c && opam update
RUN cd ~/opam-repository && git fetch -q origin master && git reset --hard bc52affc41b55ff00c0d3ac9a376538d79695aaf && opam update
RUN sudo ln -sf /usr/bin/opam-2.1 /usr/bin/opam
COPY --chown=opam scache/scache.opam /src/scache/
COPY --chown=opam solver-service.opam solver-service-api.opam /src/
WORKDIR /src
RUN opam pin add -yn scache.dev "./scache"
RUN opam install -y --deps-only .
ADD --chown=opam . .
RUN opam exec -- dune build @install
Expand Down
19 changes: 14 additions & 5 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,25 @@ let start_server ~service vat_config =
let+ vat = Capnp_rpc_unix.serve vat_config ~restore in
Capnp_rpc_unix.Vat.sturdy_uri vat service_id

let main_service () solver cap_file vat_config =
let uri = start_server ~service:(Solver_service.Service.v solver) vat_config in
let main_service () solver cacheable cap_file vat_config =
let uri = start_server ~service:(Solver_service.Service.v ~cacheable solver) vat_config in
Capnp_rpc_unix.Cap_file.save_uri uri cap_file |> or_die;
Fmt.pr "Wrote solver service's address to %S@." cap_file;
Fiber.await_cancel ()

let main_service_pipe () solver =
let main_service_pipe () solver cacheable =
let socket = Lwt_unix.stdin in
(* Run locally reading from socket *)
export (Solver_service.Service.v solver) ~on:socket
export (Solver_service.Service.v ~cacheable solver) ~on:socket

let main_cluster () solver name capacity register_addr =
let main_cluster () solver cacheable name capacity register_addr =
let vat = Capnp_rpc_unix.client_only_vat () in
let sr = Capnp_rpc_unix.Vat.import_exn vat register_addr in
let `Cancelled =
Solver_worker.run solver sr
~name
~capacity
~cacheable
in
()

Expand Down Expand Up @@ -128,6 +129,11 @@ let capacity =
@@ Arg.info ~doc:"The number of cluster jobs that can run in parallel" ~docv:"N"
[ "capacity" ]

let cacheable =
Arg.value
@@ Arg.flag
@@ Arg.info ~doc:"Activate the cache system" [ "activate-cache"; "cache" ]

let cap_file =
Arg.required
@@ Arg.opt Arg.(some string) None
Expand Down Expand Up @@ -168,6 +174,7 @@ let () =
const main_service
$ setup_log
$ solver
$ cacheable
$ cap_file
$ Capnp_rpc_unix.Vat_config.cmd
)
Expand All @@ -179,6 +186,7 @@ let () =
const main_service_pipe
$ setup_log
$ solver
$ cacheable
)
in
let run_agent =
Expand All @@ -188,6 +196,7 @@ let () =
const main_cluster
$ setup_log
$ solver
$ cacheable
$ worker_name
$ capacity
$ register_addr
Expand Down
4 changes: 3 additions & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
(dirs :standard \ var cache)
(dirs :standard \ var)

(vendored_dirs scache)
117 changes: 83 additions & 34 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,48 +1,97 @@
(lang dune 3.7)

(name solver-service)

(formatting (enabled_for dune))
(formatting
(enabled_for dune))

(generate_opam_files true)
(source (github ocurrent/solver-service))
(authors "Thomas Leonard <[email protected]>" "Patrick Ferris <[email protected]>")
(maintainers "[email protected]" "Tim McGilchrist <[email protected]>")

(source
(github ocurrent/solver-service))

(authors
"Thomas Leonard <[email protected]>"
"Patrick Ferris <[email protected]>")

(maintainers [email protected] "Tim McGilchrist <[email protected]>")

(package
(name solver-service)
(synopsis "Choose package versions to test")
(depends
(ocaml (>= 5.0.0))
; Examples dependencies
(current_web (and (>= 0.6.4) :with-test))
(current_git (and (>= 0.6.4) :with-test))
(current_github (and (>= 0.6.4) :with-test))
(current_ocluster (and (>= 0.2.1) :with-test))
(ppx_deriving_yojson (>= 3.6.1))
(ppx_deriving (>= 5.1))
(yojson (>= 2.1.0))
(lwt (>= 5.6.1))
(eio (>= 0.12))
(eio_main (>= 0.12))
(lwt_eio (>= 0.5))
(logs (>= 0.7.0))
(fmt (>= 0.9.0))
(ocaml-version (>= 3.6.1))
(solver-service-api (= :version))
(dune-build-info (>= 3.8.0))
(opam-0install (>= 0.4.3))
(git-unix (>= 3.12.0))
(ocluster-api (>= 0.2.1))
(prometheus-app (>= 1.2))
(capnp-rpc-net (>= 1.2.3))
(capnp-rpc-unix (>= 1.2.3)))
(conflicts (carton (< 0.4.2))))
(opam-file-format
(>= 2.1.6))
(ocaml
(>= 5.0.0))
(current_web
(and
(>= 0.6.4)
:with-test))
(current_git
(and
(>= 0.6.4)
:with-test))
(current_github
(and
(>= 0.6.4)
:with-test))
(current_ocluster
(and
(>= 0.2.1)
:with-test))
(ppx_deriving_yojson
(>= 3.6.1))
(ppx_deriving
(>= 5.1))
(yojson
(>= 2.1.0))
(lwt
(>= 5.6.1))
(eio
(>= 0.12))
(eio_main
(>= 0.12))
(lwt_eio
(>= 0.5))
(logs
(>= 0.7.0))
(fmt
(>= 0.9.0))
sqlite3
(ocaml-version
(>= 3.6.1))
(solver-service-api
(= :version))
(dune-build-info
(>= 3.8.0))
(opam-0install
(>= 0.4.3))
(git-unix
(>= 3.12.0))
(ocluster-api
(>= 0.2.1))
(prometheus-app
(>= 1.2))
(capnp-rpc-net
(>= 1.2.3))
(capnp-rpc-unix
(>= 1.2.3)))
(conflicts
(carton
(< 0.4.2))))

(package
(name solver-service-api)
(synopsis "Cap'n Proto API for the solver service")
(depends
(ocaml (>= 4.14.1))
(capnp (>= 3.5.0))
(capnp-rpc-lwt (>= 1.2.3))
(ppx_deriving_yojson (>= 3.6.1))
(ppx_deriving (>= 5.1))))
(ocaml
(>= 4.14.1))
(capnp
(>= 3.5.0))
(capnp-rpc-lwt
(>= 1.2.3))
(ppx_deriving_yojson
(>= 3.6.1))
(ppx_deriving
(>= 5.1))))
1 change: 1 addition & 0 deletions scache
Submodule scache added at 265c82
6 changes: 5 additions & 1 deletion service/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
solver-service-api
opam-0install
capnp-rpc-net
opam-file-format
git-unix
ocaml-version))
scache
ocaml-version)
(preprocess
(pps ppx_deriving_yojson)))
Loading