Reject steps disturbed by foreign load on the shared VM

The first run of series A was spoiled by other stands on the same
Docker VM: an image build of another lab is invisible to docker stats,
yet it took CPU from the pinned replicas, doubled their CPU per request
and stalled the Docker API for fifteen minutes in the middle of two
steps.

docker-stats.sh now also samples the VM-wide /proc/stat counters, so a
step records the CPU of the whole VM, the part not used by this
project, the largest gap between samples and its wall time. A step
with more than one foreign core, a gap over 10 s or a k6 run 90 s
longer than its load is written to disturbed.csv and repeated after
the VM has been quiet for 15 s, up to three times. On a quiet VM the
foreign part is 2 % of a core at 600 rps and 25 % at 4 560 rps, which
is Docker networking and the samplers themselves.

The growth series starts at 300 rps per CPU and searches up to 9 000,
so its knees are found with fewer idle steps. The plots fit the
universal scalability law to the growth series.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Artyom
2026-10-28 22:18:14 +03:00
co-authored by Claude Opus 5.5
parent e8804b05d0
commit 67f6d6866e
4 changed files with 114 additions and 18 deletions
+31 -3
View File
@@ -9,6 +9,7 @@ import matplotlib.pyplot as plt
ORDER = ("1x1", "2x1", "4x1", "8x1", "2x2", "1x4")
PALETTE = ("#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300", "#6250d6", "#e34948")
MARKERS = ("o", "s", "^", "D", "v", "P", "X", "*")
USL_POINTS = 3
COMPONENTS = (("api", "API"), ("postgres", "PostgreSQL"), ("lb", "HAProxy"), ("k6", "k6"))
INK, MUTED, GRID, SURFACE = "#0b0b0b", "#52514e", "#e4e3df", "#fcfcfb"
SUMMARY = (
@@ -170,6 +171,17 @@ def cpu(series, keys, groups, out):
plt.close(figure)
def usl(points):
base = points[0][1] / points[0][0]
pairs = [(n - 1, n * (n - 1), n * base / x - 1) for n, x in points]
a, b, c = (sum(p[i] * p[j] for p in pairs) for i, j in ((0, 0), (0, 1), (1, 1)))
d, e = (sum(p[i] * p[2] for p in pairs) for i in (0, 1))
det = a * c - b * b
sigma, kappa = (d * c - b * e) / det, (a * e - b * d) / det
peak = ((1 - sigma) / kappa) ** 0.5 if kappa > 0 else None
return base, sigma, kappa, peak
def scaling(rows, out):
by = {(r["series"], r["config"]): r for r in rows if r["variant"] == "base"}
growth = [
@@ -183,6 +195,15 @@ def scaling(rows, out):
unit = growth[0]["peak_ok_rps"] / cpus[0]
axis.plot(cpus, [unit * c for c in cpus], color=MUTED, linestyle="--", linewidth=1)
axis.annotate("линейный рост", (cpus[-1], unit * cpus[-1]), color=MUTED, fontsize=9)
fit = None
if len(growth) >= USL_POINTS:
fit = usl([(c, r["peak_ok_rps"]) for c, r in zip(cpus, growth, strict=True)])
base, sigma, kappa, _ = fit
grid = [1 + i * (cpus[-1] - 1) / 60 for i in range(61)]
model = [base * n / (1 + sigma * (n - 1) + kappa * n * (n - 1)) for n in grid]
axis.plot(
grid, model, color=PALETTE[6], linewidth=1.5, label=f"USL: σ={sigma:.3f}, κ={kappa:.4f}"
)
axis.errorbar(
cpus,
[r["peak_ok_rps"] for r in growth],
@@ -210,6 +231,7 @@ def scaling(rows, out):
figure.tight_layout()
figure.savefig(out / "scaling.png", dpi=150)
plt.close(figure)
return fit
def utilisation(rows, out):
@@ -251,7 +273,7 @@ def utilisation(rows, out):
plt.close(figure)
def write(rows, out):
def write(rows, out, fit):
with (out / "capacity.csv").open("w", newline="") as handle:
writer = csv.DictWriter(handle, fieldnames=SUMMARY, extrasaction="ignore")
writer.writeheader()
@@ -269,6 +291,12 @@ def write(rows, out):
f"{r['cpu_api']:.0f} / {r['cpu_api_limit']} | {r['cpu_postgres']:.0f} | "
f"{r['cpu_lb']:.0f} | {r['pg_lock_avg']:.1f} / {r['pool_total']} |"
)
if fit:
_, sigma, kappa, peak = fit
best = f"{peak:.1f}" if peak else "—"
lines_.append(
f"\nUSL по серии B: σ = {sigma:.4f}, κ = {kappa:.5f}, пик при N* = {best} CPU"
)
(out / "capacity.md").write_text("\n".join(lines_) + "\n")
print("\n".join(lines_))
@@ -288,9 +316,9 @@ def main():
chosen = [k for k in keys if k[0] == series]
throughput(series, chosen, groups, out)
cpu(series, chosen, groups, out)
scaling(rows, out)
fit = scaling(rows, out)
utilisation(rows, out)
write(rows, out)
write(rows, out, fit)
if __name__ == "__main__":