Debian Codegraph @

engine/profile_tactic.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11
12 (** Ltac profiling primitives *)
13
14 (* Note(JasonGross): Ltac semantics are a bit insane. There isn't
15 really a good notion of how many times a tactic has been "called",
16 because tactics can be partially evaluated, and it's unclear
17 whether the number of "calls" should be the number of times the
18 body is fetched and unfolded, or the number of times the code is
19 executed to a value, etc. The logic in [Tacinterp.eval_tactic]
20 gives a decent approximation, which I believe roughly corresponds
21 to the number of times that the engine runs the tactic value which
22 results from evaluating the tactic expression bound to the name
23 we're considering. However, this is a poor approximation of the
24 time spent in the tactic; we want to consider time spent evaluating
25 a tactic expression to a tactic value to be time spent in the
26 expression, not just time spent in the caller of the expression.
27 So we need to wrap some nodes in additional profiling calls which
28 don't count towards to total call count. Whether or not a call
29 "counts" is indicated by the [count_call] boolean argument.
30
31 Unfortunately, at present, we can get very strange call graphs when
32 a named tactic expression never runs as a tactic value: if we have
33 [Ltac t0 := t.] and [Ltac t1 := t0.], then [t1] is considered to
34 run 0(!) times. It evaluates to [t] during tactic expression
35 evaluation, and although the call trace records the fact that it
36 was called by [t0] which was called by [t1], the tactic running
37 phase never sees this. Thus we get one call tree (from expression
38 evaluation) that has [t1] calls [t0] calls [t], and another call
39 tree which says that the caller of [t1] calls [t] directly; the
40 expression evaluation time goes in the first tree, and the call
41 count and tactic running time goes in the second tree. Alas, I
42 suspect that fixing this requires a redesign of how the profiler
43 hooks into the tactic engine. *)
44 val do_profile_gen :
45 ('a -> Pp.t option) -> 'a ->
46 ?count_call:bool -> 'b Proofview.tactic -> 'b Proofview.tactic
47
48 val set_profiling : bool -> unit
49
50 val get_profiling : unit -> bool
51
52 (* Cut off results < than specified cutoff *)
53 val print_results : cutoff:float option -> unit
54
55 val print_results_tactic : string -> unit
56
57 val reset_profile : unit -> unit
58
59 val restart_timer : string option -> unit
60
61 val finish_timing : prefix:string -> string option -> unit
62
63 val do_print_results_at_close : unit -> unit
64
65 (* The collected statistics for a tactic. The timing data is collected over all
66 * instances of a given tactic from its parent. E.g. if tactic 'aaa' calls
67 * 'foo' twice, then 'aaa' will contain just one entry for 'foo' with the
68 * statistics of the two invocations combined, and also combined over all
69 * invocations of 'aaa'.
70 * total: time spent running this tactic and its subtactics (seconds)
71 * local: time spent running this tactic, minus its subtactics (seconds)
72 * ncalls: the number of invocations of this tactic that have been made
73 * max_total: the greatest running time of a single invocation (seconds)
74 *)
75 type treenode = {
76 name : string;
77 total : float;
78 local : float;
79 ncalls : int;
80 max_total : float;
81 children : treenode CString.Map.t
82 }
83
84 (* Returns the profiling results known by the current process *)
85 val get_local_profiling_results : unit -> treenode
86 val feedback_results : treenode -> unit
87
88 val set_get_printing_width : (unit -> int) -> unit
89 (** Internal hook *)