service_parity: two sugars in one drain; repeat a run whose recorder fell behind

The TASK-01 review's N1: a second sugar before the next commit is refused
with the first one's pulse as the retry, legacy and session alike. A run
whose recorder misses a frame on a loaded box is repeated rather than
failed (it cannot be compared, and it says nothing about either runtime).
This commit is contained in:
acamilo 2026-09-29 20:48:37 +00:00
parent 002fcbe26c
commit 0776fab225

View file

@ -131,6 +131,8 @@ fn script() -> Vec<Action> {
/// What one run produced. /// What one run produced.
struct Recording { struct Recording {
/// False when the recorder missed a frame; such a run is repeated, never compared.
complete: bool,
/// Every running snapshot: the comparable header and the attachments' digests. /// Every running snapshot: the comparable header and the attachments' digests.
running: Vec<(Value, [String; 3])>, running: Vec<(Value, [String; 3])>,
/// The idle headers a pause published (compared for shape, not count). /// The idle headers a pause published (compared for shape, not count).
@ -267,6 +269,7 @@ fn record(
let mut idle = Vec::new(); let mut idle = Vec::new();
let mut pending = Vec::new(); let mut pending = Vec::new();
let mut last_frame: Option<u64> = None; let mut last_frame: Option<u64> = None;
let mut complete = true;
let deadline = Instant::now() + Duration::from_secs(1800); let deadline = Instant::now() + Duration::from_secs(1800);
while running.len() < frames { while running.len() < frames {
assert!(Instant::now() < deadline, "{}: the run stalled", runtime.label()); assert!(Instant::now() < deadline, "{}: the run stalled", runtime.label());
@ -285,13 +288,17 @@ fn record(
FeedStatus::Running | FeedStatus::Recovering => { FeedStatus::Running | FeedStatus::Recovering => {
// Every frame publishes; a gap means the recorder fell behind the loop. // Every frame publishes; a gap means the recorder fell behind the loop.
let frame = snapshot.header.frame; let frame = snapshot.header.frame;
if let Some(last) = last_frame { if let Some(last) = last_frame
assert_eq!( && frame != last + 1
frame, {
last + 1, // The recorder fell behind the loop (a loaded box): this run cannot be
"{}: the recorder missed a frame (pace the loop slower)", // compared, and the caller runs it again.
runtime.label() eprintln!(
" {}: the recorder missed frames {}..{frame}; the run will be repeated",
runtime.label(),
last + 1
); );
complete = false;
} }
last_frame = Some(frame); last_frame = Some(frame);
let index = running.len(); let index = running.len();
@ -349,13 +356,13 @@ fn record(
.filter_map(|l| l.split([' ', '{']).next()) .filter_map(|l| l.split([' ', '{']).next())
.map(str::to_owned) .map(str::to_owned)
.collect(); .collect();
(running, idle, responses, status, metric_names) (running, idle, responses, status, metric_names, complete)
}); });
thread thread
.join() .join()
.expect("the loop thread") .expect("the loop thread")
.unwrap_or_else(|e| panic!("{}: {e:#}", runtime.label())); .unwrap_or_else(|e| panic!("{}: {e:#}", runtime.label()));
let (running, idle, responses, status, metric_names) = recording; let (running, idle, responses, status, metric_names, complete) = recording;
assert_eq!(running.len(), frames, "{}: the loop stopped early", runtime.label()); assert_eq!(running.len(), frames, "{}: the loop stopped early", runtime.label());
let events: Vec<Value> = shared let events: Vec<Value> = shared
@ -396,6 +403,7 @@ fn record(
.unwrap(); .unwrap();
let final_checkpoint = checkpoint_json(&bytes); let final_checkpoint = checkpoint_json(&bytes);
Recording { Recording {
complete,
running, running,
idle, idle,
responses, responses,
@ -597,28 +605,31 @@ fn run_pair(
init_tracing(); init_tracing();
let actions = script(); let actions = script();
let root = tempfile::tempdir().unwrap(); let root = tempfile::tempdir().unwrap();
let dir = root.path().join("legacy"); // One run of `runtime` from a freshly seeded copy of the store, repeated (up to three times)
// when the recorder fell behind the loop on a loaded box.
let run = |runtime: Runtime, name: &str| -> Recording {
for attempt in 1..=3 {
let dir = root.path().join(format!("{name}-{attempt}"));
seed(seeded, &dir); seed(seeded, &dir);
let started = Instant::now(); let recording = record(
let legacy = record( runtime,
Runtime::Legacy,
config(rom, dataset, &dir, mode, speed), config(rom, dataset, &dir, mode, speed),
profile, profile,
frames, frames,
&actions, &actions,
); );
if recording.complete {
return recording;
}
}
panic!("{}: the recorder fell behind three times", runtime.label());
};
let started = Instant::now();
let legacy = run(Runtime::Legacy, "legacy");
eprintln!("{label}: legacy {} running snapshots in {:.1?}", legacy.running.len(), started.elapsed()); eprintln!("{label}: legacy {} running snapshots in {:.1?}", legacy.running.len(), started.elapsed());
for exec in modes() { for exec in modes() {
let dir = root.path().join(format!("session-{}", exec.label()));
seed(seeded, &dir);
let started = Instant::now(); let started = Instant::now();
let session = record( let session = run(Runtime::Session(exec), &format!("session-{}", exec.label()));
Runtime::Session(exec),
config(rom, dataset, &dir, mode, speed),
profile,
frames,
&actions,
);
let label = format!("{label}, {}", exec.label()); let label = format!("{label}, {}", exec.label());
compare(&legacy, &session, &label); compare(&legacy, &session, &label);
let rewards = legacy let rewards = legacy