Something went wrong. Try again.
A local Git merge queue with content-bound gate verdicts
Something went wrong. Try again.
1.9 kB · 50 lines
OCaml
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051(** The lands queued for one target, checked and landed under a policy.
A discrete-event simulation of one target's queue. A land arrives at its {!Merge_queue.Order.job.arrived} time, waits in the queue, is checked on the target's tip for the sum of its ready checks' durations and, once checked, fast-forwards the target at once; every check is green. The build slots are {!Sim_order}'s concern: here a land under check holds a worktree of its own and nothing else. *)
module M := Merge_queue
(** The type for the policies. *)type policy = | Serial (** First come first served, one land at a time: mq before {!Merge_queue.Order.admit}. *) | Admit (** {!Merge_queue.Order.admit} at each arrival and each landing. *)
type course = { branch : M.Branch.t; arrived_ms : int; (** Milliseconds from the start of the simulation. *) started_ms : int; (** When its check started on the target's tip. *) base : int; (** How many lands the target held when its check started. *) landed_ms : int; (** When it fast-forwarded the target. *) cone : M.Cone.t;}(** The type for one land's course. *)
val run : duration:(M.Check.name -> int) -> M.Order.estimates -> now:Ptime.t -> policy -> M.Order.entry list -> course list(** [run ~duration e ~now policy queue] is the course of each land of [queue], in the order given, under [policy] with [e] as its estimates; each arrives at its job's [arrived], [now] being the simulation's start, and its checks take [duration] milliseconds each.
@raise Failure if a land never lands. *)
val lead_ms : course -> int(** [lead_ms l] is [l]'s lead time: from its arrival to its landing. *)
val mean_lead_ms : course list -> int(** [mean_lead_ms ls] is the mean of {!lead_ms} over [ls], rounded down. *)
val pp : course Fmt.t(** [pp] formats a land as [NAME arrived A, checked S-L on base N]. *)