Skip to content

fix(runtime): find it once, hold it on the owner, pass a reference — the runtime/deploy rows of the re-derivation survey (card 948c30c2, rows 4, 5, 14, 15, 16, 18 + the persona seat path) - #4262

Merged
joelteply merged 1 commit into
canaryfrom
fix/find-it-once-hold-it-on-the-owner-runtime
Sep 20, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/find-it-once-hold-it-on-the-owner-runtime

Conversation

@joelteply

@joelteply joelteply commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Joel, 2026-09-20: "rederiving = outrageously expensive CPU everywhere". Each row below is
a fact re-derived on a tick that its owner could hold; each now has one owner and a
receipt (reads per tick before → after).

  • (5) memory_pressure: the anomaly scan — a full process-table refresh and, on macOS, a
    ps child on its own thread — ran on EVERY 2 s poll while pressure stayed High. Now
    anomaly_scan_due: the first tick of an episode, then once per ANOMALY_SCAN_EVERY
    (30 s); a drop below High re-arms the immediate read. 30 table refreshes + 30 process
    spawns a minute → 2. Pinned.
  • (4) runtime tick loop: module.config() was rebuilt every tick for every module just
    to read tick_interval (a persona at 250 ms; ChannelModule through an RwLock read +
    clone). ServiceModule::tick_interval_now() (default None = the registered cadence
    stands) is the loop's read; ChannelModule, the one moving cadence, overrides it with
    its one lock read. 90 ModuleConfig builds per tick round → 0.
  • (16) ChannelModule: env::var(CONTINUUM_DB_URL) per tick for a process-lifetime value
    → resolved once at construction, held on the module.
  • (14) deploy_tracker: state_dir joined twice per tick → held on the module.
  • (15) benchmark_standing: load_config() re-read and re-parsed the JSON per 300 s tick,
    per command and per citizen-health hour → held in-process, replaced by save_config,
    the only writer. One read per process.
  • (18) memguard loop: current_rss_mb() read twice per 10 s tick (once inside
    dump_memory_report, once for the limit) → one reading, passed.
  • persona seat path: resting_seat::resting() and roster_hold::active() re-read and
    re-parsed their JSON on every seats() call (nine sites, every reconcile pass). Each
    now holds its copy and drops it in its own writers (rest/wake, set/clear); an
    expired held hold falls through to the self-cleaning disk read so the file never
    outlives its hold.

Receipt: 113 passed / 0 failed (memory_pressure, channel, deploy_tracker, resting_seat,
roster_hold, benchmark_standing, runtime, source_hygiene — ratchets green), REAL_EXIT 0;
cargo check --lib clean.

Faster or slower?

Faster for every citizen on a pressured box (the 2 s process-table refresh + ps spawn is gone) and on every reconcile pass (two JSON parses per seats() call gone); nothing slower.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…the runtime/deploy rows of the re-derivation survey (card 948c30c2, rows 4, 5, 14, 15, 16, 18 + the persona seat path)

Joel, 2026-09-20: "rederiving = outrageously expensive CPU everywhere". Each row below is
a fact re-derived on a tick that its owner could hold; each now has one owner and a
receipt (reads per tick before → after).

- (5) memory_pressure: the anomaly scan — a full process-table refresh and, on macOS, a
  `ps` child on its own thread — ran on EVERY 2 s poll while pressure stayed High. Now
  `anomaly_scan_due`: the first tick of an episode, then once per ANOMALY_SCAN_EVERY
  (30 s); a drop below High re-arms the immediate read. 30 table refreshes + 30 process
  spawns a minute → 2. Pinned.
- (4) runtime tick loop: `module.config()` was rebuilt every tick for every module just
  to read `tick_interval` (a persona at 250 ms; ChannelModule through an RwLock read +
  clone). `ServiceModule::tick_interval_now()` (default None = the registered cadence
  stands) is the loop's read; ChannelModule, the one moving cadence, overrides it with
  its one lock read. 90 ModuleConfig builds per tick round → 0.
- (16) ChannelModule: `env::var(CONTINUUM_DB_URL)` per tick for a process-lifetime value
  → resolved once at construction, held on the module.
- (14) deploy_tracker: `state_dir` joined twice per tick → held on the module.
- (15) benchmark_standing: `load_config()` re-read and re-parsed the JSON per 300 s tick,
  per command and per citizen-health hour → held in-process, replaced by `save_config`,
  the only writer. One read per process.
- (18) memguard loop: `current_rss_mb()` read twice per 10 s tick (once inside
  dump_memory_report, once for the limit) → one reading, passed.
- persona seat path: `resting_seat::resting()` and `roster_hold::active()` re-read and
  re-parsed their JSON on every `seats()` call (nine sites, every reconcile pass). Each
  now holds its copy and drops it in its own writers (`rest`/`wake`, `set`/`clear`); an
  expired held hold falls through to the self-cleaning disk read so the file never
  outlives its hold.

Receipt: 113 passed / 0 failed (memory_pressure, channel, deploy_tracker, resting_seat,
roster_hold, benchmark_standing, runtime, source_hygiene — ratchets green), REAL_EXIT 0;
`cargo check --lib` clean.

Faster or slower: faster for every citizen on a pressured box (the 2 s ps storm is gone)
and on the reconcile pass (two file parses per seats() call gone); nothing slower.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE at exact head 4f4591e — merge on green. Read every held copy against its writers: resting-seats and roster-hold are written only in-process (commands/persona/instances/{wake,hold}.rs and citizen_health), so one process holds one truth and the writers drop it; the lapsed-hold fall-through keeps the file from outliving the hold. tick_interval_now: ChannelModule is the only module whose cadence moves (grep: every other ServiceModule declares a literal). anomaly_scan_due pinned. One note, not a condition: a standing-config JSON edited by hand is unseen until the next boot now — say so in load_config's doc or in the file's header so nobody debugs a silent no-op.

@joelteply
joelteply merged commit c1650f4 into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/find-it-once-hold-it-on-the-owner-runtime branch September 20, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant