Skip to content

Commit d9377e8

Browse files
authored
Remove the old cache library and cache daemon (#4465)
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]>
1 parent 32de406 commit d9377e8

File tree

37 files changed

+483
-1926
lines changed

37 files changed

+483
-1926
lines changed

bin/cache.ml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
open Stdune
2+
open Import
3+
4+
let name = "cache"
5+
6+
(* CR-someday amokhov: Implement other commands supported by Jenga. *)
7+
8+
let man =
9+
[ `S "DESCRIPTION"
10+
; `P
11+
{|Dune can share build artifacts between workspaces. Currently, the only
12+
action supported by this command is `trim`, but we plan to provide more
13+
functionality soon. |}
14+
; `S "ACTIONS"
15+
; `P {|$(b,trim) trim the shared cache to free space.|}
16+
; `Blocks Common.help_secs
17+
]
18+
19+
let doc = "Manage the shared cache of build artifacts"
20+
21+
let info = Term.info name ~doc ~man
22+
23+
let trim ~trimmed_size ~size =
24+
Log.init_disabled ();
25+
let open Result.O in
26+
match
27+
let+ goal =
28+
match (trimmed_size, size) with
29+
| Some trimmed_size, None -> Result.Ok trimmed_size
30+
| None, Some size ->
31+
Result.Ok (Int64.sub (Dune_cache.Trimmer.overhead_size ()) size)
32+
| _ -> Result.Error "specify either --size or --trimmed-size"
33+
in
34+
Dune_cache.Trimmer.trim ~goal
35+
with
36+
| Error s -> User_error.raise [ Pp.text s ]
37+
| Ok { trimmed_bytes } ->
38+
User_message.print
39+
(User_message.make [ Pp.textf "Freed %Li bytes" trimmed_bytes ])
40+
41+
type mode = Trim
42+
43+
let modes = [ ("trim", Trim) ]
44+
45+
let term =
46+
Term.ret
47+
@@ let+ mode =
48+
Arg.(
49+
value
50+
& pos 0 (some (enum modes)) None
51+
& info [] ~docv:"ACTION"
52+
~doc:
53+
(Printf.sprintf "The cache action to perform (%s)"
54+
(Arg.doc_alts_enum modes)))
55+
and+ trimmed_size =
56+
Arg.(
57+
value
58+
& opt (some bytes) None
59+
& info ~docv:"BYTES" [ "trimmed-size" ]
60+
~doc:"size to trim from the cache")
61+
and+ size =
62+
Arg.(
63+
value
64+
& opt (some bytes) None
65+
& info ~docv:"BYTES" [ "size" ] ~doc:"size to trim the cache to")
66+
in
67+
match mode with
68+
| Some Trim -> `Ok (trim ~trimmed_size ~size)
69+
| None -> `Help (`Pager, Some name)
70+
71+
let command = (term, info)
File renamed without changes.

bin/caching.ml

Lines changed: 0 additions & 162 deletions
This file was deleted.

bin/dune

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
fiber
77
stdune
88
unix
9-
cache_daemon
10-
cache
119
dune_cache
1210
dune_cache_storage
1311
dune_rules

bin/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let all : _ Term.Group.t list =
2222
; Format_dune_file.command
2323
; Compute.command
2424
; Upgrade.command
25-
; Caching.command
25+
; Cache.command
2626
; Describe.command
2727
; Top.command
2828
; Ocaml_merlin.command

boot/libs.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ let local_libraries =
1313
; ("src/dag", Some "Dag", false, None)
1414
; ("src/fiber", Some "Fiber", false, None)
1515
; ("src/memo", Some "Memo", false, None)
16-
; ("src/dune_util", Some "Dune_util", false, None)
1716
; ("src/xdg", Some "Xdg", false, None)
1817
; ("src/dune_cache_storage", Some "Dune_cache_storage", false, None)
1918
; ("src/dune_cache", Some "Dune_cache", false, None)
20-
; ("src/cache", Some "Cache", false, None)
21-
; ("src/cache_daemon", Some "Cache_daemon", false, None)
2219
; ("vendor/re/src", Some "Dune_re", false, None)
2320
; ("vendor/opam-file-format/src", None, false, None)
2421
; ("otherlibs/dune-glob/src", Some "Dune_glob", false, None)
@@ -27,6 +24,7 @@ let local_libraries =
2724
; ("src/chrome_trace", Some "Chrome_trace", false, None)
2825
; ("vendor/spawn/src", Some "Spawn", false, None)
2926
; ("src/stats", Some "Stats", false, None)
27+
; ("src/dune_util", Some "Dune_util", false, None)
3028
; ("src/meta_parser", Some "Dune_meta_parser", false, None)
3129
; ("src/section", Some "Dune_section", false, None)
3230
; ("vendor/build_path_prefix_map/src", Some "Build_path_prefix_map", false,

src/cache/cache.ml

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/cache/cache.mli

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)