156 lines
4.4 KiB
Bash
156 lines
4.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
TS=$(date +%Y%m%d_%H%M%S)
|
|
CSV="test-redis/results/kv_overwrite5_${TS}.csv"
|
|
SUMMARY="test-redis/results/kv_overwrite5_summary_${TS}.csv"
|
|
BACKUP=$(mktemp /tmp/config.xml.bak.${TS}.XXXXXX)
|
|
cp config/config.xml "$BACKUP"
|
|
|
|
cleanup() {
|
|
cp "$BACKUP" config/config.xml || true
|
|
rm -f "$BACKUP" || true
|
|
pkill -x kvstore >/dev/null 2>&1 || true
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
pkill -x kvstore >/dev/null 2>&1 || true
|
|
mkdir -p test-redis/results
|
|
rm -rf data/*
|
|
|
|
echo "case,mode,round,qps,avg_us,requests,keyspace,value_size,pipeline" > "$CSV"
|
|
|
|
auto_set_cfg() {
|
|
local ptype="$1" alloc="$2" syncm="$3" pdir="$4"
|
|
python3 - "$ptype" "$alloc" "$syncm" "$pdir" <<'PY'
|
|
import sys
|
|
import xml.etree.ElementTree as ET
|
|
|
|
ptype, alloc, syncm, pdir = sys.argv[1:]
|
|
path = "config/config.xml"
|
|
tree = ET.parse(path)
|
|
root = tree.getroot()
|
|
|
|
server = root.find("server")
|
|
if server is not None:
|
|
ip = server.find("ip")
|
|
port = server.find("port")
|
|
mode = server.find("mode")
|
|
replica = server.find("replica")
|
|
if ip is not None:
|
|
ip.text = "127.0.0.1"
|
|
if port is not None:
|
|
port.text = "8888"
|
|
if mode is not None:
|
|
mode.text = "master"
|
|
if replica is not None:
|
|
replica.text = "disable"
|
|
|
|
persist = root.find("persistence")
|
|
if persist is not None:
|
|
ptype_node = persist.find("type")
|
|
dir_node = persist.find("dir")
|
|
sync_node = persist.find("oplog_sync")
|
|
if ptype_node is not None:
|
|
ptype_node.text = ptype
|
|
if dir_node is not None:
|
|
dir_node.text = pdir
|
|
if sync_node is not None:
|
|
sync_node.text = syncm
|
|
|
|
memory = root.find("memory")
|
|
if memory is not None:
|
|
alloc_node = memory.find("allocator")
|
|
leak_node = memory.find("leakage")
|
|
if alloc_node is not None:
|
|
alloc_node.text = alloc
|
|
if leak_node is not None:
|
|
leak_node.text = "disable"
|
|
|
|
tree.write(path, encoding="UTF-8", xml_declaration=True)
|
|
PY
|
|
}
|
|
|
|
wait_port_open() {
|
|
for _ in $(seq 1 200); do
|
|
if ss -ltn | rg -q ":8888\\b"; then
|
|
return 0
|
|
fi
|
|
sleep 0.1
|
|
done
|
|
return 1
|
|
}
|
|
|
|
extract_qps() {
|
|
local line="$1"
|
|
echo "$line" | sed -E "s/.*qps=([0-9]+).*/\\1/"
|
|
}
|
|
|
|
extract_avg() {
|
|
local line="$1"
|
|
echo "$line" | sed -E "s/.*avg=([0-9]+(\\.[0-9]+)?).*/\\1/"
|
|
}
|
|
|
|
run_case() {
|
|
local cname="$1" ptype="$2" alloc="$3" syncm="$4"
|
|
local REQ=2000000 KEYSPACE=1000000 VSIZE=64 PIPE=128
|
|
|
|
for r in 1 2 3 4 5; do
|
|
local pdir="data/ovw_${cname}_r${r}_${TS}"
|
|
local line qps avg out kp
|
|
|
|
rm -rf "$pdir"
|
|
mkdir -p "$pdir"
|
|
auto_set_cfg "$ptype" "$alloc" "$syncm" "$pdir"
|
|
|
|
./kvstore > "/tmp/kv_${cname}_r${r}_${TS}.log" 2>&1 &
|
|
local kvpid=$!
|
|
wait_port_open
|
|
|
|
kp="bench:ovw:long-key-prefix-abcdefghijklmnopqrstuvwxyz-0123456789:${cname}:r${r}:set:"
|
|
out=$(./test-redis/bench \
|
|
--host 127.0.0.1 --port 8888 --mode set \
|
|
--set-cmd RSET --get-cmd RGET \
|
|
--requests "$REQ" --pipeline "$PIPE" --keyspace "$KEYSPACE" \
|
|
--value-size "$VSIZE" --seed $((13000 + r * 31)) \
|
|
--key-prefix "$kp")
|
|
echo "$out"
|
|
line=$(echo "$out" | rg "\\[result\\]" | tail -n1)
|
|
qps=$(extract_qps "$line")
|
|
avg=$(extract_avg "$line")
|
|
echo "${cname},set,${r},${qps},${avg},${REQ},${KEYSPACE},${VSIZE},${PIPE}" >> "$CSV"
|
|
|
|
kp="bench:ovw:long-key-prefix-abcdefghijklmnopqrstuvwxyz-0123456789:${cname}:r${r}:get:"
|
|
out=$(./test-redis/bench \
|
|
--host 127.0.0.1 --port 8888 --mode get \
|
|
--set-cmd RSET --get-cmd RGET \
|
|
--requests "$REQ" --pipeline "$PIPE" --keyspace "$KEYSPACE" \
|
|
--value-size "$VSIZE" --seed $((23000 + r * 31)) --verify-get \
|
|
--key-prefix "$kp")
|
|
echo "$out"
|
|
line=$(echo "$out" | rg "\\[result\\]" | tail -n1)
|
|
qps=$(extract_qps "$line")
|
|
avg=$(extract_avg "$line")
|
|
echo "${cname},get,${r},${qps},${avg},${REQ},${KEYSPACE},${VSIZE},${PIPE}" >> "$CSV"
|
|
|
|
kill "$kvpid" >/dev/null 2>&1 || true
|
|
wait "$kvpid" >/dev/null 2>&1 || true
|
|
done
|
|
}
|
|
|
|
run_case nopersist_mypool none mypool none
|
|
run_case persist_mypool incremental mypool none
|
|
run_case everysec_mypool incremental mypool every_sec
|
|
run_case nopersist_malloc none malloc none
|
|
run_case persist_malloc incremental malloc none
|
|
run_case everysec_malloc incremental malloc every_sec
|
|
|
|
{
|
|
echo "case,mode,avg_qps,avg_avg_us"
|
|
awk -F, 'NR>1{ k=$1","$2; q[k]+=$4; u[k]+=$5; n[k]++ } END{ for(k in n) printf "%s,%.2f,%.2f\n", k, q[k]/n[k], u[k]/n[k] }' "$CSV" | sort
|
|
} > "$SUMMARY"
|
|
|
|
echo "RAW_CSV=$CSV"
|
|
echo "SUMMARY_CSV=$SUMMARY"
|
|
cat "$SUMMARY"
|