Skip to content

Strengthen machine strategy guardrails - #76

Merged
SandroMaglione merged 1 commit into
mainfrom
codex/machine-refactor-guardrails
Aug 10, 2026
Merged

Strengthen machine strategy guardrails#76
SandroMaglione merged 1 commit into
mainfrom
codex/machine-refactor-guardrails

Conversation

@SandroMaglione

Copy link
Copy Markdown
Member

Summary

  • add test-only planner and process strategy selection so generic/indexed and generic/compiled implementations can be compared directly
  • add focused and generated differential coverage for startup, targetless/reentry transitions, parallel transitions, invocation, terminal behavior, and retained snapshots
  • extend runtime benchmarks with hierarchical/parallel planning, observed hierarchical execution, and generic process lifecycle reference points

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 (not applicable)
  • Reviewed the automated type-performance report, when the public TypeScript API or inference changed (no public API change; local pnpm perf:types passes)
  • Reviewed the automated runtime-performance report, when runtime behavior changed (local five-process base-versus-head comparison reviewed; hosted report pending)

@github-actions

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) 2,965 2,965 0 (0.0%)
Machine.make (3 states, 2 events) 8,715 8,715 0 (0.0%)
machine.handle (3 states, 2 transitions) 23,492 23,492 0 (0.0%)
machine.handle (depth 8) 117,075 117,075 0 (0.0%)
machine.handle (depth 12) 129,713 129,713 0 (0.0%)
machine.handle (depth 16) 145,055 145,055 0 (0.0%)
machine.handle (depth 24) 183,851 183,851 0 (0.0%)
machine.handle (wide depth 16) 214,189 214,189 0 (0.0%)
machine.handle (parallel/history/choice) 132,667 132,667 0 (0.0%)
machine.handle (4 successive calls) 128,674 128,674 0 (0.0%)
machine exact input/output/error/services 110,584 110,584 0 (0.0%)
execution adapter readiness 127,854 127,854 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,910 2,910 0 (0.0%)
Machine.make (3 states, 2 events) 5,742 5,742 0 (0.0%)
machine.handle (3 states, 2 transitions) 14,777 14,777 0 (0.0%)
machine.handle (depth 8) 109,601 109,601 0 (0.0%)
machine.handle (depth 12) 121,039 121,039 0 (0.0%)
machine.handle (depth 16) 135,181 135,181 0 (0.0%)
machine.handle (depth 24) 171,577 171,577 0 (0.0%)
machine.handle (wide depth 16) 202,224 202,224 0 (0.0%)
machine.handle (parallel/history/choice) 114,331 114,331 0 (0.0%)
machine.handle (4 successive calls) 113,703 113,703 0 (0.0%)
machine exact input/output/error/services 100,670 100,670 0 (0.0%)
execution adapter readiness 102,092 102,092 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.12s 0.11s
Machine.make (3 states, 2 events) 0.17s 0.17s
machine.handle (3 states, 2 transitions) 0.24s 0.24s
machine.handle (depth 8) 0.55s 0.54s
machine.handle (depth 12) 0.60s 0.58s
machine.handle (depth 16) 0.65s 0.66s
machine.handle (depth 24) 0.71s 0.74s
machine.handle (wide depth 16) 0.83s 0.79s
machine.handle (parallel/history/choice) 0.66s 0.65s
machine.handle (4 successive calls) 0.62s 0.63s
machine exact input/output/error/services 0.54s 0.54s
execution adapter readiness 0.62s 0.61s

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

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Runtime performance

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

Pull request baseline

Scenario Effect Machine XState 5 XState 6 alpha
Plan counter transitions 123,092 transitions/s 132,420 transitions/s 13,100 transitions/s
Drain burst with terminal fence 497,342 increments/s 390,815 increments/s 191,987 increments/s
Drain burst with a change observer 462,729 increments/s 387,561 increments/s 190,492 increments/s
Lookup and send to one child 399,218 increments/s 385,972 increments/s 182,620 increments/s
Start and stop a machine 174,520 machines/s 185,185 machines/s 141,985 machines/s
Start and stop a parent with one child 39,766 families/s 69,219 families/s 39,798 families/s
Plan transitions through a compound state 117,598 transitions/s
Plan transitions through parallel regions 90,705 transitions/s
Drain burst through a compound state 529,554 events/s 343,348 events/s 188,523 events/s
Drain burst through two parallel regions 483,194 events/s 261,574 events/s 141,233 events/s
Drain a compound-state burst with a change observer 482,000 events/s

Effect runtime reference points

Scenario Effect Machine Effect runtime primitives
Start and stop a raw generic process 18,758 processes/s
Start and stop a raw compiled process 69,512 processes/s
Start and interrupt a suspended fiber 166,639 fibers/s
Start and stop a queue worker 116,877 workers/s
Start and stop an actor shell 106,758 actors/s
Start and stop two actor shells 64,520 families/s
Update an owner-only mutable snapshot 316,856,781 updates/s
Update a synchronized snapshot 1,533,173 updates/s
Create, resolve, and await a terminal latch 1,421,630 latches/s
Memory profile Effect Machine XState 5 XState 6 alpha Effect runtime primitives
Idle machine 1.5 KiB 3.8 KiB 2.2 KiB
Raw generic managed process 12.1 KiB
Raw compiled process 2.6 KiB
Two independent idle machines 2.9 KiB 7.3 KiB 3.9 KiB
Idle parent with one child 4.8 KiB 5.5 KiB 4.0 KiB
Parent with observed child registry 9.0 KiB
Parent with observed invoked child snapshots 5.0 KiB
Suspended Effect fiber 0.6 KiB
Effect queue with waiting fiber 2.8 KiB
Effect mailbox actor shell 3.2 KiB
Two Effect actor shells 6.9 KiB

Effect Machine change from base

Metric Base Base variability PR PR variability Difference
Plan counter transitions 122,729 transitions/s 0.3% MAD 123,092 transitions/s 0.1% MAD +0.3%
Drain burst with terminal fence 491,513 increments/s 1.8% MAD 497,342 increments/s 1.1% MAD +1.2%
Drain burst with a change observer 453,933 increments/s 0.6% MAD 462,729 increments/s 0.1% MAD +1.9%
Lookup and send to one child 388,179 increments/s 0.8% MAD 399,218 increments/s 2.5% MAD +2.8%
Start and stop a machine 174,795 machines/s 1.8% MAD 174,520 machines/s 0.7% MAD -0.2%
Start and stop a parent with one child 40,344 families/s 1.4% MAD 39,766 families/s 0.7% MAD -1.4%
Plan transitions through a compound state 118,935 transitions/s 1.9% MAD 117,598 transitions/s 0.4% MAD -1.1%
Plan transitions through parallel regions 90,491 transitions/s 0.3% MAD 90,705 transitions/s 0.2% MAD +0.2%
Drain burst through a compound state 529,061 events/s 1.2% MAD 529,554 events/s 0.2% MAD +0.1%
Drain burst through two parallel regions 483,204 events/s 0.4% MAD 483,194 events/s 1.2% MAD -0.0%
Drain a compound-state burst with a change observer 479,766 events/s 0.3% MAD 482,000 events/s 1.7% MAD +0.5%
Idle machine heap per unit 1.5 KiB 0.1% MAD 1.5 KiB 0.2% MAD -0.0%
Raw generic managed process heap per unit 12.1 KiB 0.0% MAD 12.1 KiB 0.0% MAD 0.0%
Raw compiled process heap per unit 2.6 KiB 0.0% MAD 2.6 KiB 0.0% MAD -0.0%
Two independent idle machines heap per unit 2.9 KiB 0.0% MAD 2.9 KiB 0.0% MAD +0.0%
Idle parent with one child heap per unit 4.8 KiB 0.0% MAD 4.8 KiB 0.0% MAD -0.0%
Parent with observed child registry heap per unit 9.0 KiB 0.0% MAD 9.0 KiB 0.0% MAD +0.0%
Parent with observed invoked child snapshots heap per unit 5.0 KiB 0.0% MAD 5.0 KiB 0.2% MAD -0.0%

Effect runtime reference change from base

Metric Base Base variability PR PR variability Difference
Start and stop a raw generic process 18,958 processes/s 1.2% MAD 18,758 processes/s 3.2% MAD -1.1%
Start and stop a raw compiled process 68,273 processes/s 0.9% MAD 69,512 processes/s 0.7% MAD +1.8%
Start and interrupt a suspended fiber 166,917 fibers/s 1.2% MAD 166,639 fibers/s 0.8% MAD -0.2%
Start and stop a queue worker 117,275 workers/s 0.6% MAD 116,877 workers/s 1.5% MAD -0.3%
Start and stop an actor shell 106,304 actors/s 1.1% MAD 106,758 actors/s 1.1% MAD +0.4%
Start and stop two actor shells 66,322 families/s 0.9% MAD 64,520 families/s 2.5% MAD -2.7%
Update an owner-only mutable snapshot 316,856,781 updates/s 0.0% MAD 316,856,781 updates/s 0.0% MAD 0.0%
Update a synchronized snapshot 1,536,856 updates/s 0.6% MAD 1,533,173 updates/s 1.1% MAD -0.2%
Create, resolve, and await a terminal latch 1,388,465 latches/s 4.0% MAD 1,421,630 latches/s 1.5% MAD +2.4%
Versions and interpretation
  • Effect Machine: 0.3.0
  • XState 5: 5.32.5
  • XState 6 alpha: 6.0.0-alpha.31
  • Effect runtime primitives: 4.0.0-beta.107

Higher throughput is better; lower heap is better. Variability is the median absolute deviation across independent processes, relative to their median. Runtime measurements on shared GitHub-hosted hardware remain informational, so small differences should be confirmed across multiple workflow runs.

@SandroMaglione
SandroMaglione merged commit 1951844 into main Aug 10, 2026
10 checks passed
@SandroMaglione
SandroMaglione deleted the codex/machine-refactor-guardrails branch August 10, 2026 09:33
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