Repository navigation
perf(harness-ops): reuse a fleet-state read in plugins sync when none of its inputs changed - #12977
Conversation
…anged fleet-state.sh writes every path it read or tested, absent ones included, to the file FLEET_STATE_READ_LIST names. sync-run.sh fingerprints that list with one stat (mtime and size per path) and reuses the stored report while the fingerprint is unchanged; a changed, created or removed path runs the read again. A report is stored only when no input can have changed during its read. The cache lives in the run directory, so an --only-install re-entry with the same environment reuses the first pass's last report. Each read and each reuse is journaled. Refs #12539 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz
The shell-portability check flags `stat -c` as GNU-only. Follow the repo's dual-dialect ladder: GNU first, then `stat -f` on empty output, since GNU stat exits non-zero whenever a listed path is absent. Refs #12539 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz
A write through a symlinked input moves the target and leaves the link's own mtime and size alone, so `stat` now dereferences (-L). A fingerprint line without a fractional mtime clears the whole fingerprint, so a `stat` that cannot report one turns reuse off instead of comparing on size alone. The default-marketplace read's journal line carries its elapsed time too. Refs #12539 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz
…ged during the read The fingerprint line for each listed path now carries mtime, ctime and size, or an explicit `absent` marker, so a deletion or a creation always changes it. An existing path with no stat line blanks the fingerprint, as a time without fractional digits already did. A report is stored only when an earlier read's list matches this one's, the fingerprints before and after the read match, and every present input's mtime and ctime are more than 2 s older than the read's start. The OR branch that stored on age alone is gone: it stored a read during which an input was deleted, or an old-mtime file was moved into place, and a same-size rewrite within one timestamp tick slipped past the exact comparison. A run's first read is never stored now, so an unchanged fleet takes two reads, not one. Refs #12539 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz
…e's real waits The store margin is now SYNC_FLEET_STATE_STORE_MARGIN_S (default 2 s, kept when unset or not a non-negative integer). The reuse cases that check counts set it to 0 instead of pausing 3 s; the ctime case keeps the default and its pause. A new case changes an input between an ask pass and its --only-install re-entry and asserts one live read that sees the change, so a lookup that ignores the fingerprint fails. The changelog fragment now names mtime, ctime and size, absent paths, and the unstored first read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz
…ate reuse docs Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #12977 (no security issues found)I read every hunk of all 5 changed files: the changelog fragment, What changed: What I checked:
Spend: none. The change only cuts local No embedded directives in the PR context. There were no prior findings (round 0 of cap 3), and no settled-threads file was provided. critical-findings: 0 |
|
claude-review reviewed Code review: no findingsI found nothing to block or flag. I read every hunk of all 5 changed files. To check the change in context, I also read the surrounding code in What the PR changes
What I checked
Not verified
Other notes
|
Post-merge mutation testingKilled 5, survived 2, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
Refs: #12539
Summary
Problem:
/harness-ops:plugins syncreadfleet-state.shup to 5 times per pass, at about 0.5 s per read on Linux and a reported 1.5 s on Git Bash. Intent: the owner decided to "reuse a prior fleet-state.sh read only when installed_plugins.json and the settings files it reads are unchanged (same mtime and size as at that read); otherwise read again".This PR delivers the snapshot-reuse item of #12539.
sync-run.shnow reuses a storedfleet-state.shreport only when a fresh fingerprint of every file that read touched equals the stored one. A report is stored only when the files could not have changed during the read.Fix
fleet-state.shwrites the path of every file it reads or tests, absent ones included, to the listFLEET_STATE_READ_LISTnames. The list therefore comes from the reader itself, not from a second copy in the caller.sync-run.shfingerprints that list with onestat -L: mtime, ctime and size, or anabsentmarker. A path with no stat line, or with no fractional time, blanks the fingerprint, which turns reuse off.SYNC_FLEET_STATE_STORE_MARGIN_Soverrides the margin).git rev-parseproject-root fallback, which runs whenCLAUDE_PROJECT_DIRis unset, andrealpathresults. Within one run the working directory is fixed, and the cache key includes it.Verification
sync-run.test.sh: all pass. The new cases cover reuse on unchanged inputs, a rewrite, an mtime-only change, a created settings file, a write through a symlink, a deletion during the read, an old file moved into place during the read, a fresh ctime, and a re-entry that detects a changed input. Each failed on the earlier code or with the lookup forced true.fleet-state.test.sh: 97 cases, 0 failed.check-affected.sh: 14 passed, 1 skipped. shellcheck is clean, and the changelog fragment check passed.statbranch. Both were read, not run.Remaining
Related
🤖 Generated with Claude Code
https://claude.ai/code/session_015te8Cr8u7uFJG4tdeUACLz