language-bench

File processing › C

File processing C 16

gcc -O3 -march=native. Kernel time 146 ms on the average machine, index 1.01× vs the fastest (1.00×–1.02×), 1.4 MB average memory, 1.5 MB peak. Cold first iteration 147 ms, whole process 147 ms.

How this number came about

  1. The task. Before each iteration a fresh ~49 MB CSV file (id,word,value; 1,900,000 lines, a Zipf-like word distribution) is written to tmpfs, so the timed part measures reading and aggregating from memory, not disk speed. It streams the file once and returns the number of lines, the sum of the values, the number of distinct words and the most frequent word with its count. Every iteration gets a new, never reused instance from the deterministic generator lbgen (written to tmpfs as a CSV file before each iteration). 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.
  2. The environment. A fresh GitHub-hosted VM per session runs the pinned Docker image gcc@sha256:07280eb2e744f1b7a2d8d4a3894c089ea07266c109758afc388a634bd098e4eb containing gcc (GCC) 16.2.0. Hardware, kernel and glibc of every session are listed below.
  3. The source. Exactly this code (hash 09adc0b64bd809ca, 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 standard hash map: word counts live in a small open-addressing table of strdup'd keys. */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define CAP 32768

static char *keys[CAP];
static long counts[CAP];
static long distinct;
static const char *path;
static int64_t out[64];
static int nout;

static uint32_t hash(const char *s, size_t n) {
  uint32_t h = 2166136261u;
  for (size_t i = 0; i < n; i++) h = (h ^ (unsigned char)s[i]) * 16777619u;
  return h ^ (h >> 15) ^ (h >> 7); /* FNV-1a low bits are weak: fold the high bits in */
}

void lb_setup(int argc, char **argv) { (void)argc; (void)argv; }
void *lb_decode(const unsigned char *data, size_t len) { (void)len; path = (const char *)data; return (void *)data; }
void *lb_solve(void *inst) {
  (void)inst;
  memset(keys, 0, sizeof keys); memset(counts, 0, sizeof counts); distinct = 0;
  FILE *f = fopen(path, "r");
  setvbuf(f, NULL, _IOFBF, 1 << 16);
  char *line = NULL;
  size_t cap = 0;
  long lines = 0;
  long long total = 0;
  while (getline(&line, &cap, f) > 0) {
    char *c1 = strchr(line, ',');
    char *c2 = strchr(c1 + 1, ',');
    size_t wl = (size_t)(c2 - (c1 + 1));
    total += atoll(c2 + 1);
    uint32_t h = hash(c1 + 1, wl) & (CAP - 1);
    while (keys[h] && !(strlen(keys[h]) == wl && memcmp(keys[h], c1 + 1, wl) == 0)) h = (h + 1) & (CAP - 1);
    if (!keys[h]) { keys[h] = strndup(c1 + 1, wl); distinct++; }
    counts[h]++;
    lines++;
  }
  fclose(f);
  free(line);
  const char *top = NULL;
  long top_count = -1;
  for (int h = 0; h < CAP; h++) {
    if (!keys[h]) continue;
    if (counts[h] > top_count || (counts[h] == top_count && strcmp(keys[h], top) < 0)) { top = keys[h]; top_count = counts[h]; }
  }
  nout = 0;
  out[nout++] = lines; out[nout++] = total; out[nout++] = distinct; out[nout++] = top_count; out[nout++] = (int64_t)strlen(top);
  for (const char *p = top; *p; p++) out[nout++] = (unsigned char)*p;
  return out;
}
void lb_emit(void *res, void (*sink)(int64_t)) { int64_t *o = res; for (int i = 0; i < nout; i++) sink(o[i]); }
void lb_release(void *inst, void *res) { (void)inst; (void)res; for (int h = 0; h < CAP; h++) free(keys[h]); }
  1. Build and run.
    build
    gcc -O3 -march=native -ffp-contract=off -o /work/bin/c-16-gcc-O3-native-file-processing /repo/languages/c/harness/harness.c /repo/languages/c/impl/file-processing/main.c -lm -lpthread
    run
    /work/bin/c-16-gcc-O3-native-file-processing
    kernel loop
    The harness reads and decodes an instance (untimed), times only solve with 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
    hyperfine runs 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
    18 kB
  2. Many sessions, many iterations. The benchmark was measured in 3 independent sessions between 2026-10-27 and 2026-10-27, on 1 CPU model. 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).
152 ms155 ms159 ms162 ms166 ms2026-10-27 · AMD EPYC 7763 64-Core66 iterations · median 153 ms2026-10-27 · AMD EPYC 7763 64-Core64 iterations · median 158 ms2026-10-27 · AMD EPYC 7763 64-Core63 iterations · median 160 ms

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.

151 ms155 ms158 ms162 ms166 msiteration 1 (cold)last iteration
SessionCPUIterationsColdWarm medianEnd-to-endMachine factorWarm ÷ factorAvg. / peak memorySource
2026-10-27AMD EPYC 7763 64-Core Processor (4 cores)66153 ms153 ms157 ms1.058×145 ms1.5 MB / 1.5 MBActions run · raw data · commit
2026-10-27AMD EPYC 7763 64-Core Processor (4 cores)64158 ms158 ms156 ms1.076×147 ms1.5 MB / 1.5 MBActions run · raw data · commit
2026-10-27AMD EPYC 7763 64-Core Processor (4 cores)63161 ms160 ms160 ms1.090×147 ms1.1 MB / 1.5 MBActions 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.

  1. 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× (click a date in the table above for the session's details). Technically: we fit log(time) = benchmark + machine across all 8 sessions at once; see the methodology.
  2. Combining sessions. Sessions, not iterations, are the independent samples. Each session's warm median divided by its machine factor (145 ms, 147 ms, 147 ms) is averaged geometrically: 146 ms on the average machine (kernel (warm)). The 95% interval 145 ms–147 ms comes from a cluster bootstrap that resamples sessions, then iterations within each.
  3. Index vs fastest. 1.01× = this time ÷ the time of the fastest entry on the same problem, c 14 gcc-O3-native (145 ms); interval 1.00×–1.02×.
  4. How much was hardware? Raw session medians differ by a geometric factor of 1.024; after dividing out the machine factors they differ by 1.009. The overall model leaves 1.057× of unexplained noise.
  5. 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: 1.4 MB; the highest value seen was 1.5 MB.

Reproduce it

git clone https://github.com/StijnRis/language-bench.git && cd language-bench
pnpm install
pnpm lb verify c --version 16 --variant gcc-O3-native --problems file-processing

Needs 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.