@@ -197,29 +197,42 @@ let get_workspace_lock_dir ctx =
197197 Workspace. find_lock_dir workspace path
198198;;
199199
200- let get_with_path ctx =
201- let * path =
202- get_path ctx
203- >> | function
204- | Some p -> p
205- | None ->
206- Code_error. raise
207- " No lock dir path for context available "
208- [ " context " , Context_name. to_dyn ctx ]
200+ let get_with_path =
201+ let read_lockdir =
202+ Memo. exec
203+ ( Memo. create
204+ ~human_readable_description: ( fun p ->
205+ Pp. textf " read lock directory %s " ( Path. to_string_maybe_quoted p))
206+ " read-lock-dir "
207+ ~input: ( module Path )
208+ Load. load)
209209 in
210- let * () = Build_system. build_dir path in
211- Load. load path
212- >> = function
213- | Error e -> Memo. return (Error e)
214- | Ok lock_dir ->
215- let + workspace_lock_dir = get_workspace_lock_dir ctx in
216- (match workspace_lock_dir with
217- | None -> ()
218- | Some workspace_lock_dir ->
219- Solver_stats.Expanded_variable_bindings. validate_against_solver_env
220- lock_dir.expanded_solver_variable_bindings
221- (workspace_lock_dir.solver_env |> Option. value ~default: Solver_env. empty));
222- Ok (path, lock_dir)
210+ Per_context. create_by_name ~name: " lock-dir-get" (fun ctx ->
211+ Memo. lazy_ (fun () ->
212+ let * path =
213+ get_path ctx
214+ >> | function
215+ | Some p -> p
216+ | None ->
217+ Code_error. raise
218+ " No lock dir path for context available"
219+ [ " context" , Context_name. to_dyn ctx ]
220+ in
221+ let * () = Build_system. build_dir path in
222+ read_lockdir path
223+ >> = function
224+ | Error e -> Memo. return (Error e)
225+ | Ok lock_dir ->
226+ let + workspace_lock_dir = get_workspace_lock_dir ctx in
227+ (match workspace_lock_dir with
228+ | None -> ()
229+ | Some workspace_lock_dir ->
230+ Solver_stats.Expanded_variable_bindings. validate_against_solver_env
231+ lock_dir.expanded_solver_variable_bindings
232+ (workspace_lock_dir.solver_env |> Option. value ~default: Solver_env. empty));
233+ Ok (path, lock_dir))
234+ |> Memo.Lazy. force)
235+ |> Staged. unstage
223236;;
224237
225238let get ctx = get_with_path ctx >> | Result. map ~f: snd
0 commit comments