Skip to content

Complete and document examples - #92

Merged
SandroMaglione merged 1 commit into
mainfrom
codex/complete-examples
Aug 11, 2026
Merged

Complete and document examples#92
SandroMaglione merged 1 commit into
mainfrom
codex/complete-examples

Conversation

@SandroMaglione

Copy link
Copy Markdown
Member

Summary

  • finish the turnstile, traffic-light, microwave, and worker/tab playground examples
  • align all shipped examples with state-builder .from(...) construction
  • add focused behavioral coverage and rewrite the README as a concise usage guide
  • add a patch changeset for the documentation and example improvements

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
  • Reviewed the automated type-performance report, when the public TypeScript API or inference changed — not applicable; no public API or inference change
  • Reviewed the automated runtime-performance report, when runtime behavior changed — not applicable; no library runtime change

Additional verification:

  • playground: 8 tests plus typecheck and production build
  • platformer: 4 tests plus typecheck and production build
  • Pokémon: typecheck and production build
  • browser smoke test: transitions, timers, microwave safety, worker execution, two-tab synchronization, and the 390px breakpoint

@github-actions

github-actions Bot commented Aug 11, 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) 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.04s 0.04s
Import effect-machine 0.04s 0.03s
Machine.defineStates (3 states) 0.10s 0.11s
Machine.make (3 states, 2 events) 0.16s 0.16s
machine.handle (3 states, 2 transitions) 0.23s 0.26s
machine.handle (depth 8) 0.54s 0.55s
machine.handle (depth 12) 0.57s 0.58s
machine.handle (depth 16) 0.63s 0.61s
machine.handle (depth 24) 0.74s 0.71s
machine.handle (wide depth 16) 0.76s 0.78s
machine.handle (parallel/history/choice) 0.64s 0.65s
machine.handle (4 successive calls) 0.62s 0.60s
machine exact input/output/error/services 0.51s 0.52s
execution adapter readiness 0.59s 0.60s

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

@github-actions

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 132,824 transitions/s 131,688 transitions/s 13,079 transitions/s
Drain burst with terminal fence 487,310 increments/s 392,322 increments/s 193,138 increments/s
Drain burst with a change observer 456,150 increments/s 387,273 increments/s 193,047 increments/s
Lookup and send to one child 399,604 increments/s 384,978 increments/s 183,520 increments/s
Start and stop a machine 172,087 machines/s 182,815 machines/s 140,588 machines/s
Start and stop a parent with one child 35,319 families/s 68,367 families/s 40,182 families/s
Plan transitions through a compound state 120,412 transitions/s
Plan transitions through parallel regions 90,711 transitions/s
Drain burst through a compound state 491,902 events/s 343,151 events/s 191,716 events/s
Drain burst through two parallel regions 450,135 events/s 260,032 events/s 143,464 events/s
Drain a compound-state burst with a change observer 449,729 events/s

Effect runtime reference points

Scenario Effect Machine Effect runtime primitives
Start and stop a raw generic process 17,045 processes/s
Start and stop a raw compiled process 67,852 processes/s
Start and interrupt a suspended fiber 164,447 fibers/s
Start and stop a queue worker 115,128 workers/s
Start and stop an actor shell 106,406 actors/s
Start and stop two actor shells 65,621 families/s
Update an owner-only mutable snapshot 316,856,781 updates/s
Update a synchronized snapshot 1,522,956 updates/s
Create, resolve, and await a terminal latch 1,385,713 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.7 KiB
Raw compiled process 2.8 KiB
Two independent idle machines 3.0 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.8 KiB

Effect Machine change from base

Metric Base Base variability PR PR variability Difference
Plan counter transitions 131,919 transitions/s 1.7% MAD 132,824 transitions/s 1.8% MAD +0.7%
Drain burst with terminal fence 512,061 increments/s 0.5% MAD 487,310 increments/s 1.4% MAD -4.8%
Drain burst with a change observer 469,902 increments/s 1.0% MAD 456,150 increments/s 1.7% MAD -2.9%
Lookup and send to one child 400,437 increments/s 1.4% MAD 399,604 increments/s 2.6% MAD -0.2%
Start and stop a machine 168,039 machines/s 0.8% MAD 172,087 machines/s 3.2% MAD +2.4%
Start and stop a parent with one child 32,822 families/s 2.5% MAD 35,319 families/s 7.6% MAD +7.6%
Plan transitions through a compound state 119,411 transitions/s 1.1% MAD 120,412 transitions/s 0.6% MAD +0.8%
Plan transitions through parallel regions 90,600 transitions/s 1.4% MAD 90,711 transitions/s 0.1% MAD +0.1%
Drain burst through a compound state 495,921 events/s 1.0% MAD 491,902 events/s 1.4% MAD -0.8%
Drain burst through two parallel regions 458,354 events/s 0.7% MAD 450,135 events/s 1.1% MAD -1.8%
Drain a compound-state burst with a change observer 454,670 events/s 0.7% MAD 449,729 events/s 2.0% MAD -1.1%
Idle machine heap per unit 1.5 KiB 0.1% MAD 1.5 KiB 0.1% MAD -0.1%
Raw generic managed process heap per unit 12.7 KiB 0.0% MAD 12.7 KiB 0.0% MAD -0.0%
Raw compiled process heap per unit 2.8 KiB 0.0% MAD 2.8 KiB 0.1% MAD +0.4%
Two independent idle machines heap per unit 3.0 KiB 0.0% MAD 3.0 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.0% MAD 0.0%

Effect runtime reference change from base

Metric Base Base variability PR PR variability Difference
Start and stop a raw generic process 16,616 processes/s 0.8% MAD 17,045 processes/s 1.3% MAD +2.6%
Start and stop a raw compiled process 67,714 processes/s 1.0% MAD 67,852 processes/s 0.7% MAD +0.2%
Start and interrupt a suspended fiber 164,989 fibers/s 0.2% MAD 164,447 fibers/s 0.3% MAD -0.3%
Start and stop a queue worker 117,014 workers/s 0.2% MAD 115,128 workers/s 0.8% MAD -1.6%
Start and stop an actor shell 107,216 actors/s 0.6% MAD 106,406 actors/s 0.3% MAD -0.8%
Start and stop two actor shells 65,407 families/s 2.4% MAD 65,621 families/s 0.8% MAD +0.3%
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,549,672 updates/s 1.0% MAD 1,522,956 updates/s 1.1% MAD -1.7%
Create, resolve, and await a terminal latch 1,393,043 latches/s 3.3% MAD 1,385,713 latches/s 1.6% MAD -0.5%
Versions and interpretation
  • Effect Machine: 0.5.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 a23463c into main Aug 11, 2026
17 of 18 checks passed
@SandroMaglione
SandroMaglione deleted the codex/complete-examples branch August 11, 2026 14:49
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