test: verify cluster failures and clean clone reproducibility
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
import statistics
|
||||
from pathlib import Path
|
||||
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt # noqa: E402
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("directory")
|
||||
args = parser.parse_args()
|
||||
directory = Path(args.directory)
|
||||
meta = json.loads((directory / "run.json").read_text())
|
||||
assert meta["complete"]
|
||||
rows = [
|
||||
json.loads((directory / name).read_text()) for name in meta["cells"]
|
||||
]
|
||||
keys = [
|
||||
"series",
|
||||
"replicas",
|
||||
"concurrency",
|
||||
"repeat",
|
||||
"pool_size",
|
||||
"successful_rps",
|
||||
"errors",
|
||||
"error_ratio",
|
||||
"p50_ms",
|
||||
"p95_ms",
|
||||
"p99_ms",
|
||||
]
|
||||
with (directory / "summary.csv").open("w", newline="") as stream:
|
||||
writer = csv.DictWriter(stream, fieldnames=keys)
|
||||
writer.writeheader()
|
||||
writer.writerows({k: r[k] for k in keys} for r in rows)
|
||||
fig, axes = plt.subplots(1, 2, figsize=(11, 4), constrained_layout=True)
|
||||
for ax, series in zip(axes, ["fixed", "growing"], strict=True):
|
||||
for concurrency in [1, 8, 32]:
|
||||
values = [
|
||||
statistics.median(
|
||||
r["successful_rps"]
|
||||
for r in rows
|
||||
if r["series"] == series
|
||||
and r["replicas"] == n
|
||||
and r["concurrency"] == concurrency
|
||||
)
|
||||
for n in [1, 2, 4]
|
||||
]
|
||||
ax.plot([1, 2, 4], values, marker="o", label=f"C={concurrency}")
|
||||
ax.set(
|
||||
title=series,
|
||||
xlabel="API replicas",
|
||||
ylabel="Successful HTTP requests/s",
|
||||
xticks=[1, 2, 4],
|
||||
)
|
||||
ax.legend()
|
||||
ax.grid(alpha=0.3)
|
||||
fig.savefig(directory / "scaling.png", dpi=160)
|
||||
plt.close(fig)
|
||||
pool = {
|
||||
n: statistics.median(
|
||||
r["successful_rps"]
|
||||
for r in rows
|
||||
if r["series"] == "pool" and r["pool_size"] == n
|
||||
)
|
||||
for n in [1, 10]
|
||||
}
|
||||
lines = [
|
||||
"# Измерения масштабирования",
|
||||
"",
|
||||
f"Source commit: `{meta['source_commit']}`.",
|
||||
"",
|
||||
"Медианы повторов; latency percentile внутри каждого прогона относится только к успешным ответам.",
|
||||
"",
|
||||
"| Серия | API | C | RPS | p95, ms | Ошибки |",
|
||||
"|---|---:|---:|---:|---:|---:|",
|
||||
]
|
||||
for series in ["fixed", "growing"]:
|
||||
for n in [1, 2, 4]:
|
||||
for c in [1, 8, 32]:
|
||||
group = [
|
||||
r
|
||||
for r in rows
|
||||
if r["series"] == series
|
||||
and r["replicas"] == n
|
||||
and r["concurrency"] == c
|
||||
]
|
||||
lines.append(
|
||||
f"| {series} | {n} | {c} | {statistics.median(r['successful_rps'] for r in group):.1f} | {statistics.median(r['p95_ms'] for r in group):.2f} | {sum(r['errors'] for r in group)} |"
|
||||
)
|
||||
lines.extend(
|
||||
[
|
||||
"",
|
||||
f"Пул1 → пул10: {pool[1]:.1f} → {pool[10]:.1f} успешных RPS (N2/C32, три повтора).",
|
||||
"",
|
||||
"Настройка считается подтверждённым улучшением только при наблюдаемом выигрыше; это ограниченная локальная серия.",
|
||||
]
|
||||
)
|
||||
(directory / "analysis.md").write_text("\n".join(lines) + "\n")
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"cells": len(rows),
|
||||
"success": sum(r["success"] for r in rows),
|
||||
"errors": sum(r["errors"] for r in rows),
|
||||
"pool_rps": pool,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user