j
jaipkg.dev
packages / library / 1brc-ai-results

1brc-ai-results

bab8932library

No description provided.

No license · updated 7 months ago

1BRC AI Results

AI-generated solutions for the One Billion Row Challenge in multiple programming languages.

Setup

Using Nix (Recommended)

The easiest way to get the correct versions of all compilers/interpreters is to use Nix with flakes:

nix develop

This will drop you into a shell with all the required tools at the correct versions.

Manual Installation

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

Creating the Input File

The solutions expect a sample.txt file at the repository root. To generate this file:

  1. Clone the original 1BRC repository:

    git clone https://github.com/gunnarmorling/1brc.git
    cd 1brc
  2. Follow their instructions to generate the measurements file:

    ./create_measurements.sh 1000000000
  3. Important: The script creates measurements.txt, but these solutions expect sample.txt. Rename or copy the file:

    cp measurements.txt /path/to/1brc-ai-results/sample.txt

Building and Running

Each language has normal, performant, and performance-aware variants in projects/<language>/.

Rust

cd projects/rust/normal
./build.sh        # or: rustc -O main.rs -o main
./main ../../sample.txt

Zig

cd projects/zig/normal
./build.sh        # or: zig build-exe main.zig -O ReleaseFast -femit-bin=1brc
./1brc ../../sample.txt

Nim

cd projects/nim/normal
nim c -d:release -o:main main.nim
./main ../../sample.txt

OCaml

cd projects/ocaml/normal
./build.sh        # or: ocamlopt -O3 -o main str.cmxa main.ml
./main ../../sample.txt

Java

cd projects/java/normal
javac CalculateAverage.java
java CalculateAverage ../../sample.txt

C

cd projects/c/normal
make              # or: gcc -O2 -Wall -Wextra -std=c11 -o main main.c
./main ../../sample.txt

Clojure

cd projects/clojure/normal
clojure -M -m onebrc.core ../../sample.txt

Jai

cd projects/jai/normal
jai main.jai
./main ../../sample.txt

Red

cd projects/red/normal
./run.sh ../../sample.txt