This directory contains the source code and compilation infrastructure for TPC benchmark
data generation tools. The compiled binaries are stored in _binaries/ for distribution.
_sources/
├── README.md # This file
├── compilation/ # Compilation infrastructure
│ ├── docker/ # Docker images for cross-compilation
│ │ ├── Dockerfile.linux-arm64
│ │ ├── Dockerfile.linux-x86_64
│ │ ├── Dockerfile.windows-arm64
│ │ └── Dockerfile.windows-x86_64
│ └── scripts/
│ └── compile-all-platforms.sh
├── tpc-h/ # TPC-H source (dbgen/qgen)
│ ├── EULA.txt # TPC EULA - must accept to use
│ ├── PATCHES.md # Documentation of applied patches
│ ├── stdout-support.patch # Patch for -z stdout output
│ ├── dbgen/ # Data generator source
│ └── ref_data/ # Reference data files
├── tpc-ds/ # TPC-DS source (dsdgen/dsqgen)
│ ├── EULA.txt # TPC EULA - must accept to use
│ ├── PATCHES.md # Documentation of applied patches
│ ├── stdout-support.patch # Patch for FILTER stdout output
│ ├── tools/ # Data/query generator source
│ ├── query_templates/ # SQL query templates
│ └── answer_sets/ # Reference answer sets
└── join-order-benchmark/ # JOB benchmark queries (git submodule)
The TPC source code is distributed under the TPC End User License Agreement (EULA). By using BenchBox with TPC benchmarks, you accept the TPC EULA terms.
- Visit https://www.tpc.org/tpc_documents_current_versions/current_specifications5.asp
- Select "TPC-H" from the benchmark list
- Download the "TPC-H Tools" package (requires free TPC account)
- Extract to
_sources/tpc-h/
The expected structure after extraction:
_sources/tpc-h/
├── EULA.txt
├── dbgen/
│ ├── bcd2.c
│ ├── bm_utils.c
│ ├── build.c
│ ├── config.h
│ ├── dists.dss
│ ├── driver.c
│ ├── dss.h
│ ├── makefile.suite
│ ├── print.c
│ ├── rnd.c
│ └── ... (other source files)
├── ref_data/
└── specification.pdf
- Visit https://www.tpc.org/tpc_documents_current_versions/current_specifications5.asp
- Select "TPC-DS" from the benchmark list
- Download the "TPC-DS Tools" package (requires free TPC account)
- Extract to
_sources/tpc-ds/
The expected structure after extraction:
_sources/tpc-ds/
├── EULA.txt
├── tools/
│ ├── address.c
│ ├── build_support.c
│ ├── config.h
│ ├── dsdgen.c
│ ├── genrand.c
│ ├── makefile
│ ├── Makefile.suite
│ ├── params.h
│ ├── porting.h
│ ├── print.c
│ ├── tpcds.dst
│ └── ... (other source files)
├── query_templates/
├── query_variants/
└── specification/
BenchBox includes patches that add features and fix compilation issues:
The stdout-support.patch adds a -z flag for streaming data to stdout:
cd _sources/tpc-h
patch -p1 < stdout-support.patchChanges applied:
- Adds
-zflag to stream generated data to stdout (enables piping to compression) - Fixes format specifier bug in money printing (
%ld→%d)
See _sources/tpc-h/PATCHES.md for detailed documentation.
The stdout-support.patch fixes the broken -FILTER Y flag and adds Linux compatibility:
cd _sources/tpc-ds
patch -p1 < stdout-support.patchChanges applied:
- Fixes
-FILTER Yflag for stdout output (was broken in upstream) - Adds
MAXINTdefinition for Linux builds - Adds
-fcommonflag for GCC 10+ compatibility
See _sources/tpc-ds/PATCHES.md for detailed documentation.
After applying patches, verify they were applied correctly:
grep -n "zstdout" _sources/tpc-h/dbgen/dss.h
grep -n '"FILTER"' _sources/tpc-ds/tools/params.hThe first command checks the TPC-H -z flag and should print EXTERN int zstdout;. The second checks the TPC-DS FILTER fix and should show "FILTER" without a leading underscore.
macOS (native compilation):
- Xcode Command Line Tools:
xcode-select --install - For cross-compilation:
brew install make(optional)
Linux/Windows (Docker-based):
- Docker: https://docs.docker.com/get-docker/
- Docker Buildx for multi-platform builds
For quick local development on Apple Silicon:
cd _sources/tpc-h/dbgen
make -f makefile.suite CC=clang MACHINE=LINUX DATABASE=ORACLE WORKLOAD=TPCH
cd _sources/tpc-ds/tools
make CC=clang CFLAGS="-O2 -DMACOS -DMAXINT=INT_MAX -fcommon"The TPC-H build produces dbgen and qgen. The TPC-DS build requires the patches to be applied first and produces dsdgen, dsqgen and distcomp.
The compile-all-platforms.sh script builds binaries for all supported platforms:
cd _sources/compilation/scripts
./compile-all-platforms.shSupported platforms:
| Platform | Architecture | Method |
|---|---|---|
| darwin | arm64 | Native (on Apple Silicon) |
| darwin | x86_64 | Cross-compilation |
| linux | x86_64 | Docker |
| linux | arm64 | Docker |
| windows | x86_64 | Docker + MinGW |
| windows | arm64 | Docker + MinGW |
Output location: _binaries/tpc-{h,ds}/{platform}-{arch}/
Build Docker images for cross-compilation:
docker build -f _sources/compilation/docker/Dockerfile.linux-x86_64 \
-t benchbox/tpc-linux-x86_64 _sources/compilation/docker/
docker build -f _sources/compilation/docker/Dockerfile.linux-arm64 \
-t benchbox/tpc-linux-arm64 _sources/compilation/docker/The first command builds the Linux x86_64 image and the second builds the Linux ARM64 image.
After compilation, verify binaries work correctly:
_binaries/tpc-h/darwin-arm64/dbgen -s 0.01 -f
ls -la *.tbl
_binaries/tpc-h/darwin-arm64/dbgen -z -s 0.01 -T c | head -5
_binaries/tpc-ds/darwin-arm64/dsdgen -SCALE 1 -TABLE ship_mode -DIR /tmp
cat /tmp/ship_mode.dat | head -5
_binaries/tpc-ds/darwin-arm64/dsdgen -SCALE 1 -TABLE ship_mode -FILTER Y | head -5The four checks run in order: TPC-H small dataset, TPC-H stdout mode (-z), TPC-DS small dataset, and TPC-DS stdout mode (-FILTER Y). The first should create customer.tbl, orders.tbl and the other TPC-H tables. The TPC-DS checks use -SCALE 1 because the bundled binaries require a scale factor of at least 1.
Bundled dsdgen binaries require scale factor >= 1. Fractional scale factors (e.g., 0.01)
cause segmentation faults in the bundled (unpatched) dsdgen binaries. This is a known upstream
limitation rooted in dist.c:dist_weight / scaling.c:LogScale (see _sources/tpcds-subscale-probe.md
for the Gate Zero analysis).
A patched dsdgen that fixes subscale generation ships with BenchBox (see the
patch-and-redistribute-tpcds-dsdgen-subscale-support TODO for history). SF<1 runs are
allowed by default for development use.
Unofficial subscale runs: SF<1 works out of the box with the bundled patched binaries.
Results are tagged compliance_class: unofficial_subscale; official TPC metrics are suppressed.
These results cannot be submitted (benchbox submit refuses them) and require
--label unofficial-research to publish. See benchbox/core/tpcds/compliance.py.
Generated data sizes at various scale factors:
| Benchmark | SF 0.01 | SF 1 | SF 10 | SF 100 |
|---|---|---|---|---|
| TPC-H | ~10 MB | ~1 GB | ~10 GB | ~100 GB |
| TPC-DS | N/A | ~1 GB | ~10 GB | ~100 GB |
Neither dbgen nor dsdgen are thread-safe for parallel generation of the same table.
Use the -C (chunks) and -S (step) flags for parallel generation:
for i in 1 2 3 4; do
dbgen -s 10 -C 4 -S $i -T c &
done
wait
cat customer.tbl.* > customer.tblThis generates the customer table in 4 parallel chunks and then concatenates them.
The _sources/ directory is structured for selective git tracking:
Tracked in git (included in releases):
_sources/compilation/- Docker configs and build scripts_sources/tpc-*/PATCHES.md- Patch documentation_sources/tpc-*/stdout-support.patch- Patch files_sources/tpc-ds/query_templates/- SQL templates
Tracked but can be refreshed from upstream:
_sources/tpc-h/dbgen/- TPC-H source code_sources/tpc-ds/tools/- TPC-DS source code_sources/tpc-*/EULA.txt- License files
NOT tracked (gitignored):
_sources/tpc-*/tools/*.o- Object files_sources/tpc-*/tools/tpcds.idx*- Generated index files_sources/join-order-benchmark/- Separate git repo
When a new TPC specification is released:
- Download new source from TPC website
- Extract over existing directory (preserving patches)
- Re-apply patches:
patch -p1 < stdout-support.patch - Verify patches applied: Check
PATCHES.mdverification commands - Recompile:
./compile-all-platforms.sh - Run tests:
uv run pytest tests/integration/test_tpc*.py - Update version references in documentation
Ensure patches are applied: patch -p1 < stdout-support.patch
Ensure -fcommon flag is in CFLAGS (handled by patch)
Stock dsdgen crashes at SF<1. BenchBox ships patched binaries that handle subscale generation
(see patch-and-redistribute-tpcds-dsdgen-subscale-support TODO for history); SF<1 runs are
allowed by default and tagged compliance_class: unofficial_subscale.
Patch not applied correctly. Re-apply: patch -p1 < stdout-support.patch
These distribution files must be in the same directory as the binary, or specified
via the -b flag (TPC-H) or environment (TPC-DS).
_binaries/README.md- Pre-compiled binary distributionAGENTS.md- Project architecture and conventionsbenchbox/core/tpch/- TPC-H benchmark implementationbenchbox/core/tpcds/- TPC-DS benchmark implementation