Skip to content

Commit

Permalink
Remove the old cache library and cache daemon (#4465)
Browse files Browse the repository at this point in the history
This PR continues the work started in #4443.

It does the following things:

* Remove the [cache] and [cache_daemon] libraries.
* Clean up and move and the cache trimming logic to [dune_cache].
* Add some tests to make sure the cache trimmer can cope with all versions of the cache.

Signed-off-by: Andrey Mokhov <[email protected]>
  • Loading branch information
snowleopard authored Apr 9, 2021
1 parent 32de406 commit d9377e8
Show file tree
Hide file tree
Showing 37 changed files with 483 additions and 1,926 deletions.
71 changes: 71 additions & 0 deletions bin/cache.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
open Stdune
open Import

let name = "cache"

(* CR-someday amokhov: Implement other commands supported by Jenga. *)

let man =
[ `S "DESCRIPTION"
; `P
{|Dune can share build artifacts between workspaces. Currently, the only
action supported by this command is `trim`, but we plan to provide more
functionality soon. |}
; `S "ACTIONS"
; `P {|$(b,trim) trim the shared cache to free space.|}
; `Blocks Common.help_secs
]

let doc = "Manage the shared cache of build artifacts"

let info = Term.info name ~doc ~man

let trim ~trimmed_size ~size =
Log.init_disabled ();
let open Result.O in
match
let+ goal =
match (trimmed_size, size) with
| Some trimmed_size, None -> Result.Ok trimmed_size
| None, Some size ->
Result.Ok (Int64.sub (Dune_cache.Trimmer.overhead_size ()) size)
| _ -> Result.Error "specify either --size or --trimmed-size"
in
Dune_cache.Trimmer.trim ~goal
with
| Error s -> User_error.raise [ Pp.text s ]
| Ok { trimmed_bytes } ->
User_message.print
(User_message.make [ Pp.textf "Freed %Li bytes" trimmed_bytes ])

type mode = Trim

let modes = [ ("trim", Trim) ]

let term =
Term.ret
@@ let+ mode =
Arg.(
value
& pos 0 (some (enum modes)) None
& info [] ~docv:"ACTION"
~doc:
(Printf.sprintf "The cache action to perform (%s)"
(Arg.doc_alts_enum modes)))
and+ trimmed_size =
Arg.(
value
& opt (some bytes) None
& info ~docv:"BYTES" [ "trimmed-size" ]
~doc:"size to trim from the cache")
and+ size =
Arg.(
value
& opt (some bytes) None
& info ~docv:"BYTES" [ "size" ] ~doc:"size to trim the cache to")
in
match mode with
| Some Trim -> `Ok (trim ~trimmed_size ~size)
| None -> `Help (`Pager, Some name)

let command = (term, info)
File renamed without changes.
162 changes: 0 additions & 162 deletions bin/caching.ml

This file was deleted.

2 changes: 0 additions & 2 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
fiber
stdune
unix
cache_daemon
cache
dune_cache
dune_cache_storage
dune_rules
Expand Down
2 changes: 1 addition & 1 deletion bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let all : _ Term.Group.t list =
; Format_dune_file.command
; Compute.command
; Upgrade.command
; Caching.command
; Cache.command
; Describe.command
; Top.command
; Ocaml_merlin.command
Expand Down
4 changes: 1 addition & 3 deletions boot/libs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ let local_libraries =
; ("src/dag", Some "Dag", false, None)
; ("src/fiber", Some "Fiber", false, None)
; ("src/memo", Some "Memo", false, None)
; ("src/dune_util", Some "Dune_util", false, None)
; ("src/xdg", Some "Xdg", false, None)
; ("src/dune_cache_storage", Some "Dune_cache_storage", false, None)
; ("src/dune_cache", Some "Dune_cache", false, None)
; ("src/cache", Some "Cache", false, None)
; ("src/cache_daemon", Some "Cache_daemon", false, None)
; ("vendor/re/src", Some "Dune_re", false, None)
; ("vendor/opam-file-format/src", None, false, None)
; ("otherlibs/dune-glob/src", Some "Dune_glob", false, None)
Expand All @@ -27,6 +24,7 @@ let local_libraries =
; ("src/chrome_trace", Some "Chrome_trace", false, None)
; ("vendor/spawn/src", Some "Spawn", false, None)
; ("src/stats", Some "Stats", false, None)
; ("src/dune_util", Some "Dune_util", false, None)
; ("src/meta_parser", Some "Dune_meta_parser", false, None)
; ("src/section", Some "Dune_section", false, None)
; ("vendor/build_path_prefix_map/src", Some "Build_path_prefix_map", false,
Expand Down
30 changes: 0 additions & 30 deletions src/cache/cache.ml

This file was deleted.

21 changes: 0 additions & 21 deletions src/cache/cache.mli

This file was deleted.

Loading

0 comments on commit d9377e8

Please sign in to comment.