|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with the benchmark directory in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The `benchmark/` directory contains comprehensive benchmarking infrastructure for comparing Feldera's performance against other stream processing systems. It implements industry-standard benchmarks (NEXMark, TPC-H, TikTok) across multiple platforms to provide objective performance comparisons. |
| 8 | + |
| 9 | +## Benchmark Ecosystem |
| 10 | + |
| 11 | +### Supported Systems |
| 12 | + |
| 13 | +The benchmarking framework supports comparative analysis across: |
| 14 | + |
| 15 | +- **Feldera** - Both Rust-native and SQL implementations |
| 16 | +- **Apache Flink** - Standalone and Kafka-integrated configurations |
| 17 | +- **Apache Beam** - Multiple runners: |
| 18 | + - Direct runner (development/testing) |
| 19 | + - Flink runner |
| 20 | + - Spark runner |
| 21 | + - Google Cloud Dataflow runner |
| 22 | + |
| 23 | +### Benchmark Suites |
| 24 | + |
| 25 | +#### **NEXMark Benchmark** |
| 26 | +- **Industry Standard**: Streaming benchmark for auction data processing |
| 27 | +- **22 Queries**: Complete suite of streaming analytics queries (q0-q22) |
| 28 | +- **Realistic Data**: Auction, bidder, and seller event generation |
| 29 | +- **Multiple Modes**: Streaming and batch processing modes |
| 30 | + |
| 31 | +#### **TPC-H Benchmark** |
| 32 | +- **OLAP Standard**: Traditional analytical processing benchmark |
| 33 | +- **22 Queries**: Complex analytical queries for business intelligence |
| 34 | +- **Batch Processing**: Focus on analytical query performance |
| 35 | + |
| 36 | +#### **TikTok Benchmark** |
| 37 | +- **Custom Workload**: Social media analytics patterns |
| 38 | +- **Streaming Focus**: Real-time social media data processing |
| 39 | + |
| 40 | +## Key Development Commands |
| 41 | + |
| 42 | +### Running Individual Benchmarks |
| 43 | + |
| 44 | +```bash |
| 45 | +# Basic Feldera benchmark |
| 46 | +./run-nexmark.sh --runner=feldera --events=100M |
| 47 | + |
| 48 | +# Compare Feldera vs Flink |
| 49 | +./run-nexmark.sh --runner=flink --events=100M |
| 50 | + |
| 51 | +# SQL implementation on Feldera |
| 52 | +./run-nexmark.sh --runner=feldera --language=sql |
| 53 | + |
| 54 | +# Batch processing mode |
| 55 | +./run-nexmark.sh --batch --events=100M |
| 56 | + |
| 57 | +# Specific query testing |
| 58 | +./run-nexmark.sh --query=q3 --runner=feldera |
| 59 | + |
| 60 | +# Core count specification |
| 61 | +./run-nexmark.sh --cores=8 --runner=feldera |
| 62 | +``` |
| 63 | + |
| 64 | +### Running Benchmark Suites |
| 65 | + |
| 66 | +```bash |
| 67 | +# Full benchmark suite using Makefile |
| 68 | +make -f suite.mk |
| 69 | + |
| 70 | +# Limited runners and modes |
| 71 | +make -f suite.mk runners='feldera flink' modes=batch events=1M |
| 72 | + |
| 73 | +# Specific configuration |
| 74 | +make -f suite.mk runners=feldera events=100M cores=16 |
| 75 | +``` |
| 76 | + |
| 77 | +### Analysis and Results |
| 78 | + |
| 79 | +```bash |
| 80 | +# Generate analysis (requires PSPP/SPSS) |
| 81 | +pspp analysis.sps |
| 82 | + |
| 83 | +# View results in CSV format |
| 84 | +cat nexmark.csv |
| 85 | +``` |
| 86 | + |
| 87 | +## Project Structure |
| 88 | + |
| 89 | +### Core Scripts |
| 90 | +- `run-nexmark.sh` - Main benchmark execution script |
| 91 | +- `suite.mk` - Makefile for running comprehensive benchmark suites |
| 92 | +- `analysis.sps` - SPSS/PSPP script for statistical analysis |
| 93 | + |
| 94 | +### Implementation Directories |
| 95 | + |
| 96 | +#### `feldera-sql/` |
| 97 | +- **SQL Benchmarks**: Pure SQL implementations of benchmark queries |
| 98 | +- **Pipeline Management**: Integration with Feldera's pipeline manager |
| 99 | +- **Query Definitions**: Standard benchmark queries in SQL format |
| 100 | +- **Table Schemas**: Database schema definitions for benchmarks |
| 101 | + |
| 102 | +#### `flink/` & `flink-kafka/` |
| 103 | +- **Flink Integration**: Standalone and Kafka-integrated Flink setups |
| 104 | +- **Docker Containers**: Containerized Flink environments |
| 105 | +- **Configuration**: Flink-specific performance tuning configurations |
| 106 | +- **NEXMark Implementation**: Java-based NEXMark implementation |
| 107 | + |
| 108 | +#### `beam/` |
| 109 | +- **Apache Beam**: Multi-runner Beam implementations |
| 110 | +- **Language Support**: Java, SQL (Calcite), and ZetaSQL implementations |
| 111 | +- **Cloud Integration**: Google Cloud Dataflow configuration |
| 112 | +- **Setup Scripts**: Environment preparation and dependency management |
| 113 | + |
| 114 | +## Important Implementation Details |
| 115 | + |
| 116 | +### Performance Optimization |
| 117 | + |
| 118 | +#### **Feldera Optimizations** |
| 119 | +- **Storage Configuration**: Uses `/tmp` by default, configure `TMPDIR` for real filesystem |
| 120 | +- **Multi-threading**: Automatic core detection with 16-core maximum default |
| 121 | +- **Memory Management**: Efficient incremental computation with minimal memory overhead |
| 122 | + |
| 123 | +#### **System-Specific Tuning** |
| 124 | +- **Flink**: RocksDB and HashMap state backends available |
| 125 | +- **Beam**: Multiple language implementations (Java, SQL, ZetaSQL) |
| 126 | +- **Cloud**: Optimized configurations for cloud deployments |
| 127 | + |
| 128 | +### Benchmark Modes |
| 129 | + |
| 130 | +#### **Streaming Mode (Default)** |
| 131 | +- **Real-time Processing**: Continuous data processing simulation |
| 132 | +- **Incremental Results**: Measure throughput and latency |
| 133 | +- **Event Generation**: Configurable event rates and patterns |
| 134 | + |
| 135 | +#### **Batch Mode** |
| 136 | +- **Analytical Processing**: Traditional batch analytics |
| 137 | +- **Complete Data**: Process entire datasets at once |
| 138 | +- **Throughput Focus**: Optimized for maximum data processing rates |
| 139 | + |
| 140 | +### Data Generation |
| 141 | + |
| 142 | +- **Configurable Scale**: From 100K to 100M+ events |
| 143 | +- **Realistic Patterns**: Auction data with realistic distributions |
| 144 | +- **Reproducible**: Deterministic data generation for consistent comparisons |
| 145 | + |
| 146 | +## Development Workflow |
| 147 | + |
| 148 | +### For New Benchmarks |
| 149 | + |
| 150 | +1. Add query definitions to appropriate `benchmarks/*/queries/` directory |
| 151 | +2. Update table schemas in `table.sql` files |
| 152 | +3. Implement runner-specific logic in system directories |
| 153 | +4. Add query to `run-nexmark.sh` query list |
| 154 | +5. Test across multiple systems for consistency |
| 155 | + |
| 156 | +### For System Integration |
| 157 | + |
| 158 | +1. Create system-specific directory (e.g., `newsystem/`) |
| 159 | +2. Implement setup and configuration scripts |
| 160 | +3. Add runner option to `run-nexmark.sh` |
| 161 | +4. Update `suite.mk` runner list |
| 162 | +5. Document setup requirements |
| 163 | + |
| 164 | +### Testing Strategy |
| 165 | + |
| 166 | +#### **Correctness Validation** |
| 167 | +- **Cross-System Consistency**: Results should match across systems |
| 168 | +- **Query Verification**: Validate SQL semantics and outputs |
| 169 | +- **Edge Case Testing**: Test with various data sizes and patterns |
| 170 | + |
| 171 | +#### **Performance Analysis** |
| 172 | +- **Throughput Measurement**: Events processed per second |
| 173 | +- **Latency Analysis**: End-to-end processing delays |
| 174 | +- **Resource Usage**: CPU, memory, and I/O utilization |
| 175 | +- **Scalability Testing**: Performance across different core counts |
| 176 | + |
| 177 | +### Configuration Management |
| 178 | + |
| 179 | +#### **Environment Variables** |
| 180 | +- `TMPDIR` - Storage location for temporary files |
| 181 | +- `FELDERA_API_URL` - Pipeline manager endpoint (default: localhost:8080) |
| 182 | +- Cloud credentials for Dataflow benchmarks |
| 183 | + |
| 184 | +#### **System Requirements** |
| 185 | +- **Java 11+** - Required for Beam and Flink |
| 186 | +- **Docker** - For containerized system testing |
| 187 | +- **Python 3** - For analysis scripts |
| 188 | +- **Cloud SDK** - For Google Cloud Dataflow testing |
| 189 | + |
| 190 | +### Results Analysis |
| 191 | + |
| 192 | +#### **Statistical Analysis** |
| 193 | +- **PSPP Integration**: Statistical analysis with `analysis.sps` |
| 194 | +- **Performance Tables**: Formatted comparison tables |
| 195 | +- **Trend Analysis**: Performance trends across system configurations |
| 196 | + |
| 197 | +#### **Output Formats** |
| 198 | +- **CSV Results**: Machine-readable performance data |
| 199 | +- **Formatted Tables**: Human-readable comparison tables |
| 200 | +- **Statistical Reports**: Detailed statistical analysis |
| 201 | + |
| 202 | +## Best Practices |
| 203 | + |
| 204 | +### Benchmark Execution |
| 205 | +- **Warm-up Runs**: Allow systems to reach steady state |
| 206 | +- **Multiple Iterations**: Run benchmarks multiple times for statistical significance |
| 207 | +- **Resource Isolation**: Ensure consistent resource availability |
| 208 | +- **Environment Control**: Use consistent hardware and software configurations |
| 209 | + |
| 210 | +### Performance Comparison |
| 211 | +- **Fair Comparison**: Use equivalent configurations across systems |
| 212 | +- **Resource Limits**: Apply consistent memory and CPU limits |
| 213 | +- **Data Consistency**: Use identical datasets across systems |
| 214 | +- **Metric Standardization**: Use consistent performance metrics |
| 215 | + |
| 216 | +### System Setup |
| 217 | +- **Documentation**: Follow setup instructions for each system |
| 218 | +- **Version Control**: Pin specific versions for reproducible results |
| 219 | +- **Configuration**: Use optimized configurations for each system |
| 220 | +- **Monitoring**: Monitor resource usage during benchmarks |
| 221 | + |
| 222 | +This benchmarking infrastructure provides comprehensive tools for validating Feldera's performance advantages and identifying optimization opportunities across different workloads and system configurations. |
0 commit comments