Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,14 @@ Test categories: `ddl/`, `dml/`, `queries/`, `types/`, `errors/`, `edge_cases/`,
- Use `--release` mode for Raft cluster tests (timing sensitive)
- Direct I/O requires 4KB-aligned buffers (`AlignedBuffer::page()` or `AlignedBuffer::pages()`)
- Debug protocol: update wrapper scripts in `/tmp/*.sh`, re-run to minimize prompts

## Benchmarking

- **Always run ALL workloads** — never filter to a single workload. Run the full A/B comparison every time.
- Command: `bench/run.sh --table-size=100000 --duration=30`
- After benchmarks complete, show a comparison table of ALL workload results (before vs after, RooDB vs MySQL).
- Use `bench/compare.sh` to compare against baseline when available.

## Code Policies

- `#[allow(dead_code)]` markers are banned — do not use them
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ sqlparser = { version = "0.50", features = ["visitor"] }
# Ordered floats for sorting
ordered-float = "4.2"

# LRU cache for block cache
lru = "0.12"

# MySQL protocol support
sha1 = "0.10"
rand = "0.8"
Expand Down
1 change: 1 addition & 0 deletions bench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/*.json
118 changes: 118 additions & 0 deletions bench/compare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env bash
#
# Compare two RooDB benchmark result files
#
# Usage: bench/compare.sh results/run1.json results/run2.json

set -euo pipefail

if [ $# -ne 2 ]; then
echo "Usage: $0 <result1.json> <result2.json>"
exit 1
fi

FILE1="$1"
FILE2="$2"

if ! command -v jq &>/dev/null; then
echo "ERROR: jq not found. Please install it."
exit 1
fi

if [ ! -f "$FILE1" ]; then
echo "ERROR: File not found: $FILE1"
exit 1
fi
if [ ! -f "$FILE2" ]; then
echo "ERROR: File not found: $FILE2"
exit 1
fi

# Header
echo "========================================"
echo " Benchmark Comparison"
echo "========================================"
echo ""
echo "Run 1: $FILE1"
echo " Commit: $(jq -r '.git_commit' "$FILE1") Branch: $(jq -r '.git_branch' "$FILE1")"
echo " Time: $(jq -r '.timestamp' "$FILE1")"
echo ""
echo "Run 2: $FILE2"
echo " Commit: $(jq -r '.git_commit' "$FILE2") Branch: $(jq -r '.git_branch' "$FILE2")"
echo " Time: $(jq -r '.timestamp' "$FILE2")"
echo ""

# Get workloads present in both files
WORKLOADS=$(jq -r '.workloads | keys[]' "$FILE1" | sort)

for wl in $WORKLOADS; do
# Check if workload exists in both files
if ! jq -e ".workloads[\"$wl\"]" "$FILE2" >/dev/null 2>&1; then
continue
fi

# For each target (mysql, roodb)
for target in mysql roodb; do
if ! jq -e ".workloads[\"$wl\"][\"$target\"]" "$FILE1" >/dev/null 2>&1; then
continue
fi
if ! jq -e ".workloads[\"$wl\"][\"$target\"]" "$FILE2" >/dev/null 2>&1; then
continue
fi

# Check for errors
err1=$(jq -r ".workloads[\"$wl\"][\"$target\"].error // empty" "$FILE1")
err2=$(jq -r ".workloads[\"$wl\"][\"$target\"].error // empty" "$FILE2")
if [ -n "$err1" ] || [ -n "$err2" ]; then
echo "Workload: $wl ($target) - skipped (error in one or both runs)"
continue
fi

echo "Workload: $wl ($target)"
printf "%-20s %12s %12s %12s\n" "" "Run 1" "Run 2" "Delta"
printf "%-20s %12s %12s %12s\n" "---" "---" "---" "---"

for metric in tps latency_avg_ms latency_p95_ms latency_p99_ms errors; do
v1=$(jq -r ".workloads[\"$wl\"][\"$target\"].$metric // 0" "$FILE1")
v2=$(jq -r ".workloads[\"$wl\"][\"$target\"].$metric // 0" "$FILE2")

# Compute delta
if [ "$metric" = "errors" ]; then
v1_int=${v1%.*}
v2_int=${v2%.*}
if [ "$v1_int" -eq 0 ] && [ "$v2_int" -eq 0 ]; then
delta="-"
else
delta="$((v2_int - v1_int))"
fi
else
if command -v bc &>/dev/null && [ "$(echo "$v1 > 0" | bc -l 2>/dev/null)" = "1" ]; then
pct=$(echo "scale=1; ($v2 - $v1) * 100 / $v1" | bc -l 2>/dev/null || echo "n/a")
if [ "$pct" != "n/a" ]; then
# Add + prefix for positive
if echo "$pct" | grep -qv "^-"; then
pct="+${pct}"
fi
delta="${pct}%"
else
delta="n/a"
fi
else
delta="n/a"
fi
fi

# Label
case "$metric" in
tps) label="TPS" ;;
latency_avg_ms) label="Avg Latency (ms)" ;;
latency_p95_ms) label="P95 Latency (ms)" ;;
latency_p99_ms) label="P99 Latency (ms)" ;;
errors) label="Errors" ;;
esac

printf "%-20s %12s %12s %12s\n" "$label" "$v1" "$v2" "$delta"
done
echo ""
done
done
Empty file added bench/results/.gitkeep
Empty file.
Loading