1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Whether a reduction that came back late is kept or discarded: the outcome
//! classes, the boundary between them, and the one acceptance policy every
//! reduce path runs. Pure of the shim and of the stage driver, so the
//! boundaries are unit-testable on their own.
use ;
use cratediag;
use crateVitriError;
use ;
/// How far past `deadline` a reduction may return and still count as a
/// **deadline cut** (layer 1 stopped it cooperatively) rather than an
/// uncontrolled **overrun** (layer 1 never got a poll site and the stage simply
/// ran long).
///
/// Sized from the mechanism, not from taste: Arjun's deadline is polled at the
/// existing abort/loop sites (between `elim_to_file` steps, the independent-
/// support and extend loops, the CMS-oracle and CadiBack budget-exhausted
/// paths), so a cut lands at the next poll — a propagation/simplify step past
/// the deadline, not an unbounded interval — plus the read-back/serialize cost.
/// 5 s leaves room for a slower box and a large read-back while staying far
/// below the multiples (1.3–5×) that characterize the overrun class.
///
/// The independent outer bound: in the default forked configuration the
/// backstop `SIGKILL`s the child at `deadline + fork_budget::KILL_GRACE`, so a
/// cut later than that never reaches this classification (the caller sees the
/// hard-kill give-up line instead). The effective window is the smaller of the
/// two; this constant defines the class, the fork grace bounds the wall, and
/// raising the latter would spend extra budget on the overrun class, which is
/// discarded either way.
pub const DEADLINE_CUT_GRACE: Duration = from_millis;
/// What a reduce path's budget behaviour was, relative to its budget. Three
/// distinct classes: [`Self::DeadlineCut`] — the in-process deadline stopping a
/// stage cooperatively — is kept separate from [`Self::Overrun`] because the
/// two get opposite accept/discard treatment below.
pub
/// Classify a reduce path's outcome. Pure (no clock, no env) so the boundaries
/// are unit-testable; `finished` is when the stages returned.
pub
/// The one past-deadline acceptance policy. Returns true to hand the
/// checkpoint back to the caller, false to discard it (caller falls back to
/// the raw formula). Logs the give-up/cut line, so the classification and the
/// message describing it cannot drift.
pub
/// Whether a full-count reduction that finished past its budget is still
/// returned to the caller instead of discarded. Default off (discard): a
/// more-reduced formula is not necessarily a more compilable one, and the
/// accept gate cannot see compile-friendliness. `VITRI_ARJUN_KEEP_OVERRUN=1`
/// (also `on`/`true`) opts in.
///
/// Scope: this knob is about the [`BudgetClass::Overrun`] class only —
/// [`BudgetClass::DeadlineCut`] is kept unconditionally regardless.
///
/// # Errors
///
/// [`VitriError::Env`] when the variable is set to neither an on nor an off
/// spelling.
pub