|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Build for current platform |
| 9 | +make |
| 10 | + |
| 11 | +# Build for all platforms (darwin/linux, amd64/arm64) |
| 12 | +make all |
| 13 | + |
| 14 | +# Build with InfluxDB support |
| 15 | +make TAGS=influx |
| 16 | + |
| 17 | +# Install locally (creates symlink to /usr/local/bin/pbench) |
| 18 | +make install |
| 19 | + |
| 20 | +# Generate cluster configurations from templates |
| 21 | +make clusters |
| 22 | +``` |
| 23 | + |
| 24 | +## Testing |
| 25 | + |
| 26 | +```bash |
| 27 | +# Run all tests |
| 28 | +go test ./... |
| 29 | + |
| 30 | +# Run a specific package's tests |
| 31 | +go test ./presto |
| 32 | +go test ./stage |
| 33 | +go test ./cmd/cmp |
| 34 | + |
| 35 | +# Run a single test |
| 36 | +go test ./presto -run TestQuerySplitter |
| 37 | +``` |
| 38 | + |
| 39 | +## Architecture |
| 40 | + |
| 41 | +PBench is a Presto/Trino benchmark runner built with Cobra CLI. It replaces Benchto with support for concurrent workloads, result capture, and query log collection. |
| 42 | + |
| 43 | +### Package Structure |
| 44 | + |
| 45 | +- **main.go** - Entry point, calls `cmd.Execute()` |
| 46 | +- **cmd/** - Cobra command definitions. Each subcommand has a wrapper file (e.g., `run.go`) and implementation package (e.g., `cmd/run/`) |
| 47 | +- **presto/** - Presto/Trino HTTP client implementation with query execution, session management, and result parsing |
| 48 | +- **stage/** - Core benchmark execution engine. A `Stage` defines queries, settings, and can chain to other stages via `next` field in JSON |
| 49 | +- **utils/** - Shared utilities including Presto flag handling and path helpers |
| 50 | +- **clusters/** - Cluster configuration templates and generated configs |
| 51 | +- **benchmarks/** - Benchmark definitions (TPC-DS, TPC-H, ClickBench, etc.) as JSON stage files and SQL queries |
| 52 | + |
| 53 | +### Key Concepts |
| 54 | + |
| 55 | +**Stages**: Benchmarks are defined as JSON files that specify queries (inline or via files), session parameters, catalog/schema, and execution settings. Stages form a DAG via `next` field, enabling sequential/parallel execution patterns. |
| 56 | + |
| 57 | +**Stage Settings** (inherited by child stages unless overridden): |
| 58 | +- `catalog`, `schema`, `timezone` - Presto session settings |
| 59 | +- `cold_runs`, `warm_runs` - Number of runs per query |
| 60 | +- `save_output`, `save_json`, `save_column_metadata` - Output capture options |
| 61 | +- `abort_on_error` - Stop on first failure |
| 62 | +- `random_execution`, `randomly_execute_until` - Random query selection mode |
| 63 | + |
| 64 | +**Run Recorders**: Results can be recorded to file (default), InfluxDB (requires `TAGS=influx` build), or MySQL. |
| 65 | + |
| 66 | +### Build Tags |
| 67 | + |
| 68 | +- `influx` - Enables InfluxDB run recorder support. Without this tag, `stage/no_influx.go` provides a stub that returns an error if InfluxDB config is provided. |
| 69 | + |
| 70 | +## Commands |
| 71 | + |
| 72 | +- `run` - Execute benchmarks from stage JSON files |
| 73 | +- `cmp` - Compare query results between two directories |
| 74 | +- `genconfig` - Generate cluster configs from templates |
| 75 | +- `genddl` - Generate DDL scripts |
| 76 | +- `loadjson` - Load query JSON files into databases |
| 77 | +- `replay` - Replay workloads from CSV |
| 78 | +- `forward` - Forward queries between Presto clusters |
| 79 | +- `save` - Save table schema/data information |
0 commit comments