JSON parsing C 15
gcc -O2. Kernel time 23.9 ms on the average machine, index 1.22× vs the fastest (1.20×–1.24×), 20.4 MB average memory, 20.4 MB peak. Cold first iteration 24.2 ms, whole process 41.1 ms.
How this number came about
- The task. Each iteration receives a different ~19 MB ASCII JSON document of 90,000 records (padded with whitespace to a fixed length) as raw bytes. The timed part parses it and walks the document, returning the number of objects, the sum of all integers, the total length of all string values, and the numbers of true and null values. Every iteration gets a new, never reused instance from the deterministic generator lbgen (streamed to the program on standard input). A separate check compares an order-sensitive hash of the complete result of 20 iterations with the generator's reference; this was the case in every session.
- The environment. A fresh GitHub-hosted VM per session runs the pinned Docker image
gcc@sha256:dc99c5016a0fb74d4e9a392e7892966ec7f358af744799bd3479239598f79d45containinggcc (GCC) 15.3.0. Hardware, kernel and glibc of every session are listed below. - The source. Exactly this code (hash
29eb1b7b35028c11, in git at the commit of each session) is the kernel: it only decodes the instance and solves it. It is built together with the language's one harness, which owns the clock, the loop and the output:
/* C has no JSON parser in its standard library: a small recursive-descent parser that aggregates
* while parsing (it does not build a tree). */
#include <stdint.h>
#include <stdlib.h>
static const unsigned char *s;
static size_t i;
static long objects, str_len, trues, nulls;
static long long int_sum;
static void ws(void) {
while (s[i] == ' ' || s[i] == '\n' || s[i] == '\r' || s[i] == '\t') i++;
}
static long string(void) {
long n = 0;
i++;
for (;;) {
unsigned char c = s[i];
if (c == '"') {
i++;
return n;
}
if (c == '\\') {
i += (s[i + 1] == 'u') ? 6 : 2;
} else {
i++;
}
n++;
}
}
static void value(void) {
ws();
switch (s[i]) {
case '{':
objects++;
i++;
ws();
if (s[i] == '}') {
i++;
return;
}
for (;;) {
ws();
string();
ws();
i++; /* ':' */
value();
ws();
if (s[i++] == '}') return;
}
case '[':
i++;
ws();
if (s[i] == ']') {
i++;
return;
}
for (;;) {
value();
ws();
if (s[i++] == ']') return;
}
case '"':
str_len += string();
return;
case 't':
trues++;
i += 4;
return;
case 'f':
i += 5;
return;
case 'n':
nulls++;
i += 4;
return;
default: {
int neg = s[i] == '-';
if (neg) i++;
long long v = 0;
while (s[i] >= '0' && s[i] <= '9') v = v * 10 + (s[i++] - '0');
int_sum += neg ? -v : v;
}
}
}
static int64_t out[5];
void lb_setup(int argc, char **argv) { (void)argc; (void)argv; }
void *lb_decode(const unsigned char *data, size_t len) { (void)len; s = data; return (void *)data; }
void *lb_solve(void *inst) {
(void)inst;
i = 0; objects = str_len = trues = nulls = 0; int_sum = 0;
value();
out[0] = objects; out[1] = int_sum; out[2] = str_len; out[3] = trues; out[4] = nulls;
return out;
}
void lb_emit(void *res, void (*sink)(int64_t)) { int64_t *o = res; for (int k = 0; k < 5; k++) sink(o[k]); }
void lb_release(void *inst, void *res) { (void)inst; (void)res; }
- Build and run.
- build
gcc -O2 -ffp-contract=off -o /work/bin/c-15-gcc-O2-json-parse /repo/languages/c/harness/harness.c /repo/languages/c/impl/json-parse/main.c -lm -lpthread- run
/work/bin/c-15-gcc-O2-json-parse- kernel loop
- The harness reads and decodes an instance (untimed), times only
solvewith the language's monotonic clock, and repeats until the summed kernel time reaches 10 s (at least 3 iterations, no other cap). The first iteration is the cold time; the warm time is the median of the iterations after the first 2 s of kernel time. Memory is read from the container's cgroup by a sampler outside the process. - end-to-end
hyperfineruns the same binary for exactly one iteration (process start to exit, with the instance read from a file) and records wall-clock time and peak resident memory; reported next to the kernel time.- binary size
- 21 kB
- Many sessions, many iterations. The benchmark was measured in 4 independent sessions between 2026-10-27 and 2026-10-27, on 2 CPU models. Within a session the execution order of all benchmarks was randomised. Each dot below is one warm kernel iteration (at most 100 evenly spaced ones per session are shown); the black bar is the session median; orange dots are flagged outliers (kept in the data).
Warm-up curve
Kernel time of every iteration in order, one line per session (log axis; orange dot: the cold first iteration). Just-in-time and garbage-collected runtimes need a while to settle; compiled languages are flat from the start.
| Session | CPU | Iterations | Cold | Warm median | End-to-end | Machine factor | Warm ÷ factor | Avg. / peak memory | Source |
|---|---|---|---|---|---|---|---|---|---|
| 2026-10-27 | AMD EPYC 7763 64-Core Processor (4 cores) | 385 | 26.7 ms | 25.8 ms | 43.5 ms | 1.058× | 24.4 ms | 20.4 MB / 20.4 MB | Actions run · raw data · commit |
| 2026-10-27 | AMD EPYC 7763 64-Core Processor (4 cores) | 386 | 27.1 ms | 25.8 ms | 43.4 ms | 1.076× | 24.0 ms | 20.4 MB / 20.4 MB | Actions run · raw data · commit |
| 2026-10-27 | AMD EPYC 7763 64-Core Processor (4 cores) | 386 | 25.5 ms | 25.9 ms | 45.1 ms | 1.090× | 23.7 ms | 20.4 MB / 20.4 MB | Actions run · raw data · commit |
| 2026-10-27 | AMD EPYC 9V74 80-Core Processor (4 cores) | 482 | 20.4 ms | 20.7 ms | 36.7 ms | 0.880× | 23.5 ms | 20.4 MB / 20.4 MB | Actions run · raw data · commit |
The table is computed from the raw values: download every iteration and repetition of this benchmark (CSV), or the complete session files linked above. Each “Warm median” is the median of the kernel iterations after the first 2 s; “÷ factor” divides it by the machine factor.
- Cancelling out the hardware. GitHub gives every session a different computer, and some are faster than others, so raw times from different sessions cannot be compared directly. To fix that, every session gets a machine factor: how many times longer programs take on that machine than on the average machine. A factor of 1.2 means “20% slower than average”. We find these factors by looking at benchmarks that ran in several sessions: if the same programs are consistently 20% slower in one session, that machine is 1.2× slower. The factors for this benchmark's sessions are 1.058×, 1.076×, 1.090×, 0.880× (click a date in the table above for the session's details). Technically: we fit
log(time) = benchmark + machineacross all 8 sessions at once; see the methodology. - Combining sessions. Sessions, not iterations, are the independent samples. Each session's warm median divided by its machine factor (24.4 ms, 24.0 ms, 23.7 ms, 23.5 ms) is averaged geometrically: 23.9 ms on the average machine (kernel (warm)). The 95% interval 23.6 ms–24.3 ms comes from a cluster bootstrap that resamples sessions, then iterations within each.
- Index vs fastest. 1.22× = this time ÷ the time of the fastest entry on the same problem, c 16 gcc-O3-native (19.6 ms); interval 1.20×–1.24×.
- How much was hardware? Raw session medians differ by a geometric factor of 1.118; after dividing out the machine factors they differ by 1.017. The overall model leaves 1.057× of unexplained noise.
- Memory. A sampler on the host reads the anonymous memory of the container's cgroup every few milliseconds. The average is weighted by time over the timed kernel regions only (instance generation and decoding excluded), then averaged over sessions: 20.4 MB; the highest value seen was 20.4 MB.
Reproduce it
git clone https://github.com/StijnRis/language-bench.git && cd language-bench
pnpm install
pnpm lb verify c --version 15 --variant gcc-O2 --problems json-parseNeeds Docker. The command builds the harness and the program in the pinned image and checks the result against the generator's reference; the full timed measurement runs in CI sessions. The parameters of the problem are none.