Ractors vs threads vs fork: 28 Ruby benchmarks on 1–8 cores

Ruby/RailsConcurrency

The 28 programs from Spinel’s benchmark set, each run as 8 identical tasks under threads, Ractors and fork on 1, 2, 4 and 8 pinned cores, Ruby 4.0.9 with YJIT. fork ran 6.5–8.0× faster than one thread on every program. Ractors reached 5.3–7.9× on the 14 programs that allocate fewer than 0.11 million objects per second on one thread, and 0.26–2.0× on the 13 that allocate 2.4 million or more; 4 of those ran slower than on one thread. Why allocation stops Ractors, and what each model costs per message and per start, is in Ruby Ractors: isolation, message cost and where they scale.

Speed-up at 8 workers over one thread for 28 Ruby programs: fork reaches 6.5 to 8 times on every program, Ractors 5.3 to 7.9 times on the 14 programs that allocate under 0.11 million objects per second and 0.3 to 2 times on the 13 that allocate 2.4 million or more 8 Ractors 8 forked processes 1× 2× 4× 6× 8× partial_sums 7.91 7.99 matmul 7.69 7.95 life 7.56 8.00 sieve 7.44 7.63 so_mandelbrot 7.41 8.00 so_lists 7.07 7.90 nqueens 7.04 8.04 sudoku 7.01 7.95 fib 6.40 7.99 tak 6.33 7.98 ackermann 6.30 7.99 tarai 6.29 7.98 str_concat 5.77 6.47 fannkuch 5.29 7.82 rbtree * 4.28 7.95 linked_list * 2.00 7.88 ao_render_rs * 1.99 7.96 gcbench * 1.92 7.77 bigint_fib * 1.62 7.75 fasta_rs * 1.62 7.83 csv_process * 1.35 7.70 pidigits 1.33 7.86 io_wordcount_rs 1.28 7.95 huffman 1.17 7.80 template 0.80 7.98 binary_trees * 0.77 7.79 json_parse 0.77 7.88 splay * 0.26 6.62 * range across trials wider than ±5 % (thin line: min–max)
Speed-up at 8 workers over one thread of the same program, 8 Cortex-A725 cores, Ruby 4.0.9 + YJIT; median of 9 within-trial ratios (18 for fib, gcbench and json_parse, which ran on both machines). * marks a program whose trials ranged wider than ±5 %.
Speed-up at 8 workers over one thread for 28 Ruby programs: fork reaches 6.5 to 8 times on every program, Ractors 5.3 to 7.9 times on the 14 programs that allocate under 0.11 million objects per second and 0.3 to 2 times on the 13 that allocate 2.4 million or more 8 Ractors 8 forked processes 1× 2× 4× 6× 8× partial_sums 7.91 7.99 matmul 7.69 7.95 life 7.56 8.00 sieve 7.44 7.63 so_mandelbrot 7.41 8.00 so_lists 7.07 7.90 nqueens 7.04 8.04 sudoku 7.01 7.95 fib 6.40 7.99 tak 6.33 7.98 ackermann 6.30 7.99 tarai 6.29 7.98 str_concat 5.77 6.47 fannkuch 5.29 7.82 rbtree * 4.28 7.95 linked_list * 2.00 7.88 ao_render_rs * 1.99 7.96 gcbench * 1.92 7.77 bigint_fib * 1.62 7.75 fasta_rs * 1.62 7.83 csv_process * 1.35 7.70 pidigits 1.33 7.86 io_wordcount_rs 1.28 7.95 huffman 1.17 7.80 template 0.80 7.98 binary_trees * 0.77 7.79 json_parse 0.77 7.88 splay * 0.26 6.62 * range across trials wider than ±5 % (thin line: min–max)
Speed-up at 8 workers over one thread of the same program, 8 Cortex-A725 cores, Ruby 4.0.9 + YJIT; median of 9 within-trial ratios (18 for fib, gcbench and json_parse, which ran on both machines). * marks a program whose trials ranged wider than ±5 %.

All 28 programs

Program1 thread, runs/s8 threads2 Ractors4 Ractors8 Ractors8 Ractors, min–max8 × forkΣPSS 8 Ractors / 8 forksAllocated objects/s, 1 thread
scales
partial_sums0.911.00×2.01×4.00×7.91×7.80–8.017.99×22 / 63 MB1 k
matmul3.181.00×2.01×3.98×7.69×7.62–7.737.95×48 / 74 MB71 k
life2.071.00×1.95×3.88×7.56×7.53–7.718.00×63 / 328 MB435
sieve2.160.98×2.00×3.87×7.44×7.21–7.557.63×86 / 242 MB1 k
so_mandelbrot0.791.01×1.99×3.94×7.41×7.24–7.488.00×24 / 38 MB101 k
so_lists4.150.97×1.97×3.83×7.07×6.93–7.147.90×166 / 476 MB7 k
nqueens13.860.59×1.94×3.98×7.04×6.97–7.138.04×24 / 32 MB665
sudoku29.100.99×1.98×3.83×7.01×6.82–7.097.95×59 / 269 MB12 k
partly
fib7.281.00×1.68×3.33×6.40×6.30–6.537.99×22 / 26 MB44
tak7.441.00×1.66×3.31×6.33×6.08–6.437.98×22 / 27 MB60
ackermann11.341.00×1.69×3.36×6.30×6.12–6.507.99×26 / 32 MB91
tarai9.751.00×1.66×3.31×6.29×6.14–6.407.98×22 / 27 MB78
str_concat5,1150.94×1.86×3.51×5.77×5.64–5.886.47×78 / 194 MB46 k
fannkuch5320.85×1.85×3.83×5.29×5.12–5.487.82×24 / 69 MB6 k
rbtree6.730.99×1.75×2.99×4.28×4.07–4.517.95×43 / 63 MB1.5 M
stalls
linked_list5.160.87×1.36×1.84×2.00×1.66–2.277.88×145 / 227 MB11.3 M
ao_render_rs0.720.97×1.74×2.46×1.99×1.76–2.117.96×24 / 54 MB5.4 M
gcbench0.590.98×1.40×1.76×1.92×1.78–2.107.77×748 / 702 MB18.2 M
bigint_fib10,3800.99×1.63×2.08×1.62×1.45–1.737.75×29 / 82 MB9.5 M
fasta_rs4940.96×1.49×1.82×1.62×1.55–1.737.83×32 / 70 MB6.1 M
csv_process1.201.00×1.38×1.75×1.35×1.22–1.407.70×36 / 57 MB7.3 M
pidigits7,8690.99×1.54×1.73×1.33×1.29–1.367.86×29 / 70 MB14.5 M
io_wordcount_rs13.060.94×1.51×1.95×1.28×1.23–1.347.95×24 / 51 MB8.6 M
huffman34.460.62×1.00×1.37×1.17×1.14–1.197.80×82 / 121 MB6.9 M
slower
template1.440.98×1.33×1.38×0.80×0.76–0.847.98×23 / 42 MB15.2 M
binary_trees94.640.96×1.22×1.07×0.77×0.68–0.897.79×27 / 56 MB12.9 M
json_parse3.780.95×1.26×1.20×0.77×0.72–0.797.88×23 / 46 MB15.5 M
splay16.180.97×0.96×0.75×0.26×0.21–0.316.62×62 / 99 MB2.4 M

The allocation column is objects allocated by one run, counted once per program after two warm-up runs (alloc28.rb), times the 1-thread runs per second. The 1-thread column is runs of the program per second; every other column is a speed-up over the 1-thread cell of the same trial. Median of 9 trials (18 for fib, gcbench and json_parse, which ran on both machines). Programs are grouped by their 8-Ractor speed-up: scales ≥ 7×, partly 4–7×, stalls 1–4×, slower < 1×.

Memory

ΣPSS is the proportional set size of the Ractor process, or of the parent plus 8 children under fork, at the end of the cell; pages shared between processes count once in total.

Three patched programs

The harness loads every constant through Ractor.make_shareable in all three models, so every model runs the same code. Three programs needed a patch; the originals’ results are in the data.

ProgramOriginalPatch
ao_renderRAND = Rand.new becomes frozen; Rand#rand changes it → FrozenError in every modelone Rand per run in Thread.current
fastathe global $last → Ractor::IsolationError in Ractors only (threads and fork ran: 8 forks 7.80×)Thread.current[:fasta_last]
io_wordcountevery worker writes, reads and deletes one fixed /tmp fileone file per worker

Each patch does the same work per run as the original and uses the original’s runs per task. fasta_rs costs 3.5 % on one thread (494 against 512 runs per second).

--- bm_fasta.rb
+++ bm_fasta_rs.rb
-$last = 42
+Thread.current[:fasta_last] = 42

 def gen_random(max)
-  $last = ($last * IA + IC) % IM
-  max * $last / IM
+  Thread.current[:fasta_last] = (Thread.current[:fasta_last] * IA + IC) % IM
+  max * Thread.current[:fasta_last] / IM
 end
--- bm_ao_render.rb
+++ bm_ao_render_rs.rb
-RAND = Rand.new
+# RAND: one Rand per run, thread-local (was a mutable constant)
-        r = RAND.rand
-        phi = 2.0 * 3.14159265 * RAND.rand
+        r = Thread.current[:ao_rand].rand
+        phi = 2.0 * 3.14159265 * Thread.current[:ao_rand].rand
 # File.open("ao.ppm", "w") do |fp|
+Thread.current[:ao_rand] = Rand.new   # one Rand per run (was the mutable constant RAND)
--- bm_io_wordcount.rb
+++ bm_io_wordcount_rs.rb
-File.open("/tmp/spinel_io_wf.txt", "w") do |f|
+wf_path = "/tmp/spinel_io_wf_#{Process.pid}_#{Thread.current.object_id}.txt"   # one file per worker (was one fixed path)
+File.open(wf_path, "w") do |f|
   (the same change on the two reads and the delete)

GC settings

The knowledge article’s String, Hash and JSON.parse workloads (rb3.rb) under four settings of the garbage collector; 1 thread, 8 Ractors and 8 forks, 9 trials on one machine. “1M slots” sets RUBY_GC_HEAP_0_INIT_SLOTS to RUBY_GC_HEAP_4_INIT_SLOTS to 1,000,000; “growth 4” adds RUBY_GC_HEAP_GROWTH_FACTOR=4 and RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO=0.5; “GC off” calls GC.disable before the timed reps.

WorkloadSetting1 thread, tasks/s8 Ractors8 forksGCs per rep, 8 RactorsGC share, 8 Ractors8 Ractors, trial rangePeak memory, 8 Ractors
String allocdefault1,5440.92×7.89×92.731 %15 %19 MB
String alloc1M slots1,6402.96×8.85×3.238 %3 %59 MB
String alloc1M slots + growth 41,6402.91×8.83×3.238 %6 %59 MB
String allocGC off1,5263.05×7.99×0.00 %17 %2.6 GB
Hash allocdefault4,9991.04×7.64×32.433 %22 %19 MB
Hash alloc1M slots4,8272.81×9.04×0.745 %9 %129 MB
Hash alloc1M slots + growth 44,5523.05×9.97×0.547 %52 %165 MB
Hash allocGC off4,2391.94×9.07×0.00 %12 %3.3 GB
JSON.parsedefault6,5061.14×7.69×16.633 %15 %19 MB
JSON.parse1M slots6,3422.58×8.74×0.649 %5 %115 MB
JSON.parse1M slots + growth 46,3155.63×8.54×0.549 %21 %151 MB
JSON.parseGC off6,0231.92×8.32×0.00 %11 %3.1 GB

Speed-ups are over 1 thread under the same setting. GC share is GC.stat[:time] over wall time.

Task size

How small may a task be before one message per task eats the gain? Each task is fib(n), sent as its own message to one of 8 Ractors, or as one line over a pipe to one of 8 forked children (64 in flight per child). The baseline runs the same tasks in a loop on one core. Tasks per rep are fixed per n: about 0.4 s of work on one core from fib(10) up, capped at 400,000 tasks below that.

TaskOne task on one core8 Ractors8 forks8 Ractors, trial range
fib(1)0.016 µs0.03×0.01×84 %
fib(5)0.117 µs0.17×0.06×23 %
fib(10)1.3 µs2.29×0.65×28 %
fib(15)14.7 µs5.46×4.48×4 %
fib(18)62.2 µs6.31×6.74×2 %
fib(20)163 µs6.21×7.13×2 %
fib(22)426 µs6.39×7.45×2 %
fib(25)1.81 ms6.49×7.67×1 %

Shared read-only data

8 workers each scan one Array of 500,000 Strings of 100 B twice per rep. Ractors receive it after one Ractor.make_shareable (0.109 s); forked children inherit it. Every model runs GC.start and GC.compact before starting its workers, as a pre-forking server does before forking.

ModelScans/sSpeed-upTrial rangeΣPSSΣRSS
1 thread47.71.00×2 %121 MB122 MB
1 Ractor47.61.00×2 %120 MB121 MB
1 fork47.61.00×3 %121 MB236 MB
8 threads32.20.68×2 %121 MB122 MB
8 Ractors360.27.56×27 %122 MB123 MB
8 forks477.810.02×1 %138 MB1,068 MB
Cores1 child4 children
core 1 / cores 1–4 (8 MB L3)47.653.5
core 10 / cores 10–13 (16 MB L3)49.959.0
cores 1–4 and 10–13, 8 children59.5 per child

The bigger L3 adds 5 % for one child. Children that read the same pages through one shared L3 each run 12–18 % faster than one alone, consistent with each page coming from memory once for several cores. Every 8-against-1 ratio of memory-heavy work in this article (this section and the GC settings) includes both effects; CPU-bound programs stay at or below 8.04×.

Two machines

The 28 programs were split across two identical machines; fib, gcbench and json_parse ran on both:

ProgramCellMachine A, runs/sMachine B, runs/sGap
fib1 thread7.2807.285+0.1 %
fib8 Ractors46.58646.558−0.1 %
fib8 forks58.14258.168+0.0 %
gcbench1 thread0.5930.594+0.2 %
gcbench8 Ractors1.1441.141−0.3 %
gcbench8 forks4.6284.615−0.3 %
json_parse1 thread3.7833.765−0.5 %
json_parse8 Ractors2.8492.951+3.6 %
json_parse8 forks29.77629.802+0.1 %

All 30 anchor cells (every model and W) agree within 1.1 %, except json_parse at 4 and 8 Ractors (+2.8 %, +3.6 %).

Gates and discards

RunRows keptRe-run: machine busyRe-run: foreign load on the coresRe-run: GPU busyYJIT gate (6 probes, spread)
28 programs, both machines2,970105000.16–0.83 %
knowledge article cells, 3 passes1,1611700none; fib on 1 Ractor ran 2,176–2,178 tasks/s in all 9 trials
GC settings, task size, shared data, cache check7650000.24–0.92 %

The 2,970 rows include 126 expected failures: the unpatched ao_render in every model and the unpatched fasta in Ractors. In every kept cell the rest of the machine used at most 4.99 cores and the GPU 0 %.

Downloads

Benchmark setup

SetupDetails
Programsthe 28 programs in Spinel’s benchmark/ directory, the same set as in Spinel vs JRuby vs CRuby (YJIT): 28 Ruby benchmarks; 25 run unchanged, 3 need a 2–4 line patch to run as parallel copies (below)
Ruby4.0.9, image ruby@sha256:3251898a…2cd31d (full digest in the commands below), arm64, --yjit
Modelsthreads: W threads in one process (one GVL) · Ractors: W Ractors in one process (one GVL each) · fork: W pre-forked child processes fed over pipes, the shape of a Puma cluster
WorkersW = 1, 2, 4, 8 Ractors or forked children, and 1 and 8 threads, each on exactly W cores
Hoststwo identical 20-core ARM64 servers (10 × Cortex-X925 + 10 × Cortex-A725). Benchmarks on the A725 cores at 2.8 GHz, governor performance: --cpuset-cpus=1, 1-2, 1-4, 1-4,10-13. Each program ran on one host; three anchor programs ran on both
Isolationevery systemd service, every other container and every movable IRQ confined to the ten X925 cores for the whole run (cgroup v2 cpuset.cpus on system.slice, user.slice, init.scope); benchmark containers in their own slice
Load gatesa cell is discarded and run again when, during that cell, (1) other processes used more than 0.05 + 0.03 × W cores of the benchmark’s own cores, (2) the rest of the machine used more than 5 cores — a busy neighbour slows allocation-heavy cells by 10–14 % through the shared memory system even when no core is shared — or (3) the GPU, which shares that memory, was more than 5 % busy (a GPU serving a model slowed memory-bound cells 2.5×). After (2) or (3) the cell waits 30 s. Discarded cells are never counted
YJIT gatebefore every pass, 6 processes of 64 × fib(22) on one benchmark core must agree within 10 % (on the X925 cores YJIT speed varies up to 14× between processes); all 12 gates gave 0.0274–0.0277 s
Correctnessevery run of every program, in every model, compares its output with Spinel’s .expected file; one mismatch fails the cell
Trials3 passes × 3 interleaved trials = 9 measurements per cell; the median is reported

Method

bm28.rb turns one Spinel program into a task. Prism splits the file: method, class and module definitions and constant assignments load once in the main Ractor (constants through Ractor.make_shareable, in every model); every other top-level statement becomes __bm_run, which captures $stdout into a per-thread buffer. A task runs __bm_run k times and compares every output with the program’s .expected. k comes from calib.jsonl, one value per program for both machines, chosen so one task takes at least 50 ms on one core.

Each rep sends 8 tasks to W workers round-robin: W threads fed by a Queue, W Ractors fed by send and answering on one Ractor::Port (with #monitor, so a worker that dies fails the cell instead of hanging it), or W forked children fed over pipes. 1 warm-up rep, then at least 2 reps and 3 s; the cell reports the median rep as runs per second (8 × k ÷ rep time) and ΣPSS/ΣRSS from /proc/<pid>/smaps_rollup. A program that cannot run in a Ractor prints its error as the result.

The order inside a pass: trial 1 of every cell of every program, then trial 2, then trial 3. A speed-up is the ratio to the 1-thread cell of the same program in the same trial; the tables give the median of the 9 ratios and the figure marks programs whose ratios ranged wider than ±5 %. Machine A ran 16 programs, the first (superseded) task-size and shared-data run and the 3 passes of the knowledge article’s cells; machine B ran 17 programs, the GC settings and the corrected task-size and shared-data runs. Machine A ran for 5.9 hours, machine B for 4.8.

The scripts are a record of this run on this hardware: core sets, the core lock and the work directory are written into them, not read from a configuration.

One cell, as run28g.sh starts it:

docker run --rm --cgroup-parent=bench651.slice --cpuset-cpus=1-4,10-13 -v "$PWD":/b -w /b \
  ruby@sha256:3251898a6b7ff1275a0dc279d401889c6c743c1fb3292fa3ce1a2e12fc2cd31d \
  timeout 900 ruby --yjit bm28.rb benchmark/bm_life.rb ractors 8 1

bm28.rb:

# bm28.rb <bm_file> <model> <W> <k> — one Spinel program under threads / ractors / fork, W workers on W cores.
# Prism splits the program: def/class/module/constant writes load once in the main Ractor (constants through
# Ractor.make_shareable, the same in every model); every other top-level statement becomes __bm_run, which
# captures $stdout. A task runs __bm_run k times and checks every output against Spinel's .expected.
# TASKS tasks per rep, split round-robin over W workers; 1 warm-up rep, then >= 2 reps and >= 3 s; median rep.
# One JSON line on stdout; a non-Ractor-safe program prints {error: …} and exits 0 (it is a result, not a crash).
require "prism"
require "stringio"
require "json"
require "etc"
Warning[:experimental] = false
file, model, w, k = ARGV.shift, ARGV.shift, Integer(ARGV.shift), Integer(ARGV.shift)
ARGV.clear
TASKS = 8
def now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
def median(a) = a.sort[a.size / 2]
def pss_kb(pid) = File.read("/proc/#{pid}/smaps_rollup")[/^Pss:\s+(\d+)/, 1].to_i
def rss_kb(pid) = File.read("/proc/#{pid}/smaps_rollup")[/^Rss:\s+(\d+)/, 1].to_i
bm = File.basename(file, ".rb").sub(/\Abm_/, "")
out = { test: "bm28", bm: bm, model: model, w: w, k: k, tasks: TASKS, ruby: RUBY_VERSION,
        yjit: defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?, cpus: Etc.nprocessors }
EXPECTED = Ractor.make_shareable(File.read("#{file}.expected"))
stmts = Prism.parse(File.read(file)).value.statements.body
DEFN = [Prism::DefNode, Prism::ClassNode, Prism::ModuleNode, Prism::ConstantWriteNode, Prism::ConstantPathWriteNode]
defs, body = stmts.partition { |n| DEFN.any? { n.is_a?(_1) } }
defs_src = defs.map { |n| n.is_a?(Prism::ConstantWriteNode) ? "#{n.name} = Ractor.make_shareable(#{n.value.slice})" : n.slice }.join("\n")
TOPLEVEL_BINDING.eval(defs_src, file)
TOPLEVEL_BINDING.eval(<<~RUBY, file)
  def __bm_run
    o = StringIO.new; Thread.current[:bm_out] = o
    begin
  #{body.map(&:slice).join("\n")}
    ensure
      Thread.current[:bm_out] = nil
    end
    o.string
  end
  def __bm_task(k)
    k.times { raise "output != .expected" unless __bm_run == EXPECTED }
    1
  end
RUBY
Ractor.make_shareable(ARGV)
class BmOut   # $stdout forwarder: output goes to the calling thread's buffer, in every model
  def target = Thread.current[:bm_out] || STDOUT   # inside __bm_run: the run's buffer; outside (fork's flush, at_exit): the real stdout
  def write(*a) = target.write(*a)
  def method_missing(m, *a, &b) = target.__send__(m, *a, &b)
  def respond_to_missing?(*) = true
end
$stdout = BmOut.new

begin
  __bm_task(1)   # the program must be correct in the main Ractor first
rescue Exception => e
  STDOUT.puts JSON.generate(out.merge(error: "main: #{e.class}: #{e.message.lines.first.to_s.strip[0, 160]}")); exit 0
end

shares = Array.new(w) { |i| (i...TASKS).step(w).count }
rep = case model
when "threads"
  Thread.abort_on_exception = true   # a worker that raises ends the process (the cell fails) instead of leaving back.pop waiting
  qs = Array.new(w) { Queue.new }; back = Queue.new
  w.times { |i| Thread.new { while qs[i].pop; back << shares[i].times.sum { __bm_task(k) }; end } }
  -> { qs.each { _1 << true }; Array.new(w) { back.pop }.sum }
when "ractors"
  back = Ractor::Port.new
  begin   # one task in a Ractor first: a program that is not Ractor-safe is a result, not a hang
    Ractor.new(k) { |k| $stdout = BmOut.new; __bm_task(k) }.value
  rescue Ractor::RemoteError => e
    STDOUT.puts JSON.generate(out.merge(error: "ractor: #{e.cause.class}: #{e.cause.message.lines.first.to_s.strip[0, 160]}")); exit 0
  end
  rs = Array.new(w) { |i| Ractor.new(shares[i], k, back) { |n, k, b| $stdout = BmOut.new; while Ractor.receive; b << n.times.sum { __bm_task(k) }; end } }
  rs.each { _1.monitor(back) }       # a worker that dies posts :aborted to the results port -> the task count check fails the cell
  -> { rs.each { _1.send(true) }; Array.new(w) { v = back.receive; raise "ractor worker died: #{v.inspect}" unless v.is_a?(Integer); v }.sum }
when "fork"
  kids = Array.new(w) do |i|
    cr, cw = IO.pipe; pr, pw = IO.pipe
    pid = fork { cw.close; pr.close; while cr.gets; pw.puts(shares[i].times.sum { __bm_task(k) }); end; exit! 0 }
    cr.close; pw.close; [cw, pr, pid]
  end
  -> { kids.each { |cw, _, _| cw.puts "go" }; kids.sum { |_, pr, _| pr.gets.to_i } }
else abort "model?"
end

begin
  abort "task count" unless rep.call == TASKS   # warm-up rep
  times = []; t_end = now + 3.0
  while times.size < 2 || now < t_end
    t = now; abort "task count" unless rep.call == TASKS; times << now - t
  end
rescue Ractor::RemoteError => e
  STDOUT.puts JSON.generate(out.merge(error: "ractor: #{e.cause.class}: #{e.cause.message.lines.first.to_s.strip[0, 160]}")); exit 0
end
pids = [Process.pid] + (model == "fork" ? kids.map { _1[2] } : [])
t = median(times)
STDOUT.puts JSON.generate(out.merge(reps: times.size, median_s: t.round(6), runs_per_s: (TASKS * k / t).round(3),
  pss_kb: pids.sum { pss_kb(_1) }, rss_kb: pids.sum { rss_kb(_1) }, procs: pids.size, checksum: EXPECTED.bytesize))
if model == "fork"   # close every command pipe first: each later child holds copies of the earlier children's pipes,
  kids.each { |cw, _, _| cw.close }          # so closing and waiting one by one deadlocks; all closed, they exit last-to-first
  kids.each { |_, _, pid| Process.wait(pid) }
end

Questions? Let's Chat :)

ruby