perf(cache): memoise file digests and invalidate them on write

A header included by fourteen translation units was hashed once per dependent,
and every built action hashed its inputs twice: once to decide it was stale and
again to store the new key. Digests are now memoised for the run, and the
scheduler drops the entries for an action's outputs and depfile once it
finishes, so a freshly written file is never read from the memo.
This commit is contained in:
sneeker committed 2022-07-12 08:44:33 +00:00
1 parent 56a45e5776
commit 2ce144e8aa
2 files changed
+14 -1

No files matched your search

+3
View File
@@ -78,11 +78,14 @@ let run g ~selected ~jobs ~cache ~verbose ~keep_going ~on_start ~on_done =
if ok then begin
incr built;
state.(v.id) <- Done;
List.iter Cache.forget v.outs;
(match v.depfile with Some d -> Cache.forget d | None -> ());
Cache.put cache (List.hd v.outs) (key_of v);
release v.id
end
else begin
incr failed;
List.iter Cache.forget v.outs;
Cache.drop cache (List.hd v.outs);
List.iter (fun o -> try Sys.remove o with Sys_error _ -> ()) v.outs;
skip v.id