Batch-size benchmarks
What does batch mode buy, and at
which batch size? This directory measures it end to end. The same
row-wise transformation is written in R, Python, Node.js, DuckDB SQL and
Starlark, and the real openflange binary runs it:
- without batch mode (one record per call),
- with batches as array lines (
delivery: lines) of at most 1, 10, 100,
1,000 and 10,000 records,
- with batches as files (
delivery: file) of at most 100, 1,000 and
10,000 records, plus 100,000 for DuckDB, which is started once per file.
One more scenario is the reason batch mode exists: a pipe whose every
call costs 5 ms, however many records the call carries.
Status: the runner is ready; the published results are not measured
yet. They are to be measured on a dedicated machine, following
RUNNING.md. Numbers from a shared machine were discarded.
Results
Not measured yet: see RUNNING.md.
How to read this
- Throughput is end to end. Each number is records divided by the
wall-clock time of one
openflange run process: runner start-up,
interpreter start-up, reading the input file, the pipe, and writing
the output file. That is what a user waits for, not the speed of the
transformation alone.
- Every run is checked before it counts. The SHA-256 of every run's
output, calibration runs included, must equal that of a reference
implementation (
data.go) for the same records. A configuration that
produces different bytes stops the benchmark with WRONG OUTPUT; it is
never reported as a slow cell.
- Median of 3 runs, with the slowest and fastest as min–max. A wide
range means something else ran on the machine.
- Runs are interleaved. Cells are grouped by scenario and runtime. Every
cell of a group is calibrated first; then the timed runs go round-robin:
run 1 of every batch size, then run 2, then run 3. A disturbance
therefore hits all batch sizes of a runtime alike, and comparing
batch sizes within one runtime is the most robust reading of the
tables.
n differs per cell. Each cell uses the smallest dataset, from 1,000
to 1,000,000 records, on which one run takes about 2 seconds. It also
holds at least 5 × maxItems records. A fast cell is measured on more
records than a slow one, so start-up weighs less on it.
- † noisy: the machine's 1-minute load average was above 4 before or
after one of the cell's runs. On a dedicated machine there should be
none.
- ‡ short batches: the run report's average batch was under 90 % of
maxItems, so the cell does not measure the size it is labelled with.
- "not measured" means the cell was stopped by a limit (20 s per run,
2 GiB of memory) or its runtime is missing. The reason is in the table
and in
results.json. Nothing is extrapolated.
- One machine. The line above the tables names the CPU, memory, OS,
versions and whether the benchmark was confined. It is not a claim about
other hardware.
Choosing maxItems and maxWaitMs
These are rules of thumb that follow from how batch mode works. Check them
against the tables once they are measured.
- Start from the cost per call. If one call has a fixed cost (process
round trip, an HTTP request, a model call), the throughput ceiling is
roughly
maxItems / cost-per-call. The slow-call table shows that
ceiling (200 × maxItems records per second for 5 ms) and where the
cost of the records themselves takes over. Raise maxItems until you
are past that point, not further.
- Vectorised runtimes (R, NumPy-style Python) want hundreds to
thousands of items per call. Per-record R pays its interpreter's per-call overhead on every record.
Very large batches stop helping once one call's work dominates, and they
cost memory: a node holds up to 2 ×
maxItems items (one batch in flight,
one accumulating). With delivery: file, the spooled batch is on disk,
not in memory.
- Per-record languages (plain Python, Node.js) gain less. Their
per-record cost is already small, and array lines save mostly parsing
and system calls. A few hundred items is usually enough.
delivery: file is for tools that want a file (DuckDB, pandas, a
command per file). With one process per batch, start-up is paid per
batch, so batches must be large (DuckDB: tens of thousands) to amortise
it.
maxWaitMs bounds latency, not throughput. A batch is handed over
when it is full or when its first item has waited maxWaitMs. For
bulk files it does not matter, because input arrives faster than any
wait. For a trickle (events, a live feed) it is the longest a record
waits before it is processed. Choose the latency you can accept, for
example 100–1,000 ms. 0 means "never hold a record back", so batches
are only as large as what is already queued.
- Consumers may only tighten. A pipeline node, or
openflange run --batch, can lower maxItems and maxWaitMs, never raise them above
what the pipe declares. Declare the largest batch the implementation
handles safely, and let consumers choose smaller ones.
openflange run --verbose prints, per batch-mode node, how many batches
there were, their average and largest size, and why each was flushed
(full, wait, end of input). It is the quickest way to see what your
settings do on your data.
Run it
See RUNNING.md for the full procedure, the prerequisites
and how to send results back. In short:
benchmarks/batch/run.sh --check # prerequisites, with install commands for what is missing
benchmarks/batch/run.sh --quick # smoke test, about a minute, published files untouched
benchmarks/batch/run.sh # full run (estimated 15-40 minutes): results.json, charts/, the tables above
go run ./benchmarks/batch -render # redraw charts and tables from results.json only