Clarify scaling plots and show CPU repeat ranges

This commit is contained in:
Artyom
2026-11-06 00:58:21 +03:00
parent 07965a2fb6
commit 3fb741e6a8
+28 -10
View File
@@ -156,8 +156,6 @@ def lines(axis, keys, groups, field, categorical=False):
markeredgewidth=1.5, markeredgewidth=1.5,
**look, **look,
) )
if not categorical:
direct_label(axis, rates[-1], values[-1][0], label(key))
if categorical: if categorical:
axis.set_xticks(range(len(keys)), [label(k) for k in keys], rotation=25, ha="right") axis.set_xticks(range(len(keys)), [label(k) for k in keys], rotation=25, ha="right")
@@ -174,14 +172,15 @@ def throughput(series, keys, groups, out):
axes[0].set_title("Успешные RPS") axes[0].set_title("Успешные RPS")
for axis, field, title in ((axes[1], "p95_ms", "p95, мс"), (axes[2], "p99_ms", "p99, мс")): for axis, field, title in ((axes[1], "p95_ms", "p95, мс"), (axes[2], "p99_ms", "p99, мс")):
lines(axis, keys, groups, field, categorical) lines(axis, keys, groups, field, categorical)
axis.set_yscale("log") if not categorical:
axis.set_yscale("log")
axis.set_title(title) axis.set_title(title)
for axis in axes: for axis in axes:
axis.set_xlabel( axis.set_xlabel(
f"Вариант при {top} запросах/с" if categorical else "Предложенная нагрузка, запросов/с" f"Вариант при {top} запросах/с" if categorical else "Предложенная нагрузка, запросов/с"
) )
if not categorical: if not categorical:
axis.legend(loc="upper left", fontsize=9) axis.legend(loc="best", fontsize=9)
figure.suptitle(f"{series}: медиана повторов, усы — min–max", color=INK) figure.suptitle(f"{series}: медиана повторов, усы — min–max", color=INK)
save(figure, out / f"{series}-throughput.png") save(figure, out / f"{series}-throughput.png")
@@ -193,13 +192,22 @@ def cpu(series, keys, groups, out):
first = groups[key][rates[0]][0] first = groups[key][rates[0]][0]
limit = int(first["replicas"]) * float(first["cpus"]) * 100 limit = int(first["replicas"]) * float(first["cpus"]) * 100
for index, (field, name) in enumerate(COMPONENTS): for index, (field, name) in enumerate(COMPONENTS):
values = [med(groups[key][rate], f"cpu_{field}")[0] for rate in rates] values = [med(groups[key][rate], f"cpu_{field}") for rate in rates]
axis.plot(rates, values, color=PALETTE[index], marker=MARKERS[index], label=name) axis.errorbar(
rates,
[v[0] for v in values],
yerr=[[v[1] for v in values], [v[2] for v in values]],
capsize=3,
color=PALETTE[index],
marker=MARKERS[index],
label=name,
)
axis.axhline(limit, color=PALETTE[0], linestyle=":", linewidth=1.2, label="лимит API") axis.axhline(limit, color=PALETTE[0], linestyle=":", linewidth=1.2, label="лимит API")
axis.axhline(200, color=PALETTE[1], linestyle=":", linewidth=1.2, label="лимит PostgreSQL") axis.axhline(200, color=PALETTE[1], linestyle=":", linewidth=1.2, label="лимит PostgreSQL")
axis.set_title(f"CPU, % ядра — {label(key)}") axis.set_title(f"CPU, % ядра — {label(key)}")
axis.set_xlabel("Предложенная нагрузка, запросов/с") axis.set_xlabel("Предложенная нагрузка, запросов/с")
axis.legend(fontsize=8, loc="upper left") axis.legend(fontsize=8, loc="best")
figure.suptitle("Медиана CPU по повторам, усы — min–max", color=INK)
save(figure, out / f"{series}-cpu.png") save(figure, out / f"{series}-cpu.png")
@@ -254,13 +262,23 @@ def scaling(rows, out):
r = by.get(("series-a", config)) r = by.get(("series-a", config))
if r: if r:
look = style(config) look = style(config)
axis.plot(4, r["peak_ok_rps"], linestyle="none", label=f"серия A: {config}", **look) axis.errorbar(
4,
r["peak_ok_rps"],
yerr=[[r["peak_ok_rps"] - r["peak_ok_min"]], [r["peak_ok_max"] - r["peak_ok_rps"]]],
capsize=3,
linestyle="none",
label=f"серия A: {config}",
**look,
)
after = [r for r in rows if r["variant"] == "after"] after = [r for r in rows if r["variant"] == "after"]
for r in after: for r in after:
width = r["cpu_api_limit"] / 100 width = r["cpu_api_limit"] / 100
axis.plot( axis.errorbar(
width, width,
r["peak_ok_rps"], r["peak_ok_rps"],
yerr=[[r["peak_ok_rps"] - r["peak_ok_min"]], [r["peak_ok_max"] - r["peak_ok_rps"]]],
capsize=3,
linestyle="none", linestyle="none",
label=f"{r['config']} после улучшения", label=f"{r['config']} после улучшения",
**VARIANTS["after"], **VARIANTS["after"],
@@ -269,7 +287,7 @@ def scaling(rows, out):
axis.set_ylabel("Пик успешных RPS") axis.set_ylabel("Пик успешных RPS")
axis.set_title("Пропускная способность от ресурсов API") axis.set_title("Пропускная способность от ресурсов API")
axis.set_xticks(cpus) axis.set_xticks(cpus)
axis.legend(loc="upper left", fontsize=9) axis.legend(loc="best", fontsize=9)
save(figure, out / "scaling.png") save(figure, out / "scaling.png")
return fit return fit