mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-28 13:44:03 +00:00
ci: measure several regions, replay and dropped-table collection in the S3 benchmark
A load group may set partitions: the cell creates the loader's table split into equal event_time ranges over the corpus window, so every batch writes to every region, runs the loader with its --skip-create-table flag, and fails unless every region took rows by the server's region statistics. A drop group writes one table, drops it and kills the server at once, restarts on the same prefix, then writes and flushes another table and waits for the dropped table's objects to be collected. The summary adds the loader's own write latency, entries and appends per object, rows per region, and what every restart replayed per region from the server log next to the store's read time. The recovery concurrency default the plan records is now 64. Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ batch sequence numbers, inserts `rows` rows per batch and stops at the first
|
||||
statement that is not acknowledged, so a stripe has at most one attempted but
|
||||
unacknowledged batch: the one in flight at the kill. Every request is logged
|
||||
with its status and the time it ended, on the same clock as the kill stamps.
|
||||
With `--seconds` the writers also stop once that long has passed.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -50,12 +51,12 @@ def insert(url: str, table: str, seq: int, rows: int) -> str:
|
||||
return "000"
|
||||
|
||||
|
||||
def writer(args, index: int) -> None:
|
||||
def writer(args, index: int, deadline: float) -> None:
|
||||
directory, seq = Path(args.dir), args.first_seq + index
|
||||
with open(directory / f"attempted-{index}.log", "a") as attempted, \
|
||||
open(directory / f"requests-{index}.log", "a") as requests, \
|
||||
open(directory / f"acked-{index}.log", "a") as acked:
|
||||
while True:
|
||||
while time.monotonic() < deadline:
|
||||
attempted.write(f"{seq}\n")
|
||||
attempted.flush()
|
||||
code = insert(args.url, args.table, seq, args.rows)
|
||||
@@ -71,7 +72,8 @@ def writer(args, index: int) -> None:
|
||||
|
||||
def write(args) -> int:
|
||||
os.makedirs(args.dir, exist_ok=True)
|
||||
threads = [threading.Thread(target=writer, args=(args, i)) for i in range(args.writers)]
|
||||
deadline = time.monotonic() + args.seconds if args.seconds else float("inf")
|
||||
threads = [threading.Thread(target=writer, args=(args, i, deadline)) for i in range(args.writers)]
|
||||
for thread in threads:
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
@@ -170,6 +172,7 @@ def main() -> int:
|
||||
w.add_argument("--table", default="crash")
|
||||
for name in ("writers", "first-seq", "rows"):
|
||||
w.add_argument(f"--{name}", type=int, required=True)
|
||||
w.add_argument("--seconds", type=float, default=0, help="stop after this long; 0 writes until a failure")
|
||||
c = commands.add_parser("check")
|
||||
c.add_argument("--run-dir", type=Path, required=True)
|
||||
c.add_argument("--cycle", type=int, required=True)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs inside the o11ybench runtime image: the load of scripts/agent-observability/greptimedb.sh
|
||||
# with the same arguments plus the loader's --skip-create-table, for a table the cell created.
|
||||
set -euo pipefail
|
||||
|
||||
mkdir "/results/$RESULT_NAME"
|
||||
mkdir -p /results/corpus
|
||||
cp /work/corpus/summary.json /work/corpus/evidence.json /results/corpus/
|
||||
w="$PWD/workloads/logbench-agent-observability"
|
||||
r="/results/$RESULT_NAME"
|
||||
prepare_workers=${PREPARE_WORKERS:-$(python3 -c 'import sys; sys.path.insert(0, "scripts"); from benchmark_workers import effective_cpus; print(effective_cpus())')}
|
||||
o11ybench-greptimedb-loader --workload logbench-agent-observability --prepare-workers "$prepare_workers" \
|
||||
--skip-create-table \
|
||||
--grpc-endpoint "$GRPC_ENDPOINT" --sql-endpoint "$ENDPOINT" \
|
||||
--database public --table agent_observations --batch-size "${GREPTIMEDB_BATCH_SIZE:-10000}" --write-mode stream --max-in-flight "${MAX_IN_FLIGHT:-1}" \
|
||||
--flush-table --request-timeout-seconds 900 \
|
||||
--schema "$w/schema.json" --physical-index-profiles "$w/physical-index-profiles.json" \
|
||||
--data /work/corpus/agent_observations.jsonl \
|
||||
--profile-summary /work/corpus/summary.json --evidence /work/corpus/evidence.json \
|
||||
--transcript-output "$r/load-transcript.jsonl" \
|
||||
--target-metadata-output "$r/target-metadata.json" \
|
||||
--greptimedb-image "$TARGET_IMAGE" --greptimedb-version "$TARGET_VERSION" \
|
||||
--greptimedb-digest "$TARGET_DIGEST" \
|
||||
--startup-input=standalone --startup-input=start \
|
||||
--startup-input=--http-addr=0.0.0.0:4000 \
|
||||
--startup-input=--grpc-bind-addr=0.0.0.0:4001 \
|
||||
> "$r/load-result.json"
|
||||
@@ -224,6 +224,45 @@ crash_cycles() {
|
||||
done
|
||||
}
|
||||
|
||||
# Writes the table `dropped` for write_seconds, drops it and kills the server right
|
||||
# away, while most of its objects are still indexed; restarts on the same prefix and
|
||||
# data home, then writes and flushes the table `kept` and samples the indexed objects
|
||||
# until the dropped table's objects are collected.
|
||||
drop_restart() {
|
||||
local writers rows seconds started deadline indexed recovered sql_url=${OSWAL_SQL_URL:-http://127.0.0.1:4000/v1/sql?db=public}
|
||||
writers=$(jq -r .concurrency <<< "$spec") rows=$(jq -r .batch_rows "$PLAN") seconds=$(jq -r .write_seconds <<< "$spec")
|
||||
sql "CREATE TABLE dropped (seq BIGINT, ts TIMESTAMP TIME INDEX) WITH (append_mode = 'true')" >/dev/null
|
||||
sql "CREATE TABLE kept (seq BIGINT, ts TIMESTAMP TIME INDEX) WITH (append_mode = 'true')" >/dev/null
|
||||
python3 "$here/oswal-s3-bench-crash.py" write --dir "$dir/dropped" --url "$sql_url" --table dropped \
|
||||
--writers "$writers" --first-seq 0 --rows "$rows" --seconds "$seconds"
|
||||
phase=-written; scrape_retry indexed_objects || { echo "$id: metrics scrape failed" >&2; exit 4; }
|
||||
sql "DROP TABLE dropped" >/dev/null
|
||||
stop_server kill
|
||||
phase=-restart started=$(now)
|
||||
start_server
|
||||
restart_seconds=$(elapsed "$started")
|
||||
scrape_retry recovery_seconds_count || { echo "$id: metrics scrape failed" >&2; exit 4; }
|
||||
recovered=$(awk '/^greptime_logstore_object_store_wal_recovered_objects_total / {print $2}' "$dir/metrics-restart.prom")
|
||||
python3 "$here/oswal-s3-bench-crash.py" write --dir "$dir/kept" --url "$sql_url" --table kept \
|
||||
--writers 1 --first-seq 0 --rows "$rows" --seconds 2
|
||||
sql "ADMIN FLUSH_TABLE('kept')" >/dev/null
|
||||
# The flushed watermark becomes durable with the next object, so every sample writes one row.
|
||||
deadline=$((SECONDS + ${OSWAL_COLLECT_SECONDS:-120}))
|
||||
while :; do
|
||||
sql "INSERT INTO kept VALUES (-1, $SECONDS)" >/dev/null
|
||||
# The samples have their own file; the final scrape and the log keep the restart's name.
|
||||
phase=-collected
|
||||
scrape_retry indexed_objects || { phase=-restart; echo "$id: metrics scrape failed" >&2; exit 4; }
|
||||
phase=-restart
|
||||
indexed=$(awk '/^greptime_logstore_object_store_wal_indexed_objects / {print $2}' "$dir/metrics-collected.prom")
|
||||
printf '%s %s\n' "$(date +%s)" "$indexed" >> "$dir/collected.tsv"
|
||||
# A start object, the newest object and kept's own may stay; the dropped table's go.
|
||||
awk -v i="$indexed" -v r="${recovered:-0}" 'BEGIN {exit !(i <= 3 || 2 * i < r)}' && break
|
||||
((SECONDS < deadline)) || { echo "$id: $indexed of ${recovered:-?} recovered objects still indexed" >&2; exit 9; }
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
finish() {
|
||||
local rc=$?
|
||||
trap - EXIT
|
||||
@@ -260,7 +299,7 @@ cell() {
|
||||
spec=$1 cid= wal_dir= home_dir= version= load_seconds= metrics_scraped=false id= phase=
|
||||
restart_scraped=false restart_seconds= restart_query_seconds= restart_count= server_cpu_seconds= host_cpu_busy=
|
||||
indexed_before_kill=
|
||||
local concurrency setting started cpu_before host_before host_after
|
||||
local concurrency setting started cpu_before host_before host_after corpus partitions load script
|
||||
id=$(jq -r .id <<< "$spec"); concurrency=$(jq -r .concurrency <<< "$spec")
|
||||
dir="$RESULTS/cells/$id" name="$OWNER-$id"
|
||||
mkdir -p "$dir"
|
||||
@@ -269,7 +308,7 @@ cell() {
|
||||
"STORAGE__ROOT=$RUN_PREFIX/$id")
|
||||
[[ -z "${S3_CONTAINER_ENDPOINT:-}" ]] || settings+=("STORAGE__ENDPOINT=$S3_CONTAINER_ENDPOINT")
|
||||
# A restarted server needs the metadata the loaded one kept in its data home.
|
||||
jq -e '.restart or .mode == "crash"' <<< "$spec" >/dev/null && settings+=(STORAGE__DATA_HOME=/oswal_home)
|
||||
jq -e '.restart or .mode != "load"' <<< "$spec" >/dev/null && settings+=(STORAGE__DATA_HOME=/oswal_home)
|
||||
while IFS= read -r setting; do settings+=("$setting"); done \
|
||||
< <(jq -r '.wal | to_entries[] | "WAL__\(.key)=\(.value)"' <<< "$spec")
|
||||
docker_env=() mounts=()
|
||||
@@ -293,7 +332,7 @@ cell() {
|
||||
else
|
||||
wal_device="s3://$S3_BUCKET/$RUN_PREFIX/$id/wal"
|
||||
fi
|
||||
if jq -e '.restart or .mode == "crash"' <<< "$spec" >/dev/null; then
|
||||
if jq -e '.restart or .mode != "load"' <<< "$spec" >/dev/null; then
|
||||
home_dir="$WAL_ROOT/$id-home"; mkdir -p "$home_dir"
|
||||
mounts+=(--mount "type=bind,src=$home_dir,dst=/oswal_home")
|
||||
fi
|
||||
@@ -302,18 +341,27 @@ cell() {
|
||||
version=$(docker exec "$cid" greptime --version | sed -n 's/^version: //p')
|
||||
[[ -n "$version" ]]
|
||||
if jq -e '.mode == "crash"' <<< "$spec" >/dev/null; then crash_cycles; return; fi
|
||||
if jq -e '.mode == "drop"' <<< "$spec" >/dev/null; then drop_restart; return; fi
|
||||
corpus="$CORPUS_DIR/corpus-$(jq -r .rows <<< "$spec")" partitions=$(jq -r '.partitions // 1' <<< "$spec")
|
||||
# Only the load phase, run exactly as run-agent-observability.sh runs it, or with the
|
||||
# loader writing into a table split into regions that the cell created first.
|
||||
load=(scripts/agent-observability/greptimedb.sh load) script=()
|
||||
if ((partitions > 1)); then
|
||||
sql "$(python3 "$here/oswal-s3-bench.py" table --summary "$corpus/summary.json" --partitions "$partitions")" >/dev/null
|
||||
load=(/work/oswal-s3-bench-load.sh)
|
||||
script=(--mount "type=bind,src=$here/oswal-s3-bench-load.sh,dst=/work/oswal-s3-bench-load.sh,readonly")
|
||||
fi
|
||||
cpu_before=$(server_cpu) host_before=$(host_cpu)
|
||||
started=$(now)
|
||||
# Only the load phase, run exactly as run-agent-observability.sh runs it.
|
||||
runtime --name "$name-load" --network host \
|
||||
--mount "type=bind,src=$CORPUS_DIR/corpus-$(jq -r .rows <<< "$spec"),dst=/work/corpus,readonly" \
|
||||
--mount "type=bind,src=$corpus,dst=/work/corpus,readonly" ${script[@]+"${script[@]}"} \
|
||||
--mount "type=bind,src=$dir,dst=/results" \
|
||||
-e GRPC_ENDPOINT=127.0.0.1:4001 -e "DATA_PROFILE=$(jq -r .data_profile <<< "$spec")" -e RESULT_NAME=greptimedb-1 \
|
||||
-e "ENDPOINT=http://127.0.0.1:4000/v1/sql?db=public&format=greptimedb_v1" \
|
||||
-e "TARGET_IMAGE=$GREPTIMEDB_IMAGE" -e "TARGET_VERSION=$version" -e "TARGET_DIGEST=${GREPTIMEDB_IMAGE##*@}" \
|
||||
-e "TARGET_ID=$name" -e TARGET_HOST=127.0.0.1 -e PREPARE_WORKERS= -e "MAX_IN_FLIGHT=$concurrency" \
|
||||
-e "GREPTIMEDB_BATCH_SIZE=$(jq -r .batch_rows "$PLAN")" --entrypoint /bin/bash \
|
||||
"$RUNTIME_IMAGE" scripts/agent-observability/greptimedb.sh load > "$dir/load.log" 2>&1
|
||||
"$RUNTIME_IMAGE" "${load[@]}" > "$dir/load.log" 2>&1
|
||||
load_seconds=$(elapsed "$started")
|
||||
host_after=$(host_cpu)
|
||||
server_cpu_seconds=$(awk -v a="$cpu_before" -v b="$(server_cpu)" 'BEGIN {if (a != "" && b != "") printf "%.3f", b - a}')
|
||||
@@ -322,6 +370,16 @@ cell() {
|
||||
'BEGIN {split(a, x, " "); split(b, y, " "); if (y[2] > x[2]) printf "%.4f", (y[1] - x[1]) / (y[2] - x[2])}')
|
||||
jq -e --argjson rows "$(jq .rows <<< "$spec")" '.count_before == 0 and .count_after == $rows' \
|
||||
"$dir/greptimedb-1/load-result.json" >/dev/null
|
||||
if ((partitions > 1)); then
|
||||
# The server's own account of the rows each region took.
|
||||
sql "SELECT p.partition_name, s.region_id, s.region_rows, s.written_bytes_since_open
|
||||
FROM information_schema.partitions p JOIN information_schema.region_statistics s
|
||||
ON p.greptime_partition_id = s.region_id
|
||||
WHERE p.table_schema = 'public' AND p.table_name = 'agent_observations'
|
||||
ORDER BY s.region_id" > "$dir/regions.json"
|
||||
jq -e --argjson n "$partitions" '[.output[0].records.rows[] | select(.[2] > 0)] | length == $n' \
|
||||
"$dir/regions.json" >/dev/null || { echo "$id: fewer than $partitions regions took rows" >&2; exit 8; }
|
||||
fi
|
||||
# An idle window: what the server sends with no writes, between two scrapes.
|
||||
if jq -e '.idle_seconds > 0' <<< "$spec" >/dev/null; then
|
||||
phase=-idle; scrape_metrics || { echo "$id: metrics scrape failed" >&2; exit 4; }; phase=
|
||||
|
||||
@@ -29,6 +29,12 @@ COUNTERS = ("created_objects_total", "stalled_appends_total", "poisoned_total",
|
||||
# The Raft Engine controls every object store WAL cell is compared with: fsync per write and the default.
|
||||
BASELINES = ("R", "R0")
|
||||
SAMPLE = re.compile(r'([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{([^}]*)\})?\s+(\S+)')
|
||||
# Mito's line for every region it opened, with the WAL range it replayed.
|
||||
REPLAY = re.compile(r"Replay WAL for region: (\d+)\(.*?provider: (\w+).*?rows recovered: (\d+), "
|
||||
r"replay from entry id: (\d+), last entry id: (\d+),.*?elapsed: ([0-9.]+)(ns|µs|us|ms|s)\b")
|
||||
UNITS = {"ns": 1e-9, "µs": 1e-6, "us": 1e-6, "ms": 1e-3, "s": 1.0}
|
||||
# An object store WAL entry id is the object sequence above a 20-bit position.
|
||||
POSITION_BITS = 20
|
||||
|
||||
|
||||
def parse_metrics(text: str) -> dict:
|
||||
@@ -78,6 +84,49 @@ def read_metrics(path: Path) -> dict:
|
||||
return parse_metrics(path.read_text() if path.exists() else "")
|
||||
|
||||
|
||||
def ratio(a, b):
|
||||
return a / b if a is not None and b else None
|
||||
|
||||
|
||||
def replay(log: Path, metrics: dict) -> dict | None:
|
||||
"""What a restarted server replayed: every region that had rows to replay, the objects of
|
||||
its WAL range, and the log store's time serving region reads (`read_seconds`)."""
|
||||
if not log.exists():
|
||||
return None
|
||||
regions = []
|
||||
for match in REPLAY.finditer(log.read_text(errors="replace")):
|
||||
region, provider, rows, first, last, elapsed, unit = match.groups()
|
||||
if int(rows):
|
||||
objects = (int(last) >> POSITION_BITS) - (int(first) >> POSITION_BITS) + 1 \
|
||||
if provider == "ObjectStore" else None
|
||||
regions.append({"region": int(region), "rows": int(rows), "seconds": float(elapsed) * UNITS[unit],
|
||||
"objects": objects})
|
||||
samples = metrics["samples"]
|
||||
return {"regions": regions, "rows": sum(r["rows"] for r in regions),
|
||||
"seconds": max((r["seconds"] for r in regions), default=None),
|
||||
"objects": sum(r["objects"] or 0 for r in regions) if regions and regions[0]["objects"] else None,
|
||||
"read_seconds": samples.get("read_seconds_sum"), "reads": samples.get("read_seconds_count")}
|
||||
|
||||
|
||||
def client_latency(path: Path) -> tuple:
|
||||
"""The 50th and 99th percentile of the loader's own time per write request."""
|
||||
durations = []
|
||||
if path.exists():
|
||||
for line in path.read_text().splitlines():
|
||||
record = json.loads(line) if line.strip() else {}
|
||||
if record.get("step") == "grpc_write_batch" and record.get("status") == "success":
|
||||
durations.append(record["duration_seconds"])
|
||||
durations.sort()
|
||||
return tuple(durations[max(0, math.ceil(q * len(durations)) - 1)] if durations else None for q in (0.5, 0.99))
|
||||
|
||||
|
||||
def region_rows(path: Path) -> list | None:
|
||||
"""Rows per region of a partitioned load cell, as the server reported them after the load."""
|
||||
if not path.exists():
|
||||
return None
|
||||
return [int(row[2]) for row in json.loads(path.read_text())["output"][0]["records"]["rows"]]
|
||||
|
||||
|
||||
def interval_seconds(wal: dict) -> float:
|
||||
value = wal.get("FLUSH_INTERVAL", "100ms")
|
||||
return float(value[:-2]) / 1000 if value.endswith("ms") else float(value.rstrip("s"))
|
||||
@@ -115,7 +164,8 @@ def crash_cycles(path: Path, wal: dict) -> list:
|
||||
"indexed_before_kill": before.get("indexed_objects"),
|
||||
"recovery_seconds": after["samples"].get("recovery_seconds_sum") if once else None,
|
||||
"recovered_objects": after["samples"].get("recovered_objects_total", 0 if once else None),
|
||||
"restart_requests": after["requests"]}
|
||||
"restart_requests": after["requests"],
|
||||
"replay": replay(path / f"server-restart-{cycle['cycle']}.log", after)}
|
||||
return cycles
|
||||
|
||||
|
||||
@@ -145,6 +195,13 @@ def load_cell(path: Path, spec: dict | None = None) -> dict:
|
||||
("object_bytes", "object_bytes")):
|
||||
buckets = metrics["buckets"].get(name, [])
|
||||
row[f"{key}_p50"], row[f"{key}_p99"] = quantile(0.5, buckets), quantile(0.99, buckets)
|
||||
row["client_p50"], row["client_p99"] = client_latency(path / "greptimedb-1" / "load-transcript.jsonl")
|
||||
# An entry is one region's write; an append, counted only in the durable mode, carries one or more.
|
||||
samples = metrics["samples"]
|
||||
row["entries_per_object"] = ratio(samples.get("object_entries_sum"), samples.get("object_entries_count"))
|
||||
row["appends_per_object"] = ratio(samples.get("append_ack_seconds_count"), samples.get("object_bytes_count"))
|
||||
row["partitions"] = cell.get("partitions", 1)
|
||||
row["region_rows"] = region_rows(path / "regions.json")
|
||||
if cell.get("restart"):
|
||||
# A restarted process observed exactly one recovery, so the sum is its duration.
|
||||
count = restarted["samples"].get("recovery_seconds_count")
|
||||
@@ -155,6 +212,7 @@ def load_cell(path: Path, spec: dict | None = None) -> dict:
|
||||
"recovered_objects": restarted["samples"].get("recovered_objects_total")
|
||||
if cell.get("restart_scraped") else None,
|
||||
"indexed_before_kill": cell.get("indexed_before_kill"), "min_objects": cell.get("min_objects", 0),
|
||||
"replay": replay(path / "server-restart.log", restarted),
|
||||
}
|
||||
# The counters register on their first event, so a scrape of an object store WAL
|
||||
# that created objects omits the ones that never moved: those are zero, not unknown.
|
||||
@@ -171,6 +229,21 @@ def load_cell(path: Path, spec: dict | None = None) -> dict:
|
||||
end = final["samples"].get("created_objects_total")
|
||||
row["idle"] = {"seconds": cell["idle_seconds"], "requests": idle["requests"],
|
||||
"creates": None if end is None else end - metrics["samples"].get("created_objects_total", 0)}
|
||||
if row["mode"] == "drop":
|
||||
written = read_metrics(path / "metrics-written.prom")["samples"]
|
||||
restarted_samples = restarted["samples"]
|
||||
samples = [line.split() for line in (path / "collected.tsv").read_text().splitlines()
|
||||
if line.strip()] if (path / "collected.tsv").exists() else []
|
||||
row["drop"] = {
|
||||
"acked_batches": sum(len((p.read_text()).split()) for p in sorted((path / "dropped").glob("acked-*.log"))),
|
||||
"indexed_before_drop": written.get("indexed_objects"),
|
||||
"restart_seconds": cell.get("restart_seconds"),
|
||||
"recovered_objects": restarted_samples.get("recovered_objects_total"),
|
||||
"release_records": restarted_samples.get("release_records_total"),
|
||||
"indexed_at_end": int(float(samples[-1][1])) if samples else None,
|
||||
"deleted_after_restart": restarted_samples.get("deleted_objects_total"),
|
||||
"seconds_to_collect": int(samples[-1][0]) - int(samples[0][0]) if samples else None,
|
||||
}
|
||||
if row["mode"] == "crash":
|
||||
row["cycles"] = crash_cycles(path, cell.get("wal", {}))
|
||||
if (path / "objects.tsv").exists():
|
||||
@@ -296,6 +369,45 @@ def render(run: dict, rows: list, pairs: list) -> str:
|
||||
last = next((s for s in reversed(samples) if s[1] is not None), [None] * 4)
|
||||
lines.append(f"| {r['id']} | {', '.join('missing' if s[1] is None else str(s[1]) for s in samples)} "
|
||||
f"| {sum(s[1] is None for s in samples)} | {fmt(last[2])} | {fmt(last[3])} |")
|
||||
details = [r for r in loads if any(r[k] is not None for k in ("client_p50", "entries_per_object", "region_rows"))]
|
||||
if details:
|
||||
lines += ["", "| Cell | Client p50 / p99 ms | Entries per object | Appends per object | Regions "
|
||||
"| Rows per region min / max |", "| --- | ---: | ---: | ---: | ---: | ---: |"]
|
||||
for r in details:
|
||||
spread = r["region_rows"] or []
|
||||
lines.append(" | ".join([
|
||||
f"| {label(r)}", pair(r["client_p50"], r["client_p99"], 1, 1000), fmt(r["entries_per_object"], 1),
|
||||
fmt(r["appends_per_object"], 2), fmt(len(spread) if spread else r["partitions"]),
|
||||
pair(min(spread), max(spread)) if spread else "—"]) + " |")
|
||||
replays = [(r["id"], "—", r["restart"]) for r in loads if r.get("restart", {}).get("replay")]
|
||||
replays += [(r["id"], fmt(c["cycle"]), c | {"wall_seconds": c.get("restart_seconds")})
|
||||
for r in crashes for c in r["cycles"] if c.get("replay")]
|
||||
if replays:
|
||||
lines += ["", "| Cell | Cycle | Restart to /health s | Recovery s | Recovered objects | Regions replayed "
|
||||
"| Rows replayed | Objects replayed | Slowest region replay s | Read seconds (reads) |",
|
||||
"| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- |"]
|
||||
for cell, cycle, x in replays:
|
||||
y = x["replay"]
|
||||
lines.append(" | ".join([
|
||||
f"| {cell}", cycle, fmt(x.get("wall_seconds"), 2), fmt(x.get("recovery_seconds"), 3),
|
||||
fmt(x.get("recovered_objects")), fmt(len(y["regions"])), fmt(y["rows"]), fmt(y["objects"]),
|
||||
fmt(y["seconds"], 2), f"{fmt(y['read_seconds'], 2)} ({fmt(y['reads'])})"]) + " |")
|
||||
drops = [r for r in rows if r.get("drop")]
|
||||
if drops:
|
||||
lines += ["", "| Cell | Acked batches before the drop | Indexed before the drop | Restart to /health s "
|
||||
"| Recovered objects | Release records | Indexed at the end | Deleted after the restart "
|
||||
"| Seconds to collect | Verdict |",
|
||||
"| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- |"]
|
||||
for r in drops:
|
||||
x = r["drop"]
|
||||
# Objects the release already collected before the kill leave nothing to show.
|
||||
verdict = "—" if x["indexed_at_end"] is None else \
|
||||
"nothing left at the kill" if (x["recovered_objects"] or 0) <= 3 else \
|
||||
"collected" if r["exit_code"] == 0 else "still indexed"
|
||||
lines.append(" | ".join([
|
||||
f"| {label(r)}", fmt(x["acked_batches"]), fmt(x["indexed_before_drop"]), fmt(x["restart_seconds"], 2),
|
||||
fmt(x["recovered_objects"]), fmt(x["release_records"]), fmt(x["indexed_at_end"]),
|
||||
fmt(x["deleted_after_restart"]), fmt(x["seconds_to_collect"]), verdict]) + " |")
|
||||
restarts = [r for r in rows if "restart" in r]
|
||||
if restarts:
|
||||
lines += ["", "| Cell | Overrides | Objects created | Indexed at kill | Restart to /health s | Restart to count s "
|
||||
|
||||
@@ -29,6 +29,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
SMOKE_ROWS = 50_000
|
||||
@@ -44,9 +45,43 @@ WAL_CONFIGS = {
|
||||
BASELINES = ("R", "R0")
|
||||
# The pipeline depths an image built with the overrides reads; their defaults on main.
|
||||
DEPTHS = {"GREPTIMEDB_OSWAL_MAX_IN_FLIGHT_CREATES": 4, "GREPTIMEDB_OSWAL_MAX_SEALED_BATCHES": None,
|
||||
"GREPTIMEDB_OSWAL_RECOVERY_CONCURRENCY": 8}
|
||||
"GREPTIMEDB_OSWAL_RECOVERY_CONCURRENCY": 64}
|
||||
# Restart cells seal ten times as often as the default so recovery has thousands of objects.
|
||||
RESTART_FLUSH_INTERVAL = "10ms"
|
||||
# The loader's CREATE TABLE for the agent observability workload at the pinned runtime image.
|
||||
AGENT_TABLE = """CREATE TABLE `agent_observations` (
|
||||
`event_time` TIMESTAMP(3) NOT NULL,
|
||||
`biz_date` DATE NOT NULL,
|
||||
`trace_id` STRING NOT NULL SKIPPING INDEX,
|
||||
`session_id` STRING NOT NULL,
|
||||
`observation_id` STRING NOT NULL SKIPPING INDEX,
|
||||
`parent_observation_id` STRING NULL SKIPPING INDEX,
|
||||
`seq_no` BIGINT NOT NULL,
|
||||
`type` STRING NOT NULL INVERTED INDEX,
|
||||
`status` STRING NOT NULL INVERTED INDEX,
|
||||
`tenant` STRING NOT NULL,
|
||||
`app` STRING NOT NULL,
|
||||
`environment` STRING NOT NULL,
|
||||
`task_category` STRING NULL,
|
||||
`trace_archetype` STRING NULL,
|
||||
`model` STRING NULL,
|
||||
`tool_name` STRING NULL,
|
||||
`input` STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false', granularity = '10240', false_positive_rate = '0.01'),
|
||||
`output` STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false', granularity = '10240', false_positive_rate = '0.01'),
|
||||
`input_tokens` BIGINT NULL,
|
||||
`output_tokens` BIGINT NULL,
|
||||
`total_cost` DOUBLE NULL,
|
||||
`latency_ms` BIGINT NULL,
|
||||
`payload` JSON2 NOT NULL,
|
||||
TIME INDEX (`event_time`),
|
||||
PRIMARY KEY (`tenant`, `app`, `environment`)
|
||||
)
|
||||
{partitions}ENGINE=mito
|
||||
WITH(
|
||||
append_mode = 'true',
|
||||
'compaction.type' = 'twcs',
|
||||
'compaction.twcs.time_window' = '2h'
|
||||
)"""
|
||||
GROUP_NAME = re.compile(r"[a-z][a-z0-9]{0,11}")
|
||||
RESERVED_ENV = ("GREPTIMEDB_STANDALONE__STORAGE__", "GREPTIMEDB_STANDALONE__WAL__")
|
||||
ENV_NAME = re.compile(r"[A-Za-z_][A-Za-z0-9_]*")
|
||||
@@ -141,17 +176,34 @@ def check_depths(env: dict) -> None:
|
||||
raise ValueError(f"MAX_SEALED_BATCHES {sealed} is below MAX_IN_FLIGHT_CREATES {creates} plus 2")
|
||||
|
||||
|
||||
def partitioned_table(summary: dict, partitions: int) -> str:
|
||||
"""The loader's table split into equal event_time ranges over the corpus window. The
|
||||
generator draws event times uniformly from that window, so every range gets an equal
|
||||
share of the rows and every batch writes to every region."""
|
||||
def millis(text):
|
||||
return int(datetime.fromisoformat(text.replace("Z", "+00:00")).timestamp() * 1000)
|
||||
start, end = millis(summary["start"]), millis(summary["end"])
|
||||
bounds = [start + (end - start) * i // partitions for i in range(1, partitions)]
|
||||
if len(set(bounds)) != len(bounds) or not start < bounds[0]:
|
||||
raise ValueError(f"the corpus window {summary['start']}..{summary['end']} is too short for {partitions} ranges")
|
||||
ranges = [f"`event_time` < {bounds[0]}"]
|
||||
ranges += [f"`event_time` >= {low} AND `event_time` < {high}" for low, high in zip(bounds, bounds[1:])]
|
||||
ranges.append(f"`event_time` >= {bounds[-1]}")
|
||||
clause = "PARTITION ON COLUMNS (`event_time`) (\n " + ",\n ".join(ranges) + "\n)\n"
|
||||
return AGENT_TABLE.format(partitions=clause)
|
||||
|
||||
|
||||
def group_cells(group: dict, smoke: bool) -> list:
|
||||
"""The cells of one group, in run order; a group without a name is the top-level inputs."""
|
||||
name, mode = group.get("name", ""), group.get("mode", "load")
|
||||
if mode not in ("load", "crash"):
|
||||
raise ValueError(f"group {name!r}: mode must be load or crash, got {mode!r}")
|
||||
if mode not in ("load", "crash", "drop"):
|
||||
raise ValueError(f"group {name!r}: mode must be load, crash or drop, got {mode!r}")
|
||||
concurrency = str(group["concurrency"])
|
||||
levels = [positive("concurrency", level.strip(), 256) for level in concurrency.split(",")]
|
||||
if len(set(levels)) != len(levels):
|
||||
raise ValueError(f"concurrency repeats a level: {concurrency!r}")
|
||||
chosen = [config.strip() for config in str(group["configs"]).split(",")]
|
||||
allowed = set(WAL_CONFIGS) - (set(BASELINES) if mode == "crash" else set())
|
||||
allowed = set(WAL_CONFIGS) - (set(BASELINES) if mode != "load" else set())
|
||||
if not chosen or len(set(chosen)) != len(chosen) or not set(chosen) <= allowed:
|
||||
raise ValueError(f"group {name!r}: configs must be distinct names among {', '.join(sorted(allowed))}, "
|
||||
f"got {group['configs']!r}")
|
||||
@@ -165,6 +217,9 @@ def group_cells(group: dict, smoke: bool) -> list:
|
||||
rounds = 1 if smoke else positive("rounds", str(group["rounds"]), 10)
|
||||
idle = int(group.get("idle_seconds", 0))
|
||||
common = {"group": name, "mode": mode, "restart": restart, "idle_seconds": idle}
|
||||
partitions = int(group.get("partitions", 1))
|
||||
if partitions != 1 and (mode != "load" or not 2 <= partitions <= 64):
|
||||
raise ValueError(f"group {name!r}: partitions must be in 2..64 and needs mode load")
|
||||
if mode == "load":
|
||||
if not 0 <= idle <= 600:
|
||||
raise ValueError(f"group {name!r}: idle_seconds must be in 0..600")
|
||||
@@ -173,7 +228,14 @@ def group_cells(group: dict, smoke: bool) -> list:
|
||||
if min_objects < 0 or (min_objects and not restart):
|
||||
raise ValueError(f"group {name!r}: min_objects needs restart and must not be negative")
|
||||
common |= {"rows": rows, "data_profile": DATA_PROFILES.get(rows, "custom"),
|
||||
"min_objects": 0 if smoke else min_objects}
|
||||
"min_objects": 0 if smoke else min_objects, "partitions": partitions}
|
||||
elif mode == "drop":
|
||||
# Writes one table for write_seconds, drops it, kills and restarts the server, then
|
||||
# writes and flushes another table and watches the dropped table's objects go.
|
||||
write_seconds = int(group.get("write_seconds", 30))
|
||||
if not 1 <= write_seconds <= 600 or restart or idle:
|
||||
raise ValueError(f"group {name!r}: write_seconds must be in 1..600, without restart or idle")
|
||||
common |= {"write_seconds": min(write_seconds, 10) if smoke else write_seconds}
|
||||
else:
|
||||
cycles = int(group.get("cycles", 5))
|
||||
kill_after = [int(v) for v in group.get("kill_after", [3, 10])]
|
||||
@@ -212,7 +274,8 @@ def parse_groups(text: str, defaults: dict) -> list:
|
||||
groups = json.loads(text)
|
||||
if not isinstance(groups, list) or not groups or not all(isinstance(g, dict) for g in groups):
|
||||
raise ValueError("groups must be a non-empty JSON list of objects")
|
||||
known = set(defaults) | {"name", "mode", "idle_seconds", "cycles", "kill_after", "pin", "min_objects"}
|
||||
known = set(defaults) | {"name", "mode", "idle_seconds", "cycles", "kill_after", "pin", "min_objects",
|
||||
"partitions", "write_seconds"}
|
||||
names = [g.get("name") for g in groups]
|
||||
for group, name in zip(groups, names):
|
||||
if not isinstance(name, str) or not GROUP_NAME.fullmatch(name):
|
||||
@@ -334,6 +397,9 @@ def main() -> int:
|
||||
regions = commands.add_parser("regions")
|
||||
for name in ("bucket", "runner"):
|
||||
regions.add_argument(f"--{name}", required=True)
|
||||
table = commands.add_parser("table")
|
||||
table.add_argument("--summary", type=Path, required=True)
|
||||
table.add_argument("--partitions", type=int, required=True)
|
||||
manifest = commands.add_parser("manifest")
|
||||
for name in ("results", "runtime-image", "instance-type", "region", "prefix"):
|
||||
manifest.add_argument(f"--{name}", required=True)
|
||||
@@ -359,6 +425,8 @@ def main() -> int:
|
||||
elif args.command == "regions":
|
||||
check_regions(args.bucket, args.runner)
|
||||
print(f"bucket and runner both in {args.runner}")
|
||||
elif args.command == "table":
|
||||
print(partitioned_table(json.loads(args.summary.read_text()), args.partitions))
|
||||
elif args.command == "manifest":
|
||||
results = Path(args.results)
|
||||
manifest = build_manifest(json.loads((results / "plan.json").read_text()),
|
||||
|
||||
Reference in New Issue
Block a user