-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
32de406
commit d9377e8
Showing
37 changed files
with
483 additions
and
1,926 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,6 @@ | |
fiber | ||
stdune | ||
unix | ||
cache_daemon | ||
cache | ||
dune_cache | ||
dune_cache_storage | ||
dune_rules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.