This benchmark demonstrates hint-based write batching performance across different throughput levels.
The benchmark runs write operations at four different target throughput levels with corresponding batching hints:
- 1,000 ops/sec (baseline - no batching, batch:0)
- 10,000 ops/sec (low latency batching, batch:1)
- 100,000 ops/sec (moderate batching, batch:10)
- 1,000,000 ops/sec (aggressive batching, batch:100)
For each load level, it tracks:
- Batching window (ms)
- Actual throughput (ops/sec)
- Average latency (ms)
cd benchmarks/batching
go run main.goThis will:
- Run benchmarks at each load level (3 seconds each)
- Generate
bars_postgres.datandbars_mysql.datwith raw data - Generate
plot_bars.gnugnuplot script
Requires gnuplot:
# Install gnuplot (if needed)
# Ubuntu/Debian: apt install gnuplot
# macOS: brew install gnuplot
# Arch: pacman -S gnuplot
# Generate the graph
gnuplot plot_bars.gnuThis creates throughput_latency_comparison.png showing:
- Throughput (ops/sec) achieved at each target rate
- Latency (ms) for each batching configuration
- Side-by-side comparison of PostgreSQL and MariaDB
- No batching - immediate execution
- Lowest throughput baseline
- Lowest latency
- Demonstrates performance without batching overhead
- 1ms batching window
- Good balance of low latency and some batching benefits
- Minimal additional latency from batching
- 10ms batching window
- Significant batching efficiency gains
- Moderate latency increase
- Good for high-throughput scenarios
- 100ms batching window
- Maximum batching efficiency
- Higher latency but massive throughput gains
- Best for extreme write loads where latency is less critical
The graph shows hint-based batching performance:
- Throughput: How many ops/sec achieved at each target rate
- Latency: The trade-off in latency for batching gains
- Predictability: Consistent performance based on hint values
- Control: Explicit control over batching behavior per query
The benchmark uses these batching configurations:
| Target Rate | Batch Hint | Purpose |
|---|---|---|
| 1k ops/sec | batch:0 | Baseline (no batching) |
| 10k ops/sec | batch:1 | Low latency batching (1ms window) |
| 100k ops/sec | batch:10 | Moderate batching (10ms window) |
| 1M ops/sec | batch:100 | Aggressive batching (100ms window) |
Config{
MaxBatchSize: 1000, // Maximum operations per batch
}bars_postgres.dat- PostgreSQL performance databars_mysql.dat- MariaDB performance dataplot_bars.gnu- Gnuplot script for visualizationthroughput_latency_comparison.png- Visual graph (after running gnuplot)
The graph shows two panels (PostgreSQL and MariaDB), each displaying:
Blue bars: Throughput (k ops/sec) - actual achieved rate
Red bars: Latency (ms) - average latency per operation
X-axis labels show the target rates (1k, 10k, 100k, 1M) with their corresponding batch hints, making it easy to see the latency/throughput trade-off at each level.