Module B00.Op_cache
Operation cache.
An operation cache combines a file cache and a hash function to memoize build operations.
Note. File hashes performed by this module are cached.
Build operation cache
val create : ?clock:B0_std.Time.counter -> ?hash_fun:(module B0_std.Hash.T) -> File_cache.t -> tcreate ~clock ~hash_fun cis an operation cache withcthe file cache used to memoize build operationshash_funthe hash function used to hash files and build operations; defaults toB0_std.Hash.Xxh_64clockthe clock used to measure file hashing time and timestamp revived operations defaults toB0_std.Time.counter().
val set_op_hash : t -> Op.t -> (unit, string) Stdlib.resultset_op_hash t ohashes the operationoand stores the result inowithOp.set_hash. Errors if an input file of the operation can't be hashed.
val revive : t -> Op.t -> (B0_std.Fpath.t list option, string) Stdlib.resultrevive c otries to revive operationofrom the file cache using the keyOp.hash o. In particular this:- Recreates the files
Op.writes o - Sets
o's execution information using the metadata hunk of the key. For example for spawn operations this also recovers the exit status code and standard output redirection contents intoo.
The semantics of the result is like
File_cache.revive; in particular in case ofOk Nonethe key nothing was revived.Warning. In any case the fields
Op.exec_start_time,Op.exec_end_timeandOp.exec_status ofoget set.- Recreates the files
val add : t -> Op.t -> (bool, string) Stdlib.resultadd c oadds operationoto the cache. This associates theOp.writes oofoto the keyOp.hash oand stores execution information ofoin the key's metadata hunk. The semantics of the result is likeFile_cache.add; in particular in case ofOk falseit means some file in the set of writes do not exist and is likely an error.
val hash_fun : t -> (module B0_std.Hash.T)hash_fun cis the hash function used by the operation cache.
val file_hashes : t -> B0_std.Hash.t B0_std.Fpath.Map.tfile_hashes cis a map of the files that were hashed.
val file_hash_dur : t -> B0_std.Time.spanfile_hash_dur cis the time spent hashing files.