language-bench

JSON parsing › Go

JSON parsing Go 1.27

GOAMD64=v3 go build. Kernel time 574 ms on the average machine, index 29.3× vs the fastest (27.1×–31.7×), 203 MB average memory, 266 MB peak. Cold first iteration 622 ms, whole process 641 ms.

How this number came about

  1. 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.
  2. The environment. A fresh GitHub-hosted VM per session runs the pinned Docker image golang@sha256:9048d5e7751706200eb1719c7dae0436950d362f29a1da91fa05e5c63867c60f containing go version go1.27.3 linux/amd64. Hardware, kernel and glibc of every session are listed below.
  3. The source. Exactly this code (hash 34702d9543ad79fa, 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:
package main

import "encoding/json"

var objects, trues, nulls, strLen int64
var intSum float64

func walk(v any) {
	switch t := v.(type) {
	case nil:
		nulls++
	case bool:
		if t {
			trues++
		}
	case float64:
		intSum += t
	case string:
		strLen += int64(len(t))
	case []any:
		for _, x := range t {
			walk(x)
		}
	case map[string]any:
		objects++
		for _, x := range t {
			walk(x)
		}
	}
}

func Setup(args []string) {}

func Decode(data []byte) any { return data }

func Solve(inst any) any {
	objects, trues, nulls, strLen, intSum = 0, 0, 0, 0, 0
	var doc any
	if err := json.Unmarshal(inst.([]byte), &doc); err != nil {
		panic(err)
	}
	walk(doc)
	return []int64{objects, int64(intSum), strLen, trues, nulls}
}

func Emit(res any, sink func(int64)) {
	for _, v := range res.([]int64) {
		sink(v)
	}
}
  1. Build and run.
    build
    mkdir -p /work/bin/go-1.27-go-amd64-v3-json-parse.d && cp /repo/languages/go/harness/harness.go /work/bin/go-1.27-go-amd64-v3-json-parse.d/harness.go && cp /repo/languages/go/impl/json-parse/main.go /work/bin/go-1.27-go-amd64-v3-json-parse.d/problem.go && GOAMD64=v3 go build -o /work/bin/go-1.27-go-amd64-v3-json-parse /work/bin/go-1.27-go-amd64-v3-json-parse.d/harness.go /work/bin/go-1.27-go-amd64-v3-json-parse.d/problem.go
    run
    /work/bin/go-1.27-go-amd64-v3-json-parse
    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
    4.3 MB
  2. 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).
440 ms507 ms574 ms641 ms709 ms2026-10-27 · AMD EPYC 9V74 80-Core21 iterations · median 470 ms2026-10-27 · AMD EPYC 7763 64-Core15 iterations · median 670 ms2026-10-27 · AMD EPYC 7763 64-Core15 iterations · median 668 ms2026-10-27 · AMD EPYC 9V74 80-Core21 iterations · median 471 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.

436 ms498 ms568 ms649 ms741 msiteration 1 (cold)last iteration
SessionCPUIterationsColdWarm medianEnd-to-endMachine factorWarm ÷ factorAvg. / peak memorySource
2026-10-27AMD EPYC 9V74 80-Core Processor (4 cores)21517 ms470 ms536 ms0.890×528 ms200 MB / 265 MBActions run · raw data · commit
2026-10-27AMD EPYC 7763 64-Core Processor (4 cores)15714 ms670 ms730 ms1.068×627 ms197 MB / 266 MBActions run · raw data · commit
2026-10-27AMD EPYC 7763 64-Core Processor (4 cores)15713 ms668 ms731 ms1.090×612 ms204 MB / 265 MBActions run · raw data · commit
2026-10-27AMD EPYC 9V74 80-Core Processor (4 cores)21520 ms471 ms539 ms0.880×535 ms211 MB / 261 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 0.890×, 1.068×, 1.090×, 0.880× (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 (528 ms, 627 ms, 612 ms, 535 ms) is averaged geometrically: 574 ms on the average machine (kernel (warm)). The 95% interval 532 ms–620 ms comes from a cluster bootstrap that resamples sessions, then iterations within each.
  3. Index vs fastest. 29.3× = this time ÷ the time of the fastest entry on the same problem, c 16 gcc-O3-native (19.6 ms); interval 27.1×–31.7×.
  4. How much was hardware? Raw session medians differ by a geometric factor of 1.225; after dividing out the machine factors they differ by 1.093. 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: 203 MB; the highest value seen was 266 MB.

Reproduce it

git clone https://github.com/StijnRis/language-bench.git && cd language-bench
pnpm install
pnpm lb verify go --version 1.27 --variant go-amd64-v3 --problems json-parse

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.