You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ac7cf22
Browse filesBrowse the repository at this point in the historyBrowse files
Stop parsing every historical run to find the newest one
Same theme as the last two performance passes, one call site further:
history::all_known_forms (behind `report`, `serve`'s /metrics and
/api/forms, and `baseline --write`) picked each form's newest run by
opening and fully parsing EVERY run file in that form's directory,
just to keep whichever had the largest timestamp - discarding every
other parsed run immediately after.
save_run already encodes the timestamp in the filename itself
({ts}.json or {ts}-{suffix}.json, for same-second collisions), so the
winner can be picked by comparing filenames alone - only that one file
actually needs to be read and deserialized. A form directory with
months of accumulated daily-monitor history now costs the same as one
with a single run, for exactly the commands (report generation, the
serve endpoints, baseline generation) that read across every known
form at once.
Side benefit this exposed: a single corrupted or truncated OLD run
file used to fail all_known_forms outright (and therefore report/
serve/baseline for that whole form, via `?` propagation) even though
the newest run was perfectly fine. It's now simply never read.
Also fixed report::build's own copy of the "find the run immediately
before this timestamp" snippet, missed when that was extracted into
history::previous_run in the last commit (d6f510f) - report.rs still
had its own copy-pasted .iter().rev().find(...).
Verified with a real regression test, not just reasoning: saved two
runs then corrupted the OLDER one's file in place and asserted
all_known_forms still returns the correct newest run. Confirmed the
test actually catches the regression it targets by temporarily
reverting to the old "parse everything, keep the max" implementation -
the test failed with a JSON parse error on the corrupted file, exactly
as predicted - then restored the fix.
cargo fmt/clippy -D warnings clean, full suite green (156 tests).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments