Codex made process spawning 800x faster by ditching fork+exec for posix_spawn
charliermarsh · x · 2026-11-25
Charlie Marsh (Ruff/Codex) details how Codex optimized process creation, which runs millions of times per week for shells, hooks, and MCP servers. Even with copy-on-write, fork still copies page tables scaling with parent memory. Switching to posixspawn cut per-launch time from 200ms to 0.25ms on macOS with 20 GB resident memory — 800x faster. Key gotchas: Rust's stdlib falls back to fork when preexec callbacks are used, and macOS historically forces fork for relative executables with currentdir; the team wrote a custom Command abstraction calling posixspawn directly, uses POSIXSPAWNSETSID instead of a setsid callback, and on Linux spawns itself first to do unsupported setup before exec'ing the target.
Related event: Codex speeds up process spawning 800x by replacing fork with posix_spawn(14 posts)→
More from coding & agent
- vibe-codevember Day 19: WebGPU interactive sandstone erosion demo built with Gemini — AI_Andrew · 2026-11-25
- Actual cost: one full hour of agent work on a Claude Ultra plan equals about $1 — LeviTurk · 2026-11-25
- LangChain and Arcade to host Dec 9 workshop on building governed banking agents — LangChain · 2026-11-25
- Three.js Procedural Terrain Generator ProceduralTerrains Hits 700 GitHub Stars — Promptmethus · 2026-11-25
- AssetFurnace: open-source image-to-3D pipeline for rigged game characters, 1.3k stars — Promptmethus · 2026-11-25
- Tested orchestrator + Opus 5.5 combos: best quality, but solo runs cost far less — sandersted · 2026-11-25