Repository navigation
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
Conversation
…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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).
pschild on its own thread — ran on EVERY 2 s poll while pressure stayed High. Nowanomaly_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.
module.config()was rebuilt every tick for every module justto read
tick_interval(a persona at 250 ms; ChannelModule through an RwLock read +clone).
ServiceModule::tick_interval_now()(default None = the registered cadencestands) is the loop's read; ChannelModule, the one moving cadence, overrides it with
its one lock read. 90 ModuleConfig builds per tick round → 0.
env::var(CONTINUUM_DB_URL)per tick for a process-lifetime value→ resolved once at construction, held on the module.
state_dirjoined twice per tick → held on the module.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.
current_rss_mb()read twice per 10 s tick (once insidedump_memory_report, once for the limit) → one reading, passed.
resting_seat::resting()androster_hold::active()re-read andre-parsed their JSON on every
seats()call (nine sites, every reconcile pass). Eachnow holds its copy and drops it in its own writers (
rest/wake,set/clear); anexpired 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 --libclean.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