Skip to content

fix(bin): skip the timed re-exec for idle fm-inactive-reconcile scans - #71

Merged
max-metaplanet merged 3 commits into
mainfrom
fm/proc-start-quickwins
Oct 15, 2026
Merged

max-metaplanet merged 3 commits into
mainfrom
fm/proc-start-quickwins

Conversation

@max-metaplanet

Copy link
Copy Markdown
Owner

Summary

  • bin/fm-inactive-reconcile.sh scan runs every 15-second watcher poll in every home, but its 900-second cadence gate was only checked after a fm_run_timed re-exec (a perl fork on hosts with no timeout/gtimeout), a second bash+env re-exec of $0 _scan-locked, and the scan lock. About 59 of every 60 calls were idle and paid for all of that for nothing.
  • The cadence is now checked first, with the existing scan_marker_age helper (builtins and file tests, no re-exec). An idle, not-yet-due call returns immediately without the timed re-exec, perl/timeout fork, or the lock. ledger_pass still runs on every poll in a secondmate home, the --startup bypass is unchanged, and a due call still falls through to the existing locked, timed scan unchanged.
  • Measured on one idle poll with no pending work: 18 external process starts before (including the timed-exec fork) down to 4 after. At a 15-second poll cadence that's roughly 5,664 idle polls/day/home, each saving about 14 process starts, for about 79,000 fewer process starts per home per day from this one change.
  • Added tests/fm-inactive-reconcile.test.sh::test_idle_not_due_poll_skips_timed_reexec, which shims whichever timed-exec mechanism the host has (timeout, gtimeout, or perl) and asserts a due call still invokes it, an idle not-due call does not, and ledger_pass still delivers a secondmate's terminal ledger line on that same not-due poll.

CI-validated marker

Local validation would have run a no-mistakes Test step that selected a 28-script, 4-shard matrix (the full cross-cutting suite this change's selector resolved), which ran serially and quietly for 17+ minutes locally with no end in sight. Per the machine hold on this host (no heavy local builds, at most one heavy thing at a time), I stopped that local run, recovered the review step's fix already applied to this branch, and pushed directly so this repository's own parallel CI can validate instead. The fm-ci-validated label is applied at creation for that reason.

Test plan

  • bash tests/fm-inactive-reconcile.test.sh passes locally (all cases, including the new one).
  • bin/fm-lint.sh bin/fm-inactive-reconcile.sh passes.
  • GitHub CI (this PR is marked fm-ci-validated so CI's own parallel run is the validation of record).

@max-metaplanet max-metaplanet added the fm-ci-validated Deliberately validated by this repository CI instead of the local no-mistakes pipeline label Oct 15, 2026
Every watcher poll called fm-inactive-reconcile.sh scan, but about 59 of
every 60 calls were not yet due under the 900s cadence gate. Each still
paid for fm_run_timed's perl fork, a second bash+env re-exec of the
script, and the scan lock before the cadence check (inside scan())
returned 0. The cadence is now checked with the existing scan_marker_age
helper before any of that, so an idle, not-due call returns without the
re-exec, perl, or the lock; ledger_pass still runs on every poll in a
secondmate home, and a due call still falls through to the existing
locked, timed scan unchanged.

Measured on one idle poll with no pending work: 18 external process
starts before (including the perl fork) down to 4 after. At a 15-second
watcher cadence that is roughly 5,664 idle polls/day/home, each saving
about 14 process starts, for about 79,000 fewer process starts per home
per day.
ShellCheck's parser treated the bare done argument next to a
backslash line continuation as the loop keyword. Quoting it matches
the convention already used elsewhere in this file for the same
reported_outcome_key call.
@max-metaplanet
max-metaplanet force-pushed the fm/proc-start-quickwins branch from 1d85d2f to eef2b29 Compare October 15, 2026 02:30
@max-metaplanet
max-metaplanet merged commit 04cc12d into main Oct 15, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fm-ci-validated Deliberately validated by this repository CI instead of the local no-mistakes pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant