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

Drop remaining references to visibility in Memo #4542

Merged
merged 3 commits into from
Apr 28, 2021
Merged
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
33 changes: 21 additions & 12 deletions src/dune_engine/build_system.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ module Fs : sig
val assert_exists : loc:Loc.t -> Path.t -> unit Memo.Build.t
end = struct
let mkdir_p_def =
Memo.create "mkdir_p"
(* CR-someday amokhov: It's difficult to think about the correctness of this
memoized function. Right now, we never invalidate it, so if we delete a
stale build directory, we'll not be able to recreate it later. Perhaps,
we should create directories as part of running actions that need them.
That would be less efficient, as we'd call [mkdir] on the same directory
multiple times, but it would be easier to guarantee correctness.

Note: if we find a way to reliably invalidate this function, its output
should continue to have no cutoff because the callers might depend not
just on the existence of a directory but on its *continuous* existence. *)
Memo.create_no_cutoff "mkdir_p"
snowleopard marked this conversation as resolved.
Show resolved Hide resolved
~input:(module Path.Build)
~output:(Simple (module Unit))
(fun p ->
Path.mkdir_p (Path.build p);
Memo.Build.return ())
Expand All @@ -24,7 +33,7 @@ end = struct
let assert_exists_def =
Memo.create "assert_path_exists"
~input:(module Path)
~output:(Simple (module Bool))
~output:(No_cutoff (module Bool))
(fun p -> Memo.Build.return (Path.exists p))

let assert_exists ~loc path =
Expand Down Expand Up @@ -1137,7 +1146,7 @@ end = struct
let load_dir =
let load_dir_impl dir = load_dir_impl (t ()) ~dir in
let memo =
Memo.create_hidden "load-dir" ~input:(module Path) load_dir_impl
Memo.create_no_cutoff "load-dir" ~input:(module Path) load_dir_impl
in
fun ~dir -> Memo.exec memo dir
end
Expand Down Expand Up @@ -1923,7 +1932,7 @@ end = struct
target

let execute_action_generic_stage2_memo =
Memo.create_hidden "execute-action"
Memo.create_no_cutoff "execute-action"
~input:(module Action_desc)
execute_action_generic_stage2_impl

Expand Down Expand Up @@ -2062,7 +2071,7 @@ end = struct
let eval_memo =
Memo.create "eval-pred"
~input:(module File_selector)
~output:(Allow_cutoff (module Path.Set))
~output:(Cutoff (module Path.Set))
eval_impl

let eval = Memo.exec eval_memo
Expand All @@ -2071,28 +2080,28 @@ end = struct
Memo.exec
(Memo.create "build-pred"
~input:(module File_selector)
~output:(Allow_cutoff (module Dep.Fact.Files))
~output:(Cutoff (module Dep.Fact.Files))
build_impl)
end

let build_file_memo =
Memo.create "build-file"
~output:(Allow_cutoff (module Digest))
~input:(module Path)
~output:(Cutoff (module Digest))
build_file_impl

let build_file = Memo.exec build_file_memo

let build_alias_memo =
Memo.create "build-alias"
~output:(Allow_cutoff (module Dep.Fact.Files))
~input:(module Alias)
~output:(Cutoff (module Dep.Fact.Files))
build_alias_impl

let build_alias = Memo.exec build_alias_memo

let execute_rule_memo =
Memo.create_hidden "execute-rule"
Memo.create_no_cutoff "execute-rule"
~input:(module Rule)
(execute_rule_impl ~rule_kind:Normal_rule)

Expand Down Expand Up @@ -2307,7 +2316,7 @@ end = struct
end = struct
let alias =
let memo =
Memo.create_hidden "expand-alias"
Memo.create_no_cutoff "expand-alias"
~input:(module Alias)
(fun alias ->
let* l = expand_alias_gen alias ~eval_build_request in
Expand All @@ -2331,7 +2340,7 @@ end = struct

let evaluate_rule =
let memo =
Memo.create_hidden "evaluate-rule"
Memo.create_no_cutoff "evaluate-rule"
~input:(module Non_evaluated_rule)
(fun rule ->
let* action, deps = eval_build_request rule.action in
Expand Down
3 changes: 1 addition & 2 deletions src/dune_engine/fs_memo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ open Memo.Build.O
(* Files and directories have non-overlapping sets of paths, so we can track
them using the same memoization table. *)
let memo =
Memo.create "fs_memo"
Memo.create_no_cutoff "fs_memo"
~input:(module Path)
~output:(Simple (module Unit))
(fun _path -> Memo.Build.return ())

(* Declare a dependency on a path. Instead of calling [depend] directly, you
Expand Down
4 changes: 2 additions & 2 deletions src/dune_engine/source_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ end = struct
let memo =
Memo.create "find-dir-raw"
~input:(module Path.Source)
~output:(Simple (module Output))
~output:(No_cutoff (module Output))
find_dir_raw_impl
in
Memo.cell memo
Expand Down Expand Up @@ -658,7 +658,7 @@ let execution_parameters_of_dir =
let memo =
Memo.create "execution-parameters-of-dir"
~input:(module Path.Source)
~output:(Allow_cutoff (module Execution_parameters))
~output:(Cutoff (module Execution_parameters))
f
in
Memo.exec memo
Expand Down
29 changes: 7 additions & 22 deletions src/dune_engine/vcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,16 @@ let hg_describe t =
in
s ^ dirty_suffix

let make_fun name ~output ~git ~hg =
let memo = Memo.create name ~input:(module T) ~output (select git hg) in
let make_fun name ~output_to_dyn ~git ~hg =
let memo =
Memo.create_no_cutoff name ~input:(module T) ~output_to_dyn (select git hg)
in
Staged.stage (Memo.exec memo)

module Option_output (S : sig
type t

val to_dyn : t -> Dyn.t
end) =
struct
type t = S.t option

let to_dyn t = Dyn.Encoder.option S.to_dyn t
end

let describe =
Staged.unstage
@@ make_fun "vcs-describe"
~output:(Simple (module Option_output (String)))
~output_to_dyn:(Dyn.Encoder.option String.to_dyn)
~git:(fun t -> run_git t [ "describe"; "--always"; "--dirty" ])
~hg:(fun x ->
let open Fiber.O in
Expand All @@ -137,7 +128,7 @@ let describe =
let commit_id =
Staged.unstage
@@ make_fun "vcs-commit-id"
~output:(Simple (module Option_output (String)))
~output_to_dyn:(Dyn.Encoder.option String.to_dyn)
~git:(fun t -> run_git t [ "rev-parse"; "HEAD" ])
~hg:(fun t ->
let open Fiber.O in
Expand Down Expand Up @@ -167,13 +158,7 @@ let files =
in
Staged.unstage
@@ make_fun "vcs-files"
~output:
(Simple
(module struct
type t = Path.t list

let to_dyn = Dyn.Encoder.list Path.to_dyn
end))
~output_to_dyn:(Dyn.Encoder.list Path.to_dyn)
~git:
(f run_zero_separated_git
[ "ls-tree"; "-z"; "-r"; "--name-only"; "HEAD" ])
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ module Args = struct

let memo t =
let memo =
Memo.create_hidden "Command.Args.memo"
Memo.create_no_cutoff "Command.Args.memo"
~input:(module Path)
(fun dir -> Memo.Build.return (expand_static ~dir t))
in
Expand Down
Loading