package b0

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Build operation revivers.

An operation reviver combines a file cache and a hash function to record and revive the effect of build operations.

Note. Hashes performed on files by this module are cached.

Operation reviver

type t

The type for build operation revivers.

val create : B00_std.Time.counter -> (module B00_std.Hash.T) -> File_cache.t -> t

create clock hash_fun cache is a reviver with

  • clock the clock used to measure file hashing time and timestamp revived operations.
  • hash_fun the hash function used to hash files and build operations.
  • cache the file cache used to record build operations.
val clock : t -> B00_std.Time.counter

clock r is r's clock.

val hash_fun : t -> (module B00_std.Hash.T)

hash_fun r is r's hash function.

val file_cache : t -> File_cache.t

file_cache r is r's file cache.

Hashing

val hash_string : t -> string -> B00_std.Hash.t

hash_string r s hashes s using r's hash_fun.

val hash_file : t -> B00_std.Fpath.t -> (B00_std.Hash.t, string) result

hash_file r f hashes file f using r's hash_fun. Note that file hashes are cached by r.

val hash_op : t -> Op.t -> (B00_std.Hash.t, string) result

hash_op r o hashes the operation o. Errors if an input file of the build operation can't be hashed, this is most likely because an input file does not exist.

val file_hashes : t -> B00_std.Hash.t B00_std.Fpath.Map.t

file_hashes r is a map of the files that were hashed.

val file_hash_dur : t -> B00_std.Time.span

file_hash_dur r is the time spent hashing files.

Recording and reviving operations

val record : t -> Op.t -> (bool, string) result

record r o records operation o in the reviver r. This associates the Op.writes o of o to the key Op.hash o (i.e. this function assume o has gone through set_op_hash before) and stores operation output information of o in the key's metadata hunk. The semantics of the result is like File_cache.add; in particular in case of Ok false it means some file in the set of writes do not exist and is likely an error.

val revive : t -> Op.t -> (bool, string) result

revive r o tries to revive operation o from r using the key Op.hash o (i.e. this function assume o has gone through set_op_hash before). In particular:

  1. Recreates the files Op.writes o
  2. 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 into o.

If Ok true is returned the operation was revived. If Ok false is returned then nothing was revived and the file system is kept unchanged. Nothing is guaranteed in case of Error _.

Warning. The fields Op.exec_start_time, Op.exec_end_time of o get set regardless of the result. This may be overwritten later by Exec.

OCaml

Innovation. Community. Security.