mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
feat(profile): add instant probe
This commit is contained in:
parent
fafb001934
commit
3979380896
6 changed files with 68 additions and 12 deletions
|
|
@ -368,7 +368,8 @@ module Make(A : ARG) : S with module A = A = struct
|
||||||
end)
|
end)
|
||||||
end;
|
end;
|
||||||
Log.debug 5 "lra: call arith solver";
|
Log.debug 5 "lra: call arith solver";
|
||||||
begin match SimpSolver.solve simplex with
|
let res = Profile.with1 "simplex.solve" SimpSolver.solve simplex in
|
||||||
|
begin match res with
|
||||||
| SimpSolver.Solution _m ->
|
| SimpSolver.Solution _m ->
|
||||||
Log.debug 5 "lra: solver returns SAT";
|
Log.debug 5 "lra: solver returns SAT";
|
||||||
Log.debugf 50
|
Log.debugf 50
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,7 @@ module Make (A: CC_ARG)
|
||||||
end
|
end
|
||||||
|
|
||||||
let raise_conflict (cc:t) ~th (acts:actions) (e:lit list) : _ =
|
let raise_conflict (cc:t) ~th (acts:actions) (e:lit list) : _ =
|
||||||
|
Profile.instant "cc.conflict";
|
||||||
(* clear tasks queue *)
|
(* clear tasks queue *)
|
||||||
Vec.clear cc.pending;
|
Vec.clear cc.pending;
|
||||||
Vec.clear cc.combine;
|
Vec.clear cc.combine;
|
||||||
|
|
|
||||||
|
|
@ -353,10 +353,12 @@ module Make(A : ARG)
|
||||||
|
|
||||||
(* propagation from the bool solver *)
|
(* propagation from the bool solver *)
|
||||||
let check_ ~final (self:t) (acts: msat_acts) =
|
let check_ ~final (self:t) (acts: msat_acts) =
|
||||||
|
let pb = if final then Profile.begin_ "solver.final-check" else Profile.null_probe in
|
||||||
let iter = iter_atoms_ acts in
|
let iter = iter_atoms_ acts in
|
||||||
Msat.Log.debugf 5 (fun k->k "(msat-solver.assume :len %d)" (Iter.length iter));
|
Msat.Log.debugf 5 (fun k->k "(msat-solver.assume :len %d)" (Iter.length iter));
|
||||||
self.on_progress();
|
self.on_progress();
|
||||||
assert_lits_ ~final self acts iter
|
assert_lits_ ~final self acts iter;
|
||||||
|
Profile.exit pb
|
||||||
|
|
||||||
(* propagation from the bool solver *)
|
(* propagation from the bool solver *)
|
||||||
let[@inline] partial_check (self:t) (acts:_ Msat.acts) : unit =
|
let[@inline] partial_check (self:t) (acts:_ Msat.acts) : unit =
|
||||||
|
|
|
||||||
|
|
@ -34,20 +34,32 @@ module Make()
|
||||||
let now = Mtime_clock.now() in
|
let now = Mtime_clock.now() in
|
||||||
Mtime.Span.to_us (Mtime.span program_start now)
|
Mtime.Span.to_us (Mtime.span program_start now)
|
||||||
|
|
||||||
let emit_event ~name ~start ~end_ () : unit =
|
let emit_sep_ () =
|
||||||
let dur = end_ -. start in
|
|
||||||
let ts = start in
|
|
||||||
let pid = Unix.getpid() in
|
|
||||||
let tid = Thread.id (Thread.self()) in
|
|
||||||
if !first_ then (
|
if !first_ then (
|
||||||
first_ := false;
|
first_ := false;
|
||||||
) else (
|
) else (
|
||||||
output_string oc ",\n";
|
output_string oc ",\n";
|
||||||
);
|
)
|
||||||
|
|
||||||
|
let emit_duration_event ~name ~start ~end_ () : unit =
|
||||||
|
let dur = end_ -. start in
|
||||||
|
let ts = start in
|
||||||
|
let pid = Unix.getpid() in
|
||||||
|
let tid = Thread.id (Thread.self()) in
|
||||||
|
emit_sep_();
|
||||||
Printf.fprintf oc
|
Printf.fprintf oc
|
||||||
{json|{"pid": %d,"cat":"","tid": %d,"dur": %.2f,"ts": %.2f,"name":"%s","ph":"X"}|json}
|
{json|{"pid": %d,"cat":"","tid": %d,"dur": %.2f,"ts": %.2f,"name":"%s","ph":"X"}|json}
|
||||||
pid tid dur ts name;
|
pid tid dur ts name;
|
||||||
flush oc
|
()
|
||||||
|
|
||||||
|
let emit_instant_event ~name ~ts () : unit =
|
||||||
|
let pid = Unix.getpid() in
|
||||||
|
let tid = Thread.id (Thread.self()) in
|
||||||
|
emit_sep_();
|
||||||
|
Printf.fprintf oc
|
||||||
|
{json|{"pid": %d,"cat":"","tid": %d,"ts": %.2f,"name":"%s","ph":"I"}|json}
|
||||||
|
pid tid ts name;
|
||||||
|
()
|
||||||
|
|
||||||
let teardown () = teardown_ oc
|
let teardown () = teardown_ oc
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,19 @@
|
||||||
module type BACKEND = sig
|
module type BACKEND = sig
|
||||||
val get_ts : unit -> float
|
val get_ts : unit -> float
|
||||||
|
|
||||||
val emit_event :
|
val emit_duration_event :
|
||||||
name : string ->
|
name : string ->
|
||||||
start : float ->
|
start : float ->
|
||||||
end_ : float ->
|
end_ : float ->
|
||||||
unit ->
|
unit ->
|
||||||
unit
|
unit
|
||||||
|
|
||||||
|
val emit_instant_event :
|
||||||
|
name : string ->
|
||||||
|
ts : float ->
|
||||||
|
unit ->
|
||||||
|
unit
|
||||||
|
|
||||||
val teardown : unit -> unit
|
val teardown : unit -> unit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -21,6 +27,8 @@ type probe =
|
||||||
start: float;
|
start: float;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let null_probe = No_probe
|
||||||
|
|
||||||
(* where to print events *)
|
(* where to print events *)
|
||||||
let out_ : backend option ref = ref None
|
let out_ : backend option ref = ref None
|
||||||
|
|
||||||
|
|
@ -32,10 +40,17 @@ let[@inline] begin_ name : probe =
|
||||||
| None -> No_probe
|
| None -> No_probe
|
||||||
| Some b -> begin_with_ b name
|
| Some b -> begin_with_ b name
|
||||||
|
|
||||||
|
let[@inline] instant name =
|
||||||
|
match !out_ with
|
||||||
|
| None -> ()
|
||||||
|
| Some (module B) ->
|
||||||
|
let now = B.get_ts() in
|
||||||
|
B.emit_instant_event ~name ~ts:now ()
|
||||||
|
|
||||||
(* slow path *)
|
(* slow path *)
|
||||||
let exit_full_ (module B : BACKEND) name start =
|
let exit_full_ (module B : BACKEND) name start =
|
||||||
let now = B.get_ts() in
|
let now = B.get_ts() in
|
||||||
B.emit_event ~name ~start ~end_:now ()
|
B.emit_duration_event ~name ~start ~end_:now ()
|
||||||
|
|
||||||
let exit_with_ b pb =
|
let exit_with_ b pb =
|
||||||
match pb with
|
match pb with
|
||||||
|
|
@ -60,6 +75,19 @@ let[@inline] with_ name f =
|
||||||
exit_with_ b pb;
|
exit_with_ b pb;
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
let[@inline] with1 name f x =
|
||||||
|
match !out_ with
|
||||||
|
| None -> f x
|
||||||
|
| Some b ->
|
||||||
|
let pb = begin_with_ b name in
|
||||||
|
try
|
||||||
|
let res = f x in
|
||||||
|
exit_with_ b pb;
|
||||||
|
res
|
||||||
|
with e ->
|
||||||
|
exit_with_ b pb;
|
||||||
|
raise e
|
||||||
|
|
||||||
module Control = struct
|
module Control = struct
|
||||||
let setup b =
|
let setup b =
|
||||||
assert (!out_ = None);
|
assert (!out_ = None);
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,34 @@
|
||||||
|
|
||||||
type probe
|
type probe
|
||||||
|
|
||||||
|
val null_probe : probe
|
||||||
|
|
||||||
|
val instant : string -> unit
|
||||||
|
|
||||||
val begin_ : string -> probe
|
val begin_ : string -> probe
|
||||||
|
|
||||||
val exit : probe -> unit
|
val exit : probe -> unit
|
||||||
|
|
||||||
val with_ : string -> (unit -> 'a) -> 'a
|
val with_ : string -> (unit -> 'a) -> 'a
|
||||||
|
|
||||||
|
val with1 : string -> ('a -> 'b) -> 'a -> 'b
|
||||||
|
|
||||||
module type BACKEND = sig
|
module type BACKEND = sig
|
||||||
val get_ts : unit -> float
|
val get_ts : unit -> float
|
||||||
|
|
||||||
val emit_event :
|
val emit_duration_event :
|
||||||
name : string ->
|
name : string ->
|
||||||
start : float ->
|
start : float ->
|
||||||
end_ : float ->
|
end_ : float ->
|
||||||
unit ->
|
unit ->
|
||||||
unit
|
unit
|
||||||
|
|
||||||
|
val emit_instant_event :
|
||||||
|
name : string ->
|
||||||
|
ts : float ->
|
||||||
|
unit ->
|
||||||
|
unit
|
||||||
|
|
||||||
val teardown : unit -> unit
|
val teardown : unit -> unit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue