Skip to content

Specialize compiled invoked child startup - #72

Merged
SandroMaglione merged 2 commits into
mainfrom
codex/static-compiled-invokes
Aug 10, 2026
Merged

Specialize compiled invoked child startup#72
SandroMaglione merged 2 commits into
mainfrom
codex/static-compiled-invokes

Conversation

@SandroMaglione

@SandroMaglione SandroMaglione commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

  • start eligible compiled invoked machines directly from their synchronous initial kernel while preserving the existing Effect-based transition, service, scope, observation, and completion semantics
  • compile each Machine.invokeMachine process descriptor once while keeping initialization and runtime state isolated per parent instance
  • cover input-bearing descriptor reuse and initially-final child completion

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 examples changed)
  • Reviewed the automated type-performance report, when the public TypeScript API or inference changed (local budgets pass; no public API change)
  • Reviewed the automated runtime-performance report, when runtime behavior changed

The final five-process CI comparison improves parent-plus-child lifecycle from 39,373 to 45,304 families/s (+15.1%) with standalone lifecycle +0.3%. Parent-plus-child heap changes by +0.5% (about 25 bytes); local focused runs measured +13.9% aggregate / +14.7% paired-median lifecycle with all nine pairs positive.

@github-actions

github-actions Bot commented Aug 10, 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.03s 0.03s
Import effect-machine 0.03s 0.03s
Machine.defineStates (3 states) 0.12s 0.10s
Machine.make (3 states, 2 events) 0.16s 0.16s
machine.handle (3 states, 2 transitions) 0.24s 0.24s
machine.handle (depth 8) 0.51s 0.52s
machine.handle (depth 12) 0.55s 0.56s
machine.handle (depth 16) 0.61s 0.61s
machine.handle (depth 24) 0.69s 0.70s
machine.handle (wide depth 16) 0.78s 0.78s
machine.handle (parallel/history/choice) 0.60s 0.63s
machine.handle (4 successive calls) 0.58s 0.60s
machine exact input/output/error/services 0.51s 0.50s
execution adapter readiness 0.58s 0.60s

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 9V74 80-Core Processor with Node v24.18.0.

Pull request baseline

Scenario Effect Machine XState 5 XState 6 alpha
Plan counter transitions 164,199 transitions/s 171,941 transitions/s 142,211 transitions/s
Drain burst with terminal fence 633,097 increments/s 485,631 increments/s 132,816 increments/s
Drain burst with a change observer 603,422 increments/s 481,184 increments/s 132,275 increments/s
Lookup and send to one child 531,737 increments/s 479,745 increments/s 128,853 increments/s
Start and stop a machine 145,985 machines/s 226,912 machines/s 91,861 machines/s
Start and stop a parent with one child 45,304 families/s 90,359 families/s 38,374 families/s
Drain burst through a compound state 629,282 events/s 424,553 events/s 131,785 events/s
Drain burst through two parallel regions 589,876 events/s 325,361 events/s 113,858 events/s

Effect runtime reference points

Scenario Effect Machine Effect runtime primitives
Start and stop a raw compiled process 91,017 processes/s
Start and interrupt a suspended fiber 201,288 fibers/s
Start and stop a queue worker 147,275 workers/s
Start and stop an actor shell 135,667 actors/s
Start and stop two actor shells 85,558 families/s
Update an owner-only mutable snapshot 401,123,145 updates/s
Update a synchronized snapshot 2,128,991 updates/s
Create, resolve, and await a terminal latch 2,104,975 latches/s
Memory profile Effect Machine XState 5 XState 6 alpha Effect runtime primitives
Idle machine 1.6 KiB 3.8 KiB 6.1 KiB
Raw generic managed process 12.1 KiB
Raw compiled process 2.6 KiB
Two independent idle machines 3.0 KiB 7.3 KiB 11.8 KiB
Idle parent with one child 4.9 KiB 5.5 KiB 8.8 KiB
Parent with observed child registry 9.1 KiB
Parent with observed invoked child snapshots 5.0 KiB
Suspended Effect fiber 0.7 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 164,415 transitions/s 0.6% MAD 164,199 transitions/s 0.1% MAD -0.1%
Drain burst with terminal fence 672,676 increments/s 0.6% MAD 633,097 increments/s 3.8% MAD -5.9%
Drain burst with a change observer 615,003 increments/s 0.3% MAD 603,422 increments/s 1.8% MAD -1.9%
Lookup and send to one child 543,487 increments/s 0.2% MAD 531,737 increments/s 2.3% MAD -2.2%
Start and stop a machine 145,560 machines/s 1.3% MAD 145,985 machines/s 0.3% MAD +0.3%
Start and stop a parent with one child 39,373 families/s 0.5% MAD 45,304 families/s 1.3% MAD +15.1%
Drain burst through a compound state 639,177 events/s 2.0% MAD 629,282 events/s 3.0% MAD -1.5%
Drain burst through two parallel regions 584,503 events/s 0.8% MAD 589,876 events/s 1.4% MAD +0.9%
Idle machine heap per unit 1.6 KiB 0.2% MAD 1.6 KiB 0.0% MAD -0.1%
Raw generic managed process heap per unit 12.1 KiB 0.0% MAD 12.1 KiB 0.0% MAD +0.1%
Raw compiled process heap per unit 2.6 KiB 0.0% MAD 2.6 KiB 0.2% MAD +1.1%
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.9 KiB 0.0% MAD 4.9 KiB 0.0% MAD +0.5%
Parent with observed child registry heap per unit 9.1 KiB 0.0% MAD 9.1 KiB 0.0% MAD +0.3%
Parent with observed invoked child snapshots heap per unit 5.0 KiB 0.0% MAD 5.0 KiB 0.0% MAD +1.4%

Effect runtime reference change from base

Metric Base Base variability PR PR variability Difference
Start and stop a raw compiled process 89,550 processes/s 0.4% MAD 91,017 processes/s 0.9% MAD +1.6%
Start and interrupt a suspended fiber 203,376 fibers/s 0.2% MAD 201,288 fibers/s 0.6% MAD -1.0%
Start and stop a queue worker 148,368 workers/s 0.7% MAD 147,275 workers/s 0.6% MAD -0.7%
Start and stop an actor shell 135,117 actors/s 2.1% MAD 135,667 actors/s 1.8% MAD +0.4%
Start and stop two actor shells 85,273 families/s 0.9% MAD 85,558 families/s 1.1% MAD +0.3%
Update an owner-only mutable snapshot 400,962,309 updates/s 0.0% MAD 401,123,145 updates/s 0.0% MAD +0.0%
Update a synchronized snapshot 2,106,571 updates/s 0.3% MAD 2,128,991 updates/s 1.7% MAD +1.1%
Create, resolve, and await a terminal latch 2,137,602 latches/s 1.3% MAD 2,104,975 latches/s 0.3% MAD -1.5%
Versions and interpretation
  • Effect Machine: 0.3.0
  • XState 5: 5.32.5
  • XState 6 alpha: 6.0.0-alpha.27
  • Effect runtime primitives: 4.0.0-beta.105

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 f229e7a into main Aug 10, 2026
9 checks passed
@SandroMaglione
SandroMaglione deleted the codex/static-compiled-invokes branch August 10, 2026 04:16
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