# Forkrun – NUMA-aware shell parallelizer (50×–400× faster th…

forkrun is the culmination of a 10-year-long journey focused on "how to make shell parallelization fast". What started as a standard "fork jobs in a loop" has turned into a lock-free, CAS-retry-loop-free, SIMD-accelerated, self-tuning, NUMA aware shell-based stream parallelization engine that is (m…

- **Page:** https://magpie.gallery/i/forkrun-numa-aware-shell-parallelizer-50-400-faste-exnl
- **Type:** Link to an idea elsewhere
- **Category:** AI & dev
- **Runs on:** macos, linux
- **Tags:** shell, parallelization, performance, xargs, cli

## Source

Web · jkool702: Forkrun – NUMA-aware shell parallelizer (50×–400× faster than parallel)

- **Original:** https://news.ycombinator.com/item?id=47541746

> forkrun is the culmination of a 10-year-long journey focused on "how to make shell parallelization fast". What started as a standard "fork jobs in a loop" has turned into a lock-free, CAS-retry-loop-free, SIMD-accelerated, self-tuning, NUMA aware shell-based stream parallelization engine that is (mostly) a drop-in replacement for xargs -P and GNU parallel. On my 14-core/28-thread i9-7940x, forkrun achieves: * 200,000+ batch dispatches/sec (vs ~500 for GNU Parallel) * ~95–99% CPU utilization across all 28 logical cores, even when the workload is non-existant (bash no-ops / `:`) (vs ~6% for GNU Parallel). These benchmarks are intentionally worst-case (near-zero work per task) because they measure the capability of the parallelization framework itself, not how much work an external tool can do. * Typically 50×–400× faster on real high-frequency low-latency workloads (vs GNU Parallel) A few of the techniques that make this possible: * Born-local NUMA: stdin is splice()'d into a shared memfd, then pages are placed on the target NUMA node via set_mempolicy(MPOL_BIND) before any worker touches them, making the memfd NUMA-spliced. Each numa node only claims work that is already born-local on its node. Stealing from other nodes is permitted under some conditions when no local work exists. * SIMD scanning: per-node indexers/scanners use AVX2/NEON to find line boundaries (delimiters) at speeds approaching memory bandwidth, and publish byte-offsets and line-counts into per-node lock-free rings. * Lock-free claiming: workers claim batches with a single atomic_fetch_add — no locks, no CAS retry loops; contention is reduced to a single atomic on one cache line. * Memory management: a background thread uses fallocate(PUNCH_HOLE) to reclaim space without breaking the logical offset system. …and that’s just the surface. The implementation uses many additional systems-level techniques (phase-aware tail handling, adaptive batching, early-flush detection, etc.) to eliminate overhead, in

## GitHub projects

- https://github.com/jkool702/forkrun

## Rules for reuse

- Build your own version: don't copy another product's code, look, icons, colours or copy.
- The original belongs to its author; Magpie only links to it.
- The original content's copyright belongs to its creator. Magpie doesn't download or re-upload it; we only show the link and the official preview.
