Skip to content

v3.5.2

Choose a tag to compare

@jkool702 jkool702 released this 20 Sep 04:30
· 872 commits to main since this release
4d49233

forkrun v3.5.2

Overview

forkrun is a Linux shell engine for data parallelization: it splits a byte stream into batches and dispatches them to workers — external binaries, shell functions, or native C plugins — with zero-copy data delivery, per-node NUMA affinity, and worker-level fault recovery. This release completes the C-plugin delivery contract (three modes: argv, stdin, raw window), makes the substrate's config boundary real (the engine now consumes typed config/state structs, not per-call environment reads), and provides the first empirical evidence for the upcoming Python frontend (the FFI boundary costs 1.7µs per call against a 10–100ms budget — the boundary is free).

This is a feature and port-infrastructure release: no bug fixes, no performance changes, no breaking changes.

Verification: proportionate to the engine delta. Comprehensive test suite + benchmark suite on x86_64 UMA and NUMA, both sanitizers on NUMA, QEMU aarch64 on both topologies, all new test files (T-RAW 1–7, T-STDIN 1–9, T-CONFIG 1–4, IDL 1–10, Python 14/14, canary). The full 6-topology matrix is deferred to the next engine-change release.

New features

  • C-plugin raw window delivery (FLAG_RAW) — plugins can now receive batch data as a borrowed, zero-copy pointer into shared memory instead of tokenized argv strings. The plugin declares forkrun_use_ctx = 2 | FORKUN_CTX_FLAG_RAW and receives ctx->reserved[0] pointing at [batch_offset, batch_offset + batch_byte_length). The window is stable during the callback (ingest is append-only, tokenization never writes the shared memfd, fallow punches only behind the acked prefix). This is the C-tier proof of the Python frontend's planned Batch.data contract.
  • C-plugin stdin delivery (-s/-b with -C) — plugins can now receive batch data as a byte stream on stdin (fd 0), terminated by EOF. With -s, the plugin reads to EOF; with -b, byte-mode chunks arrive binary-safe (closing the NUL-truncation gap that made -C + -b + argv broken). Small batches are fed synchronously; large batches use a forked feeder child. Precedence: a FLAG_RAW plugin always receive the raw window, never a stdin feed.

Port infrastructure

  • Substrate config boundary (Stage 1): the engine now consumes fr_config_t (immutable, fork-inherited) for worker configuration instead of reading bash environment variables per call. The struct is filled once at worker start (ring_worker inc) and consumed by ring_claim, ring_ack, and ring_call thereafter. WorkerBatchState fields are aligned with fr_state_t (the claim out-param is the future Python claim contract). This is the mechanism that lets the Python frontend drive the substrate without bash in the loop.
  • Typed IDL scaffolding (Stage 3.0): a 41-function call-schema declares every loadable's calling convention (currently all ARGC_ARGV, annotation-only). A generator (tools/gen_idl.py) produces C parse code scaffolding, ctypes definitions, and the usage/doc key table. A CI check (idl-check.yml) verifies freshness of the generated artifacts. No runtime changes; the schema exists as a build-time contract that Stage 3's thunk flips will consume. Generated: forkrun_callschema.h, tools/generated/fr_ctypes.py, tools/generated/usage_table.json.
  • FFI boundary measurement (Stage 2): the ctypes calling cost for the operations the Python frontend will perform at the claim/ack boundary, measured on the same i9-7940X as the Stage 0 table. Headline number: 1.7µs worst-case per claim-shaped call, 0.48µs for pointer-passing, 0.179µs null floor, 0.207µs for a 1MiB memoryview. Against the crossover data's ~10–100ms per-batch budget, the boundary is free. This measurement is the first Stage 0 evidence row for the Python frontend.

Security

  • No new security code changes. A previously undocumented residual is now named in SECURITY.md: the sandbox extraction executes before the ownership/permission gate (F29-B's ordering; prompts preview extracted values, which requires extraction first). An attacker with same-UID file-write can terminate the calling shell before the consent prompt fires. This is within the documented same-UID tampering boundary; the sandbox contains code effects, not process-signal effects. See SECURITY.md residual #5 for the full statement.
  • Resume consent gate: unchanged from v3.5.1. See v3.5.5.1 release notes for the F29/D10 hardening details.

Stage 0 measurement evidence (new in this release)

The Stage 0 evidence harness (benchmarks/python/) provides the first measured comparison of the forkrun substrate against real Python incumbents. On a single-socket i9-7940X:

Metric forkrun (C plugin) Pool Ratio
JSONL ingestion (1M records) 0.214s / 2.8MB 1.936s / 258MB 9.0× / 92× RSS
Raw-window int32 sum (100M tokens) 0.265s — substrate ceiling
RSS (130GB stream) 1,241MB flat — bounded ✓
Fault: SIGSEGV mid-run 3 retries → FATAL + checkpoint Pool hangs; futures BrokenProcessPool; parallel drops data rc=0 resilience

The per-record transform crossover (1µs → 10ms) shows dispatch dominating below ~100µs/record — the Python frontend's per-batch budget. Combined with the FFI spike's 1.7µs boundary cost, the port's performance thesis has its first measured validation.

Compatibility

  • No flag changes, no output-format changes, no exit-code changes. Exit taxonomy unchanged.
  • Existing C plugins (v1 and v2 dialect) are unaffected — argv delivery remains the default; FLAG_RAW requires explicit opt-in; -s/-b with -C now activate stdin delivery (previously ignored with a warning). The warning is removed. If you were passing -s with a -C plugin that didn't read stdin, behavior changes (data now arrives on fd 0 instead of being silently ignored). Plugins that need argv delivery with -s should not pass -s (or should use the -C flag without -s/-b).
  • fr_config_t and fr_state_t are in forkrun_substrate.h; Python plugins and C plugins are unaffected.

Verification basis

Proportionate to the engine delta (which is: ring_call dispatch arms, config struct, version bump — the scanner, ingest, NUMA routing, orderer, reactor, fences, and publication protocol are byte-identical to v3.5.1, whose 5,008-execution matrix covers those paths).

  • Both test suites (basic + comprehensive) on x86_64 UMA and NUMA.
  • Both sanitizers (TSan, ASan/UBSan) on x86_64 NUMA.
  • QEMU aarch64 on both UMA and NUMA.
  • All new test files (T-RAW 1–7, T-STDIN 1–9, T-CONFIG 1–4, IDL 1–10) on both topologies.
  • Benchmark suite on both topologies.
  • C-plugin test suite, Python test suite, canary link check, FFI spike (5 measurements).
  • Full 6-topology matrix (5,000+ executions) deferred to v3.5.3 (the next engine-change release).

Full leg logs and the verification gate record are in the repository (docs_port/, benchmarks/python/results/).


Full Changelog: v3.5.1...v3.5.2