Skip to content

perf(engine): cheaper launch, salvage scan, harness checks and version probes - #71

Merged
ShriD5 merged 2 commits into
mainfrom
perf/idle-zero-launch
Oct 30, 2026
Merged

ShriD5 merged 2 commits into
mainfrom
perf/idle-zero-launch

Conversation

@ShriD5

@ShriD5 ShriD5 commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Launch-time part of the idle-zero work: less work in the first minutes after launch, and no repeat of it on every relaunch.

Changes

  • Salvage scan (5 s after launch) stops decoding every journaled chat.
    • Emptiness is the messages list's length (SessionDoc::has_message_entries), not a materialization of every entry.
    • A journal whose size and mtime match the boot that last found its doc healthy is skipped without loading the doc at all. The ledger is transcript-salvage.json, beside the journals dir. A doc can only lose its transcript in a session that also wrote its journal, so an unchanged journal needs no second look.
    • The recovery retry loop backs off between passes and ends once nothing is pending, instead of waking every 30 s for the life of the engine.
  • Harness update checks wait and persist. The checks (--version, claude doctor, npm/GitHub, brew) start 90 s after launch instead of immediately. A complete check is cached in harness-update-status.json. A relaunch within the 6 h interval shows it, with dismissals re-applied, and schedules the next check for when it is due. Failed or partial checks are never restored, and an install clears the cache.
  • Version probes run outside the global lock. This ports the version-probe part of upstream zeronsh/zeron 2e151ca6. binary_version held the global cache mutex across a CLI's --version, so one slow binary stalled every harness's resolution, and any failure (timeouts included) was cached for the binary's whole life. Probes now coalesce per binary. An inconclusive probe is retried after 30 s, a definite failure after 60 s, and an install racing a probe discards its answer. Our neutral probe working directory is kept.

Before / after

Same headless bench as #69: fresh data dir, 10 worktree chats, 2 PR watches, unattended client, 180 s settle, then 10 minutes measured.

Before After
Launch window (180 s) git / gh 151 / 6 151 / 6
10 idle min git / gh 375 / 14 375 / 14
Engine CPU (10 min) 2.85 s 2.94 s

The bench cannot show this PR. Its chats are fresh, with no journals, so the salvage scan has nothing to decode. Its PATH exposes no agent CLIs, so there is nothing for the harness checks to probe. The behaviour is pinned by tests instead:

  • harness_updates::launch_waits_and_relaunch_reuses_a_fresh_check: no CLI probe at launch; a relaunch shows the cached answer with zero new probes; a dismissal survives the relaunch.
  • harness_updates::stale_or_unsettled_caches_are_not_restored
  • doc_host::salvage_sweep_remembers_healthy_journals, salvage_inspection_does_not_open_healthy_or_unrecoverable_chats
  • schema::has_message_entries_reads_the_length_only
  • Ported from upstream: executable::concurrent_probes_coalesce_per_binary_without_a_global_wait, timed_out_probe_is_retried_after_its_ttl_but_answers_are_kept, a_failed_probe_is_retried_once_its_failure_ages_out, a_probe_racing_an_invalidation_does_not_cache_its_answer, version_probe_bounds_hangs_and_rejects_nonzero

Local runs: zeron-harness executable tests 21 passed, zeron-doc 1 passed, zeron-engine harness_updates:: + salvage 39 passed.

Salvage scan (5 s after launch):
- Emptiness is the messages list's length, not a decode of every entry.
- A journal whose size and mtime match the boot that last found its doc
  healthy is skipped without loading the doc (transcript-salvage.json
  beside the journals dir). A doc only loses its transcript in a session
  that also wrote its journal.
- The recovery retry loop backs off between passes and ends once nothing
  is pending, instead of waking every 30 s forever.

Harness update checks (--version, claude doctor, npm/GitHub, brew):
- The first check waits 90 s after launch.
- A complete check is cached (harness-update-status.json); a relaunch
  within the 6 h interval shows it, with dismissals re-applied, and
  schedules the next check for when it is due. Failed or partial checks
  are never restored, and an install clears the cache.
Port of the version-probe part of upstream zeronsh/zeron 2e151ca6.
binary_version held the global cache mutex across a CLI's `--version`,
so one slow binary stalled every harness's resolution, and any failure
(timeouts included) was cached for the binary's whole life.

Probes now run outside the global lock with per-binary coalescing; an
inconclusive probe is retried after 30 s and a definite failure after
60 s; an install invalidation racing a probe discards its answer. The
probe keeps running in Godspeed's neutral working directory.
@ShriD5
ShriD5 merged commit 65738c9 into main Oct 30, 2026
23 checks passed
@ShriD5
ShriD5 deleted the perf/idle-zero-launch branch October 30, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant