The same input and the same kernels, in neo's C++ and in Spark 4.2.0. Across 14 measurements neo finished 83.2× faster in the middle and 2,049× at most; Spark was not quicker on any.
01 · The race
One kernel at a time
Each piece of work below has its own race, what it measures, how each side does it, the code that ran and every number taken for it. In a race both ships run for the same stretch: Spark completes the work once, and neo completes it as many times as the measured ratio says, turning around at each end.
Read a 46 MB CSV of a million rows and six columns into a table: split the bytes into fields, parse the amount column into numbers, and dictionary-encode the region column. Each engine's typed read, best of two, with the first read of a fresh process kept separately.
How neo does it
neo's parser finds the structural characters with SIMD, splits the file into blocks and parses them on every core above a megabyte, with results identical to the serial path. Typing and the dictionary happen once, at load, on the pool, so no kernel after it touches text. In the ledger's breakdown that is 2.8 ms of parse, 0.2 ms of typing and about nothing for the dictionary.
How Spark does it
spark.read.csv with inferSchema, cached, then a count to force the read into memory. inferSchema reads the file once more to find the types, and that is inside the time.
Spark, this kernel · neon-cpp/bench/lang/python/yardstick.py
def load():
global df
if df is not None:
df.unpersist(blocking=True)
df = spark.read.csv(args.csv, header=True, inferSchema=True).cache()
df.count() # force the read into memory; inferSchema has already read the file once more for types
res["load_first_ms"], res["load_ms"] = load_twice(load)
neo's side: the call and the contract
the harness, calling the engine · neon-cpp/bench/bench_engine_options.cpp:194
time, runs in a row, msThe typed read, best of two, with the first read of a fresh process kept separately.
2.77
359
130×
energy, runs in a row, mJMillijoules a run, in the same run as the time: the energy over the timed runs and as many more as fill 200 ms, divided by the runs, less the draw at rest. A mean, where the time is a best.
172
14,302
83.2×
Read it with this
Spark's JVM and session start-up are not counted here.
Count the rows whose amount is over 500: a million comparisons on a typed column, the answer one integer. Each library's count is written the way its users write it.
How neo does it
neo's filter produces a bitmap: one bit per row, 125 KB for a million rows, written at memory speed, with indices made only when something needs them. Below about a million values it runs on one thread, above that on the pool. The contract is the JavaScript node's: NaN never matches.
How Spark does it
A filter and a count, which Spark plans and runs as a job.
Spark, this kernel · neon-cpp/bench/lang/python/yardstick.py
timed("filter", lambda: df.filter(pred).count())
neo's side: the call and the contract
the harness, calling the engine · neon-cpp/bench/bench_engine_options.cpp:337
const double f5 = timeIt([&] { Bitmap b = compareDoubles(amt.data(), n, Cmp::Gt, 500, &pool); sink = b.words[0]; }, 7);
the filter's contract · neon-cpp/core/selection.h:1
// selection.h — the result of a filter: one bit per row. 1M rows = 125 KB,
// written at memory speed; indices are produced only when something needs them.
struct Bitmap {
std::vector<uint64_t> words;
size_t bits = 0;
bool test(size_t i) const { return (words[i >> 6] >> (i & 63)) & 1; }
size_t count() const;
std::vector<uint32_t> indices() const; // ascending row indices of the set bits
};
// JS measurefilter semantics: NaN never matches. Sequential below ~1M values; the pool otherwise.
Bitmap compareDoubles(const double* v, size_t n, Cmp op, double threshold, Pool* pool);
Every number taken for it
measurement
neo
Spark
× neo
time, runs in a row, msBest of three, runs in a row: every thread awake and the cores at speed.
0.018
36.9
2,049×
energy, runs in a row, mJMillijoules a run, in the same run as the time: the energy over the timed runs and as many more as fill 200 ms, divided by the runs, less the draw at rest. A mean, where the time is a best.
1.08
1,413
1,313×
time, one run from rest, msThe call made once after 50 ms of nothing, mean of ten: what a click finds.
0.782
29.8
38.0×
energy, one run from rest, mJThe same single call from rest, in millijoules. From rest a run costs less than in a row where the work is large, and more where it is tiny, because the threads have to be woken for it.
8.72
315
36.1×
Read it with this
Spark's JVM and session start-up are not counted here.
the filter's contract · neon-cpp/core/selection.h:1
// selection.h — the result of a filter: one bit per row. 1M rows = 125 KB,
// written at memory speed; indices are produced only when something needs them.
struct Bitmap {
std::vector<uint64_t> words;
size_t bits = 0;
bool test(size_t i) const { return (words[i >> 6] >> (i & 63)) & 1; }
size_t count() const;
std::vector<uint32_t> indices() const; // ascending row indices of the set bits
};
// JS measurefilter semantics: NaN never matches. Sequential below ~1M values; the pool otherwise.
Bitmap compareDoubles(const double* v, size_t n, Cmp op, double threshold, Pool* pool);
Every number taken for it
measurement
neo
Spark
× neo
time, runs in a row, msBest of three, runs in a row: every thread awake and the cores at speed.
0.380
22.0
57.8×
energy, runs in a row, mJMillijoules a run, in the same run as the time: the energy over the timed runs and as many more as fill 200 ms, divided by the runs, less the draw at rest. A mean, where the time is a best.
21.6
1,402
65.0×
Read it with this
Spark's JVM and session start-up are not counted here.
Produce the stable ascending order of the amount column as a permutation of row indices, without moving any other column. SQL engines have no such form, so DuckDB and Spark sit this one out.
How neo does it
neo turns each double into a sortable 64-bit key and runs an LSD radix sort on the pool: O(n), stable, with the JavaScript rule that NaN sorts as negative infinity and ties keep their order. The ledger's design levers show the step from std::stable_sort at 84 ms, to radix at 14 ms, to the pool at 1 ms.
How Spark does it
Spark, like SQL, has no ordering apart from the table it orders, so nothing is timed here and the cell is left blank.
Spark, this kernel · neon-cpp/bench/lang/python/yardstick.py
res["sort_perm_ms"] = None
neo's side: the call and the contract
the harness, calling the engine · neon-cpp/bench/bench_engine_options.cpp:372
// sort.h — stable O(n) sorting of row indices by a double key (parallel radix).
// JS numeric sort semantics: NaN sorts as -Infinity; ties keep input order.
// Fills `idx` with the stable ascending order of keys[0..n). pool may be null.
void sortIndexByDouble(const double* keys, size_t n, std::vector<uint32_t>& idx, Pool* pool);
Every number taken for it
measurement
neo
Spark
× neo
time, runs in a row, msBest of three, runs in a row: every thread awake and the cores at speed.
1.03
—
—
energy, runs in a row, mJMillijoules a run, in the same run as the time: the energy over the timed runs and as many more as fill 200 ms, divided by the runs, less the draw at rest. A mean, where the time is a best.
64.5
—
—
time, one run from rest, msThe call made once after 50 ms of nothing, mean of ten: what a click finds.
2.73
—
—
energy, one run from rest, mJThe same single call from rest, in millijoules. From rest a run costs less than in a row where the work is large, and more where it is tiny, because the threads have to be woken for it.
44.8
—
—
Read it with this
Spark's JVM and session start-up are not counted here.
Sort by amount and build the whole sorted table, every column reordered.
How neo does it
The permutation from the radix sort drives a parallel gather of every column, with the dictionary column moved as ids. The ledger times the gather alone at under three milliseconds for a million rows.
How Spark does it
orderBy on amount, written to the noop sink: every sorted row is produced and none is collected.
Spark, this kernel · neon-cpp/bench/lang/python/yardstick.py
// sort.h — stable O(n) sorting of row indices by a double key (parallel radix).
// JS numeric sort semantics: NaN sorts as -Infinity; ties keep input order.
// Fills `idx` with the stable ascending order of keys[0..n). pool may be null.
void sortIndexByDouble(const double* keys, size_t n, std::vector<uint32_t>& idx, Pool* pool);
Every number taken for it
measurement
neo
Spark
× neo
time, runs in a row, msBest of three, runs in a row: every thread awake and the cores at speed.
2.72
122
45.0×
energy, runs in a row, mJMillijoules a run, in the same run as the time: the energy over the timed runs and as many more as fill 200 ms, divided by the runs, less the draw at rest. A mean, where the time is a best.
144
6,350
44.2×
Read it with this
Spark's JVM and session start-up are not counted here.
Total the amount column for each of five regions: a grouped sum, the kernel every dashboard runs.
How neo does it
The region column was dictionary-encoded at load, so its ids are the group numbers and no string is hashed. The sum is taken on the pool in any order only when the column is whole numbers small enough that no addition can round; otherwise it is added in row order on one thread, because a floating-point sum depends on its order, and the contract is the JavaScript loop's result to the bit.
How Spark does it
groupBy on region with a sum of amount, and the answer collected to the driver.
Spark, this kernel · neon-cpp/bench/lang/python/yardstick.py
the group sum's contract · neon-cpp/core/groupsum.h:1
// groupsum.h — a typed column's sum, count and extremes per group: what the aggregate node's measures need
// once the column is doubles (toDoubles) and every row has a group number.
//
// The results are the ones a loop over the rows in order gives — `if (isFinite(v)) { sum += v; n++;
// if (v < min) min = v; if (v > max) max = v; }` a group, which is what the JavaScript does — to the bit:
// • counts and extremes are taken a part of the rows at a time on the pool and the parts joined in row
// order (a strict comparison keeps the earlier of two equal values, as the loop does);
// • a sum is added in row order on one thread, because a floating-point sum depends on its order —
// unless the column is whole numbers small enough that no addition can round (wholeNumbers below),
// where every order gives the same bits and the rows are summed on the pool, two a step.
// bench/bench_agg_node.cpp times each path against the node and checks it; PHD.md §30.
// The sum alone, any order, two rows a step; for tests and the benchmark (groupStats calls it when it may).
// False, and nothing written, when there are more groups than it is built for.
bool groupSumAnyOrder(const double* x, const uint32_t* id, size_t n, size_t groups, Pool* pool, double* sums);
Every number taken for it
measurement
neo
Spark
× neo
time, runs in a row, msBest of three, runs in a row: every thread awake and the cores at speed.
0.020
39.0
1,948×
energy, runs in a row, mJMillijoules a run, in the same run as the time: the energy over the timed runs and as many more as fill 200 ms, divided by the runs, less the draw at rest. A mean, where the time is a best.
1.55
2,352
1,518×
time, one run from rest, msThe call made once after 50 ms of nothing, mean of ten: what a click finds.
0.758
40.4
53.3×
energy, one run from rest, mJThe same single call from rest, in millijoules. From rest a run costs less than in a row where the work is large, and more where it is tiny, because the threads have to be woken for it.
9.11
787
86.4×
Read it with this
Spark's JVM and session start-up are not counted here.
02 · Every number
Against the libraries people reach for first
1,000,000 rows · ms, lower is better · 2026-10-11 21:23
kernel
neo
Spark
× neo
load the CSV (parse + type)
2.77
359
130×
filter amount > 500, count
0.018
36.9
2,049×
filter into a new table
0.380
22.0
57.8×
sort into a new table
2.72
122
45.0×
sum(amount) by region
0.020
39.0
1,948×
filter, count: one run from rest
0.782
29.8
38.0×
sum by region: one run from rest
0.758
40.4
53.3×
The same CSV and the same six kernels in neo's engine and in the libraries people reach for first, each written the way its users write it (Polars 2.0.0, DuckDB 1.5.6, pandas 3.0.6, Spark 4.2.0). Milliseconds, best of three; the chip is how many times neo's time a library took. The last three rows are one run from rest: the call made once after 50 ms of nothing, mean of ten, neo's pool told to rest after it as the editor tells it. That is what a click finds; the rows above are runs in a row, every thread awake and the cores at speed.
The same run, in energy
1,000,000 rows · mJ, lower is better · 2026-10-11 21:23
kernel
neo
Spark
× neo
load the CSV (parse + type)
172
14,302
83.2×
filter amount > 500, count
1.08
1,413
1,313×
filter into a new table
21.6
1,402
65.0×
sort into a new table
144
6,350
44.2×
sum(amount) by region
1.55
2,352
1,518×
filter, count: one run from rest
8.72
315
36.1×
sum by region: one run from rest
9.11
787
86.4×
The same CSV and the same six kernels as the times, in the same run (Polars 2.0.0, DuckDB 1.5.6, pandas 3.0.6, Spark 4.2.0). Millijoules a run. What macOS billed each engine's process, and for Spark its JVM, for the processor cores it ran on: not the memory, the disk or the screen, and not the machine at rest. A kernel's figure is the energy over its timed runs, and as many more as fill 200 ms, divided by the runs, less what the process draws at rest for as long: a mean, where the time is a best. neo's is of the variant whose time is the number on the Speed side. Each benchmark reads the counter itself; scripts/bench_libraries.sh also reads it from outside the process (neon_energy) and RESULTS.md has both totals. The chip is how many times neo's energy a library used. The last three rows are one run from rest: the call made once after 50 ms of nothing, mean of ten, neo's pool told to rest after it as the editor tells it. That is what a click finds; the rows above are runs in a row, every thread awake and the cores at speed. From rest a run costs less energy than in a row where the work is large (the cores are not at their top voltage) and more where it is tiny (the threads have to be woken for it).
03 · The code that ran
Spark's side, in full
Apache Spark is a distributed engine built for clusters, run here on one machine on Java 17. Its JVM and session start-up are listed separately and not counted against the kernels. Its kernels are written the way its users write them. Each kernel's lines are beside its race above; this is the whole block they come from, with the checks it prints.
spark, as its users write it: the six kernels · neon-cpp/bench/lang/python/yardstick.py:255
elif args.lib == "spark":
t0 = now()
from pyspark.sql import SparkSession, functions as F
import pyspark
res["version"] = pyspark.__version__
mem = os.environ.get("NEON_SPARK_MEMORY", "48g")
spark = (SparkSession.builder.master(f"local[{args.threads}]")
.config("spark.driver.memory", mem)
.config("spark.sql.shuffle.partitions", str(args.threads))
.config("spark.default.parallelism", str(args.threads))
.config("spark.ui.enabled", "false")
.config("spark.sql.adaptive.enabled", "true")
.getOrCreate())
spark.sparkContext.setLogLevel("ERROR")
res["startup_ms"] = (now() - t0) * 1000
PIDS = descendants() # the JVM is where Spark's work is done
res["java"] = spark.sparkContext._jvm.java.lang.System.getProperty("java.version")
df = None
def load():
global df
if df is not None:
df.unpersist(blocking=True)
df = spark.read.csv(args.csv, header=True, inferSchema=True).cache()
df.count() # force the read into memory; inferSchema has already read the file once more for types
res["load_first_ms"], res["load_ms"] = load_twice(load)
res["rows"] = df.count()
pred = F.col("amount") > 500
sink = lambda d: d.write.format("noop").mode("overwrite").save() # Spark's benchmarking sink: every row is produced, none is collected
timed("filter", lambda: df.filter(pred).count())
timed("filter_mat", lambda: sink(df.filter(pred)))
res["sort_perm_ms"] = None
timed("sort_mat", lambda: sink(df.orderBy("amount")))
timed("agg", lambda: df.groupBy("region").agg(F.sum("amount")).collect())
checks["filter_count"] = df.filter(pred).count()
checks["first_sorted"] = [float(r[0]) for r in df.orderBy("amount").select("amount").limit(3).collect()]
checks["sums"] = {r[0]: float(r[1]) for r in df.groupBy("region").agg(F.sum("amount")).collect()}
energy_summary() # while the JVM is still there to be read
spark.stop() # so the JVM's peak RSS is in RUSAGE_CHILDREN
neo's side: the calls and the contracts
neo's kernels are the product, so their bodies stay in the engine. What is published is what a reader needs to judge the comparison: the harness calling the engine, and each kernel's declaration with the guarantees it is held to, down to the order a floating-point sum is taken in. Each contract is beside its race above; the harness lines together, and whatever no race showed, are here. The binaries run on request, and the scripts named below reproduce every number on this page.
the harness, calling the engine · neon-cpp/bench/bench_engine_options.cpp
// energy.h — what a process has used, as the operating system's own ledger has it: the energy it was billed,
// its processor time, the wake-ups it caused. The one reader of that ledger, for two questions:
// what a kernel costs — the Evals page's Energy view (bench_engine_options.cpp reads it around each kernel;
// tools/energy/energy.cpp checks the counter and reads it for a command it runs;
// bench/lang/python/yardstick.py reads the same field; PHD.md section 33)
// what a process costs at rest — the idle studies (scripts/idle_cost.sh and scripts/idle_server.py take
// `neon_energy --pid <pid>` twice and subtract; PHD.md section 31.1)
//
// macOS on Apple silicon: proc_pid_rusage(RUSAGE_INFO_V6). ri_energy_nj — nanojoules billed to the process's
// threads for the processor cores they ran on, since it started. Not the memory, the disk or the screen, and
// not the machine at rest: what running this code added. (Not ri_billed_energy: against half a second of a
// busy loop that field read 0.08 mJ where ri_energy_nj read 1,887.) Beside it, processor time in nanoseconds
// — `ps` has hundredths of a second, more than a resting window uses in a minute — and the wake-ups. No
// privilege is needed, and any process of the same user can be read, so a tree of processes can be summed.
// Linux: /proc/<pid>/stat and /proc/<pid>/status — clock ticks and context switches. No energy: RAPL is one
// figure for the whole machine and root's to read.
// Elsewhere: nothing is read (ok stays false).
//
// A reading is cumulative; a measurement is the difference of two. The counter moves in steps (a thread's
// share is settled when it leaves a core or enters the kernel), so a window should be a quarter of a second
// or more: `neon_energy --check` prints how far apart the steps are on the machine it runs on.
04 · Diligence
What both sides were held to
Same input, same answer. Every engine reads the same file and prints the same checks line: the filter count, the first sorted values, the group sums. A number enters the ledger only when the checks agree with the C++.
Timed the same way. A kernel is the best of three in one process; a load is the engine's typed read, best of two, with the first read of a fresh process kept separately. Engines that need a warm-up get it before the clock.
Energy is what the machine billed. Millijoules a run, read from the hardware counters for each engine's whole process tree, with the draw at rest subtracted for the seconds of the window.
The machine is named, and so is its load. Apple M5 Max, 18 cores, 26.4.1. The load average before each run is in the ledger, and a study taken on a shared machine says so beside its numbers.
Where Spark wins, it is shown winning. None of the 14 measurements on this page, and that is also a measurement.
The caveat on this comparison. Spark is a cluster engine run on one laptop, which is not what it is for. Its JVM and session start are excluded from every kernel, its materialisations go to the noop sink so every row is produced and none collected, and it was given 48 GB. These are the numbers a Spark user gets on one machine, not what a cluster does.
Scripts: scripts/bench_libraries.sh · measured 2026-10-11 · the numbers on this page come from the same ledger as the app's own Evals page, written by neon-cpp/scripts/results_md.py.