Files
weaseldb/reproduce_threading_report.sh

90 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Reproduce the threading performance report results.
# Run from the project root, e.g.:
# ./reproduce_threading_report.sh
set -euo pipefail
BUILD_DIR="build"
CONFIG="test_benchmark_config.toml"
DURATION=120
if [ ! -d "$BUILD_DIR" ]; then
echo "Error: build directory '$BUILD_DIR' not found. Build the project first." >&2
exit 1
fi
if [ ! -f "$CONFIG" ]; then
echo "Error: config '$CONFIG' not found. Run this script from the project root." >&2
exit 1
fi
if [ ! -x "$BUILD_DIR/weaseldb" ] || [ ! -x "$BUILD_DIR/load_tester" ]; then
echo "Error: required binaries not found in '$BUILD_DIR'. Build the project first." >&2
exit 1
fi
cd "$BUILD_DIR"
# Increase file descriptor limit for high concurrency. Best-effort only:
# it may fail if the hard limit is lower, especially in containers.
ulimit -n 65536 2>/dev/null || echo "Warning: could not raise ulimit -n (continuing)" >&2
# Clean up any leftover socket or server log from a previous run
rm -f weaseldb.sock server.log
SERVER_PID=""
cleanup() {
if [ -n "$SERVER_PID" ] && kill -0 "$SERVER_PID" 2>/dev/null; then
echo ""
echo "=== Stopping server ==="
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
echo "=== Server log tail ==="
tail -50 server.log 2>/dev/null || true
}
trap cleanup EXIT INT TERM
echo "=== Starting WeaselDB server ==="
./weaseldb --config "../$CONFIG" > server.log 2>&1 &
SERVER_PID=$!
echo "Server PID: $SERVER_PID"
# Wait for server to be ready (unix socket created)
for i in {1..30}; do
if [ -S weaseldb.sock ]; then
echo "Server ready after $((i * 100))ms"
break
fi
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo "Server died unexpectedly"
cat server.log
exit 1
fi
sleep 0.1
done
if [ ! -S weaseldb.sock ]; then
echo "Error: server failed to create socket within 3 seconds" >&2
exit 1
fi
echo "=== Server log (first lines) ==="
head -30 server.log
echo ""
echo "=== Running load tester ==="
./load_tester \
--unix-socket weaseldb.sock \
--concurrency 2000 \
--requests-per-conn 500 \
--connect-threads 2 \
--network-threads 10 \
--duration "$DURATION" \
--stats-interval 1
echo ""
echo "=== Load test complete ==="