Repository navigation
P5 O2: a memory-reducing collection at each entry into idle (Decision Log 124, owed (2)) - #324
Conversation
…nce at each entry into idle (P5 Decision Log 124, owed (2)) Each long-lived Node process runs one V8 last-resort collection when it goes idle by its own facts, after its start and on each later return, never on a timer (@shared/host/idle-collect.ts). The gc extension is made in one fresh context with --expose-gc on only for that moment, so no global gc exists and nothing else can call it; an entry that finds the heap within 1 MiB of what the last collection left collects nothing, so a client that comes and goes costs one collection at most. - mawsd (clocks.ts): quiet from its start's end on, with no client on any socket, an empty interest union and no hold. - The engine host (supervision.ts): quiet once it serves, with no client interest, every live row idle by E10's isIdleRow and the plugin runner idle; the process table now tells interest changes. - The pty host (register.ts): quiet with no live pty, after its start's login-shell capture. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…holding collects, and nothing collects through an exit - The collector (@shared/host/idle-collect.ts): an entry collects when the heap's use or its pages grew by GROWTH_BYTES since the last collection, so work inside the pages V8 kept is seen; `dropped()` collects while idle past the guard, for garbage neither size shows; `stop()` ends every later collection, a queued one included. - The engine host (supervision.ts): quiet waits for the startup gate (designSystems.ready) to settle; the plugin runner tells each time it becomes busy (runner.ts `onBusy`) and Supervision refreshes on it; a live row that ends with the host quiet (an idle release, an engine's exit) is told as a dropped holding; a stop-all, in either mode, and a leave tell quiet false for good; engine.shutdown's body stops the collector, so every exit path is covered (index.ts). - mawsd: its exit stops the collector beside the clocks, so an entry the last evaluation queued does not run. - The pty host: the table tells its shutdown before it ends any pty (`onShutdown`), and the register stops the collector there, so the shutdown's last exit is not an entry. - mawsd-scene.ts: the `collect` stand-in's type is written out (tsc's TS2742 on the inferred one). Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…finds the process busy A dropped() queued while idle kept its guard bypass only until the next deferred turn, so work that made the process busy before that turn lost it, and the next entry, finding neither heap size grown, collected nothing. The bypass now stays owed until a collection runs while idle (a failed one included) or the collector stops. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…t from its CLI's spawn A read (plugins.list, marketplaces.list, plugins.available) has no Operation, so the runner counted it only once its CLI's group existed; its preparation (the binary probe, the directory's stat, the environment capture, which may be a login shell's) ran with busy() false and no onBusy, and a collection queued at a quiet transition could land on it (round 3 review, finding 2). The runner now counts a read from its entry to its end or failure: busy() is true and onBusy fires at once, and onIdle when the read settles. The supervisor's idle exit and exit-when-idle, which read the same busy(), now wait for a read's preparation too. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…t again, over its live state A source can begin work before it tells it: EngineSession.send() marks its use (a status still at rest) and then makes its queue busy, which it tells only once linked-read preparation and the queue's save settle; with saveQueue() held, a collection ran while session.status().busy was true (round 3 review, finding 1). Three earlier rounds each fixed one missed signal; this fixes the class. - The collector (@shared/host/idle-collect.ts) takes the process's own quiet predicate (`quiet`, required) and asks it at the moment of collecting. A process it finds busy is not idle: nothing collects, a dropped holding stays owed, and the next reading that finds it quiet is an entry. Callers now tell every reading, not only a change, so that entry comes at the next refresh even when the busy spell is never told. - The engine host: Supervision.quiet() reads the rows' live status (budget.ts isIdleRow), interest, a launch preparing, the runner's busy(), the startup gate, a stop-all and an exit; index.ts hands it to the collector. - A launch's preparation (the binary probe, relay check and environment capture before its row exists) is held in the process table from its entry (ProcessTable.preparing / launching, told through onHoldChanged, which replaces onInterestChanged and carries interest too). - mawsd: DaemonClocks.quiet() is the collector's predicate. An app between a relay's socket and the client count (a hello waiting on its admission, a departure until its drain ends the app's side) holds the quiet (Relay.between(), told through the new `between` option), so the departure's entry comes once the drain is done; the exit clock still counts welcomed clients only. - The pty host: the table's quiet() (no live pty, no shutdown begun) is the collector's predicate. - Tests: per process, a table with one row per source the collection-time quiet reads, each made pending as a queued collection runs (on the engine host told to no one), asserting it is held off; the reviewer's reproduction over the real ProcessTable and EngineSession with saveQueue() held, and over the real runner with its binary check held; the relay's between() over its admission and its drain. Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
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. |
|
The proof on the mini is in, and the description's proof section is filled in. On ad09678, four e2e:daemon-idle runs count under the architect's landing rule. Each verdict comes from the shipped Rule B
The A-B-A on this head, 40816219223, is void under both rules. That was XProtect's scan, in A'. Its ratio was x1.454. Master's additions since 781b88c add about +0.8 MiB to the engine host (+813 KiB in the mean). Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook) |
… shape 6.6 to 7.8% under acceptance 14's bound; O2's over-bound reading recorded as it was; the headroom row closed, a row for the burst-tolerant load rule Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…for the measured series Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
P5 O2: a memory-reducing collection at each entry into idle (P5 Decision Log 124, owed (2))
MAWS's three long-lived Node processes are
mawsd, the engine host and the pty host. Each now runs one synchronous V8 last-resort collection at every entry into idle, the first right after its start. This is production behaviour, not a test aid, so the daemon-idle bound measures what a user's machine does (the architect's ruling, 587).Why
Each process grows V8's young generation to 16 MiB during its start. When V8 later shrinks it, it keeps those pages for a run-dependent share of runs, and no later collection returns them. Locally, plain:
mawsdread 29,169 to 40,929 KiB, and the engine host 65,537 to 88,577, with their heaps the same 16 to 17 MiB.mawsd) and 64,897 to 67,057 (engine host).mawsd), from 85.0–85.4 to 49.9–50.0 MB (engine host) and from 36.6–36.7 to 24.4–24.7 MB (pty host).What counts as idle, per process
Each process's quiet is told to the collector at every reading. The collector asks it again synchronously at the moment it collects, on the loop's next turn (
setImmediate). A late busy signal can therefore only delay a collection, never let one run during work.mawsd(DaemonClocks.quiet,src/mawsd/clocks.ts): serving and not stopped; no client on any socket; no app between (an app's hello waiting for a parked host to wake, or a departing app's drain still forwarding,Relay.between); an empty interest union, with no remote viewer either; and no hold.Supervision.quiet,src/engine-host/supervision.ts):status().A live row that ends while quiet (an idle release, a stop, an engine's exit) is a dropped holding and collects past the guard.
PtyTable.quiet,src/pty-host/table.ts): no live pty and no shutdown begun. It is entered once after its start, behind the login-shell capture, and each time its last terminal exits. Its shutdown stops the collector.An entry whose heap grew by less than 1 MiB, in both used size and pages, since the last collection collects nothing, unless a dropped holding forces it. The gc extension is made in one fresh context with
--expose-gcon only for that moment, so no globalgcexists. Each collection logs its duration and the heap before and after:idle: collected in 22 ms, heap 58.1 to 31.4 MiB (used 37.1 to 30.5). That way real use on the owner's machine shows any long pause without a bench.The busy-source table tests pin the class, not the instance (the architect, 588). Every busy source each predicate reads is set pending at the moment a queued collection runs, and the row asserts the collection is vetoed: 17 rows on the engine host, 4 on
mawsdand 2 on the pty host. A missed signal shows up as a missing row.The pause at a large heap
Measured on the MacBook (M1 Max, 1-minute load 5.3–9.2) at 3487028, in the daemon shape over C3's replay. The app was connected with no interest and
idleExitMinuteswas null. 23 runs, all passed (data: the desk track's scratch/idle-gc-pause/). Each cell below is the engine host's collection time, the range over runs. The measured line wasidle: collected in N msfromhost.log.The proof on the mini
The bound is P5 Decision Log 128's: 99,145 KiB and 1.12 s. The architect's landing rule (632, 641):
invalidReasonsandloadPairintest/support/daemon-idle.ts, at a2fc850 on the load-rule branch p5-o2-load-rule, run on each run's recorded samples.A run valid under the peak rule uploads no artifact. Such a run is replayed from its line's peak, which is under 5, so it is valid by the rule's guard.
Every run was on the mini, inside CI-opt's measured hold on 2026-10-29.
The landing set, on ad09678 (the merged head):
The A-B-A on ad09678 (40816219223), recorded as data. It is void under both rules: A' reached 6.5 with a pair of 5.43, from macOS's XProtect Remediator scans, sustained for about two minutes.
The enrolled run on ad09678 (40826529043) is valid under Rule B. The architect ruled that one rule covers every measured idle window (645).
The lever on its own tree, 781b88c (before master's merge; replayed the same way):
What the series shows.
The ranges overlap only where 781b88c's A', 63,377, sits above ad09678's two lowest, 63,201 and 63,265.
$Nidentifiers, and diffsout/main. The additions are:OrgMemberSchema;src/endpoint/by-effect.tsgrows by 4 lines.Rejected
--js-flagsin utility processes and the LaunchAgent's argv. It stays the fallback only if the mini'smawsdspread holds at 1 MiB or more. The architect rules on it then.--semi-space-growth-factor=1set in-process. It works only because V8 checks it at heap setup.Commits
Gates
plugins/runner.ts), both green.Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)