Skip to content

Add live machine inspection - #120

Merged
SandroMaglione merged 1 commit into
mainfrom
codex/live-machine-inspection
Aug 16, 2026
Merged

Add live machine inspection#120
SandroMaglione merged 1 commit into
mainfrom
codex/live-machine-inspection

Conversation

@SandroMaglione

Copy link
Copy Markdown
Member

Summary

  • Add Machine.prepare(machine).inspection, a hot root-scoped Effect Stream for ordered lifecycle, delivery, processing, emission, activity, and termination records across the local ownership tree.
  • Preserve causal evidence and equivalent behavior in the generic and compact runtimes, including explicit child-to-parent sends, retained microsteps, Effect/timer cancellation, startup failures, and typed decode failures.
  • Add AtomMachine.inspection, public documentation, runtime/type/differential coverage, and a pre-1.0 minor changeset.

Changeset

  • Added or updated for a library or package-metadata change
  • Not required because this PR does not change src/ or package.json

Validation

  • pnpm check
  • Relevant example checks, when examples changed (no example package changed)
  • Automated type-performance measurement passed locally; CI comparison pending
  • Automated runtime- and memory-performance measurement passed locally; CI comparison pending

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Type performance

Measured with TypeScript 6.0.3 and skipLibCheck=true.

Scenario Base PR Difference
Effect only 55 55 0 (0.0%)
Import effect-machine 55 55 0 (0.0%)
Machine.defineStates (3 states) 3,039 3,039 0 (0.0%)
Machine.make (3 states, 2 events) 13,199 13,199 0 (0.0%)
machine.handle (3 states, 2 transitions) 30,443 30,443 0 (0.0%)
Machine.invoke (state-dependent Effect) 70,236 70,236 0 (0.0%)
machine.handle (depth 24) 188,212 188,212 0 (0.0%)
machine.handle (wide depth 16) 220,710 220,710 0 (0.0%)
machine.handle (parallel/history/choice) 128,069 128,069 0 (0.0%)
machine.handle (4 successive calls) 135,838 135,838 0 (0.0%)
machine exact input/output/error/services 109,952 109,952 0 (0.0%)
execution adapter readiness 121,683 121,683 0 (0.0%)

Marginal instantiations are measured against the matching setup without that API call:

Scenario Base PR Difference
Import effect-machine 0 0 0
Machine.defineStates (3 states) 2,984 2,984 0 (0.0%)
Machine.make (3 states, 2 events) 10,152 10,152 0 (0.0%)
machine.handle (3 states, 2 transitions) 17,244 17,244 0 (0.0%)
Machine.invoke (state-dependent Effect) 59,203 59,203 0 (0.0%)
machine.handle (depth 24) 168,143 168,143 0 (0.0%)
machine.handle (wide depth 16) 201,702 201,702 0 (0.0%)
machine.handle (parallel/history/choice) 102,415 102,415 0 (0.0%)
machine.handle (4 successive calls) 114,587 114,587 0 (0.0%)
machine exact input/output/error/services 93,421 93,421 0 (0.0%)
execution adapter readiness 87,555 87,555 0 (0.0%)
Check times (informational)
Scenario Base PR
Effect only 0.03s 0.03s
Import effect-machine 0.03s 0.03s
Machine.defineStates (3 states) 0.10s 0.10s
Machine.make (3 states, 2 events) 0.17s 0.17s
machine.handle (3 states, 2 transitions) 0.25s 0.25s
Machine.invoke (state-dependent Effect) 0.40s 0.41s
machine.handle (depth 24) 0.66s 0.67s
machine.handle (wide depth 16) 0.68s 0.70s
machine.handle (parallel/history/choice) 0.54s 0.54s
machine.handle (4 successive calls) 0.54s 0.54s
machine exact input/output/error/services 0.51s 0.48s
execution adapter readiness 0.53s 0.50s

Type instantiations are the comparison metric. Check time varies with runner load and is informational only.

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Runtime performance

Median of 5 independent benchmark processes on AMD EPYC 7763 64-Core Processor with Node v24.19.0.

Pull request baseline

Scenario Effect Machine
Plan counter transitions 123,276 transitions/s
Drain burst with terminal fence 379,932 increments/s
Drain burst with a change observer 354,097 increments/s
Lookup and send to one child 311,575 increments/s
Start and stop a machine 146,349 machines/s
Start and stop a parent with one child 31,105 families/s
Plan transitions through a compound state 108,748 transitions/s
Plan transitions through parallel regions 86,674 transitions/s
Drain burst through a compound state 351,791 events/s
Drain burst through two parallel regions 324,232 events/s
Drain a compound-state burst with a change observer 329,250 events/s

Process runtime reference points

Scenario Effect Machine
Start and stop a raw generic process 14,813 processes/s
Start and stop a raw compiled process 59,984 processes/s
Memory profile Effect Machine
Idle machine 1.8 KiB
Raw generic managed process 13.9 KiB
Raw compiled process 3.1 KiB
Two independent idle machines 3.4 KiB
Idle parent with one child 5.5 KiB
Parent with observed child registry 9.7 KiB
Parent with observed invoked child snapshots 6.0 KiB

Effect Machine change from base

Metric Base Base variability PR PR variability Difference
Plan counter transitions 122,118 transitions/s 0.2% MAD 123,276 transitions/s 0.7% MAD +0.9%
Drain burst with terminal fence 380,268 increments/s 2.1% MAD 379,932 increments/s 0.5% MAD -0.1%
Drain burst with a change observer 354,489 increments/s 1.2% MAD 354,097 increments/s 0.8% MAD -0.1%
Lookup and send to one child 313,011 increments/s 2.1% MAD 311,575 increments/s 0.6% MAD -0.5%
Start and stop a machine 153,327 machines/s 0.3% MAD 146,349 machines/s 1.5% MAD -4.6%
Start and stop a parent with one child 33,117 families/s 4.3% MAD 31,105 families/s 3.4% MAD -6.1%
Plan transitions through a compound state 109,835 transitions/s 2.2% MAD 108,748 transitions/s 0.8% MAD -1.0%
Plan transitions through parallel regions 86,428 transitions/s 1.5% MAD 86,674 transitions/s 0.8% MAD +0.3%
Drain burst through a compound state 371,599 events/s 1.5% MAD 351,791 events/s 0.9% MAD -5.3%
Drain burst through two parallel regions 349,294 events/s 0.6% MAD 324,232 events/s 0.9% MAD -7.2%
Drain a compound-state burst with a change observer 349,333 events/s 0.6% MAD 329,250 events/s 1.2% MAD -5.7%
Idle machine heap per unit 1.7 KiB 0.0% MAD 1.8 KiB 0.1% MAD +4.0%
Raw generic managed process heap per unit 13.7 KiB 0.0% MAD 13.9 KiB 0.0% MAD +1.1%
Raw compiled process heap per unit 2.9 KiB 0.1% MAD 3.1 KiB 0.2% MAD +6.0%
Two independent idle machines heap per unit 3.3 KiB 0.0% MAD 3.4 KiB 0.0% MAD +4.1%
Idle parent with one child heap per unit 5.2 KiB 0.0% MAD 5.5 KiB 0.0% MAD +5.2%
Parent with observed child registry heap per unit 9.4 KiB 0.0% MAD 9.7 KiB 0.0% MAD +2.9%
Parent with observed invoked child snapshots heap per unit 5.6 KiB 0.1% MAD 6.0 KiB 0.0% MAD +7.0%

Process runtime reference change from base

Metric Base Base variability PR PR variability Difference
Start and stop a raw generic process 15,581 processes/s 0.8% MAD 14,813 processes/s 0.4% MAD -4.9%
Start and stop a raw compiled process 62,775 processes/s 0.5% MAD 59,984 processes/s 1.0% MAD -4.4%

Regression guard

No large, noise-adjusted throughput or heap regressions detected.

Versions and interpretation
  • Effect Machine: 0.12.0

Higher throughput is better; lower heap is better. Variability is the median absolute deviation across independent processes, relative to their median. Small differences on shared GitHub-hosted hardware remain informational; the required guard rejects only large changes beyond the measured noise allowance.

@SandroMaglione
SandroMaglione force-pushed the codex/live-machine-inspection branch from 6a8c26b to 2bb532a Compare August 16, 2026 11:25
@SandroMaglione
SandroMaglione merged commit c8728e5 into main Aug 16, 2026
13 checks passed
@SandroMaglione
SandroMaglione deleted the codex/live-machine-inspection branch August 16, 2026 11:30
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