AI-generated solutions for the One Billion Row Challenge in multiple programming languages.
The easiest way to get the correct versions of all compilers/interpreters is to use Nix with flakes:
nix developThis will drop you into a shell with all the required tools at the correct versions.
If you prefer not to use Nix, install the following tools at these versions:
| Language | Tool | Version |
|---|---|---|
| Rust | rustc | 1.82.0 |
| Zig | zig | 0.13.0 |
| Nim | nim | 2.2.0 |
| OCaml | ocamlopt | 5.2.1 |
| Java | OpenJDK | 21.0.4 |
| C | gcc | 13.3.0 |
| C | clang | 16.0.6 |
| Clojure | clojure | 1.12.0.1479 |
| Jai | jai | beta 0.2.018 |
Not included in Nix (requires separate installation):
- Jai: beta 0.2.018 - Proprietary compiler, requires beta access from thekla.com
The solutions expect a sample.txt file at the repository root. To generate this file:
-
Clone the original 1BRC repository:
git clone https://github.com/gunnarmorling/1brc.git cd 1brc -
Follow their instructions to generate the measurements file:
./create_measurements.sh 1000000000
-
Important: The script creates
measurements.txt, but these solutions expectsample.txt. Rename or copy the file:cp measurements.txt /path/to/1brc-ai-results/sample.txt
Each language has normal, performant, and performance-aware variants in projects/<language>/.
cd projects/rust/normal
./build.sh # or: rustc -O main.rs -o main
./main ../../sample.txtcd projects/zig/normal
./build.sh # or: zig build-exe main.zig -O ReleaseFast -femit-bin=1brc
./1brc ../../sample.txtcd projects/nim/normal
nim c -d:release -o:main main.nim
./main ../../sample.txtcd projects/ocaml/normal
./build.sh # or: ocamlopt -O3 -o main str.cmxa main.ml
./main ../../sample.txtcd projects/java/normal
javac CalculateAverage.java
java CalculateAverage ../../sample.txtcd projects/c/normal
make # or: gcc -O2 -Wall -Wextra -std=c11 -o main main.c
./main ../../sample.txtcd projects/clojure/normal
clojure -M -m onebrc.core ../../sample.txtcd projects/jai/normal
jai main.jai
./main ../../sample.txtcd projects/red/normal
./run.sh ../../sample.txt