Repository navigation
v3.6.0
forkrun v3.6.0
Overview
forkrun is a data parallelization engine: it splits a byte stream into batches and dispatches them to workers — Python functions, external binaries, or native C plugins — with zero-copy shared-memory delivery, per-node NUMA affinity, and automatic crash recovery.
v3.6.0 is the largest release in the project's history. The headline is the Python frontend (the python/ package, installable via pip), which brings forkrun's engine to AI/ML data-preparation pipelines. Alongside it: recovery-by-default, a consolidated executor architecture with a generated ABI gate, a hardened bash frontend (security gate, parsing, compatibility floor to bash 4.4), a C engine hardening pass, and a release infrastructure that machine-checks the project's own documentation claims.
Breaking/behavioral changes are listed in §7.
1. The Python Frontend (new)
The complete port, built on the same C substrate the bash frontend drives:
import forkrun
def process(batch):
return transform(batch.data) # memoryview into shared memory — zero copy
results = forkrun.map(process, "input.jsonl", workers=28)
for r in forkrun.stream(process, "input.jsonl"): # yields while workers run
...- Four modes: Python UDF (default),
spawn(external commands,posix_spawnpdispatch),plugin(C callbacks through the frozen 128-byte ABI — the same plugins bash uses), andsplice(kernel passthrough). - API surface:
run/map/stream/sweep(parameter sweeps), with ordered/unordered output, streaming ingest (bounded memory on unbounded input), resume/checkpoint on C-orderer paths, and typed exceptions carrying signal provenance. - No pickling, no queues: data crosses via shared memory; results via per-worker memfds.
- 644 tests, plus the verification machinery in §5.
- Version:
forkrun.__version__= 0.16.0; the engine reports v3.6.0.
The port was executed as 41 staged work orders (W-PY1–41) against a frozen engine, then survived two blind adversarial code reviews plus a differential audit against the bash frontend's entire fix history (W-PORTAUDIT: 32 items, all dispositioned). Every finding and its fix is in the changelog.
2. Automatic Crash Recovery — Now the Default
When a worker dies mid-batch (SIGSEGV, OOM-kill — which the kernel delivers as SIGKILL — or an unhandled exception):
- Partial output is rolled back (
ftruncateto the batch boundary) - The batch is re-queued via escrow
- A fresh worker re-executes it (~1ms disruption)
- Output is byte-identical to an uninterrupted run; other workers never pause
Recovery is on by default (orchestrator=True); orchestrator=False restores fail-fast. Supervision itself costs nothing measurable — the throughput delta vs. unsupervised mode is the C-orderer transit for ordered output (~14% on C-plugin light workloads, shrinking to ~9% heavy, ~5% Python; order="none" with recovery on is within noise of max throughput).
Semantics, stated plainly: payload side effects are at-least-once (make them idempotent); a deterministically-crashing batch is retried up to retry_limit (default 3, configurable via FORKRUN_RETRY_LIMIT), then skipped and reported. Tested against SIGSEGV/SIGKILL injection, including burst storms (28 simultaneous kills: ~20% cost, run completes). No autonomous equivalent was found in Executor (BrokenProcessPool), Pool (hangs), or Ray (task retry, higher overhead). A cgroup-OOM scenario test is queued for 3.6.1 (SIGKILL-class recovery is tested; the OOM-specific scenario is true-by-mechanism).
3. Engine & Frontend Fixes
Highlights of ~120 closed findings this cycle (full list in DOCS/CHANGELOG.md):
- F-NUMA1 (critical): multi-node runs could silently return ~25% of records — ingest lapped the metadata ring around stalled nodes and thieves read recycled slots. Fixed via a meta-lifetime bound + per-chunk snapshots + a parent-side drain audit that makes any under-drain loud (a RuntimeError naming node and indices, not silent loss).
- Security gate bypass (critical, bash): the 3-layer resume-consent gate only ran in one invocation form; any additional argument skipped it entirely. The gate now runs unconditionally; 101 new security tests where zero existed.
- Octal parsing silent data loss (critical, bash):
-j 00silently dropped all input with exit 0 (bash octal arithmetic). Numeric parsing is now fail-closed. - F-PY-UMA1 / the "mover": sporadic UMA head-of-output loss traced to fd-number recycling aliasing the claim path's eventfd reads onto the ingress memfd. Fixed at the scanner; closed as INVARIANTS §20 (ingress position is undefined; explicit offsets only).
- Legacy-path scanner park (P0): a bounded-wait false positive killed the scanner's by-design backpressure park on slow-payload runs; teardown reordered to the reactor pattern.
- Bash compatibility: the 0.9MB single-line
declaredeath (bootstrap failure on bash ≤5.2) replaced with chunked transport;-e/errexit landmines closed; floor is now bash ≥4.4 (README corrected;mapfile -dalready required it). - Engine hardening (15 items): bounded polls (replacing
poll(-1)sites),fallocatereturn checks (silent reclamation failure on overlayfs → now warns and stops), overflow guards, alignment fixes, escrow anti-recycle guard, NULL-guard consistency. - Port-parity guarantees: workers ≥ NUMA nodes (was silent stranding), drain verification before completion, CUDA-context refusal at every fork path, resume+NO_V1 loud refusal.
4. Benchmarks
5M-record JSONL, i9-7940X (28 threads), same input for every system, median-of-3 post-warmup, exact totals verified. "default" = ordered + recovery (out of the box); "max" = unordered, recovery off.
| System | Light (533MB) | Medium (2.35GB) | Heavy (6.72GB) |
|---|---|---|---|
| forkrun C plugin (max) | 6.70M rec/s | 2.34M rec/s | 698k rec/s |
| forkrun C plugin (default) | 5.38M rec/s | 1.91M rec/s | 634k rec/s |
| Executor + C (ctypes)† | 3.67M rec/s | 2.03M rec/s | 735k rec/s |
| Polars native | — | 2.20M rec/s | — |
| ProcessPoolExecutor | 1.64M rec/s | 797k rec/s | 94k rec/s |
| multiprocessing.Pool | 1.60M rec/s | 757k rec/s | 94k rec/s |
| forkrun Python (default) | 1.56M rec/s | 672k rec/s | 90k rec/s |
| Ray Data | 250k rec/s | 184k rec/s | 56k rec/s |
| HF Datasets | 120k rec/s | 90k rec/s | 44k rec/s |
† A purpose-built control (~80 lines: pre-scan for line boundaries, pre-computed ranges, shared-file pread, same C plugin via ctypes, no recovery/ordering/streaming) — the ceiling of hand-tuned static orchestration. Setup-inclusive rates quoted; timed-only (scan excluded, relevant for range reuse) reaches 7.54M/3.20M/1.04M. The control isolates the payload dividend: removing Python from the per-batch loop is worth ~2.2–7.8×. Against the setup-inclusive control, forkrun-C(max) leads on light/medium and is ~even on heavy — while providing what the control lacks: dynamic batching, streaming sources, ordering, recovery, NUMA placement.
Tokenization (500k docs): 97.7M tokens/s, 2× Executor. Bash side: 87–191M lines/s for external binaries vs. GNU Parallel's ~58k — independently re-measured by a third party at 1445×. All scripts in python/benchmarks/ and BENCHMARKS/.
First-generation EPYC results (64-core, rented): competitive at peak worker counts (1.6–2.2× Executor) with identified scaling characteristics — optimum near physical-core count, an unresolved 2-node/4-node ring-allocation inversion — that warrant dedicated hardware access. Single-socket results demonstrate the architecture's ceiling; multi-socket optimization is the 3.6.1+ priority.
5. Verification & Release Infrastructure
- Test suites: 644 Python + 463 bash (96 basic + 101 security + 264 comprehensive; 92/89 by boot topology), all in binding CI for the first time.
- Machine-checked claims: an invariant gate (INVARIANTS §3/§6/§9 as behavioral probes), a doc-accuracy harness (every headline doc claim paired with its covering test), an executor consistency checker, and a generated shim ABI gate (triple agreement: declared == bindings == exports).
- Reproducible builds: 7 architectures (x86-64 v2/v3/v4, aarch64, ppc64le, s390x, riscv64); CI-verified embedded blobs byte-match source (freshness gates); an independent reviewer reproduced the shipped binary from source to within 31 bytes (build-id + provenance string only).
release_check.py: 21 checks including tag-readiness, changelog finality, IDL freshness, and single-build checksums. The changelog-finality check is designed-red until this release's heading is finalized — by design.- Process note: during final assembly, the verification gates caught three specification errors in the fix orders themselves (halt-and-report dispositions, all documented) — the review machinery reviewed its own reviewers.
6. New Parameters & API Notes
orchestrator=True(default) — recovery supervision;False= fail-faststrict_poison— raise on poison-skip instead of warnsignal_policy="checkpoint"— opt-in graceful-abort-and-checkpoint on operator signals (HUP/TERM); installs nothing by default, restores prior handlers on exitsink=is rejected onmap/stream(at-least-once side-effect semantics make honoring it a footgun); worker-side sinks remain available viarun()- Exception taxonomy:
ForkrunInterrupted(dual-inheritsRuntimeError+KeyboardInterrupt— existing handlers of either keep working),ForkrunWorkerFailurewithsigno, and siblings; Bash exit-code mapping documented inpython/docs/TROUBLESHOOTING.md - Default worker count on large SMT systems follows real cores (>16 real cores); override with
workers=N
7. Behavioral Changes (migration notes)
- Recovery is default-on — pass
orchestrator=Falsefor the previous fail-fast behavior. - NUMA runs now emit poison-skip summaries (previously silent on multi-node).
sink=onmap/streamnow raises (was a silent no-op).- Bash numeric args with leading zeros are rejected (was silent octal data loss).
- Bash floor is 4.4 (README previously claimed 4.0;
mapfile -dalways required 4.4). - Resume security gate runs in all invocation forms (was bypassable with extra args).
8. Deferred to 3.6.1
Old-glibc/UBI8 build (glibc 2.28 floor), TSan evaluation + sanitizer legs→blocking, PRIu64 format fixes (D13), executor driver-merge completion, dead-code purge (trap-ACK timer machinery, legacy loadables), EPYC scaling characterization (the 2-node inversion), signature-level shim ABI typing, SBOM/signing/attestation, invariant-gate extensions.
9. Acknowledgments
This release was built with extensive AI assistance (opencode instances implementing ~150 work orders against a frozen engine, under owner-ratified specifications with pre-registered gates), and materially improved by two blind adversarial code reviews whose findings — and the fixes they prompted — are fully documented in the changelog. The reviewer that corrected its own CPU-utilization methodology mid-review deserves particular credit: that is the falsification culture working in both directions.
10. Python Package on PyPI
forkrun is now published to PyPI as 0.16.0 — the Python frontend's
own version line. The engine reports v3.6.0 separately via
forkrun.__engine_version__.
pip install forkrun
- Wheel —
forkrun-0.16.0-py3-none-manylinux_2_28_x86_64.whl. The
PEP 600 tag pins the real glibc floor at 2.28, so it installs
without a local build on RHEL 8, Debian 10+, and Ubuntu 20.04+.
Requires-Python: >=3.10, no runtime dependencies. - Sdist —
forkrun-0.16.0.tar.gz. Compiles the C substrate at
install time and needsgcc make bash-devel(Fedora/RHEL). Debian and
Ubuntu do not package bash headers, so on those the wheel is the
supported install path. - Release artifacts are produced by
tools/build_wheel.sh, which builds
inquay.io/pypa/manylinux_2_28_x86_64, builds the wheel from the
sdist (so the published tarball is proven self-sufficient), and gates
on the ELF's actual glibc floor before writing todist/.
Scope note. This lands the 2.28 floor for the Python wheel only. The
frun.bash ring blobs still require glibc >= 2.38 — they carry the
__isoc23_strto* symbol aliases that glibc >= 2.38 headers introduce
under _GNU_SOURCE, which the engine requires. The old-base blob build
remains deferred as listed in section 8.
SHA-256 for both artifacts is attached as checksums.txt.
Full Changelog: v3.5.2...v3.6.0