feat: run load bench on PostgreSQL with query plans
- bench stand is a separate compose project mtusi-bench (API, Postgres, Valkey) with fixed limits, fresh volume per size and migrations - k6 registers with a password, logs in with Basic and sends Bearer - VACUUM (ANALYZE) and CHECKPOINT after prefill - EXPLAIN (ANALYZE, BUFFERS) of the app's history query via auto_explain, plus the same query without the index in a rolled back transaction - Postgres CPU, table and index size in results; storages in passport - bench_compare checks storage limits, images and settings - remove inproc.py and make bench_inproc Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+41
-13
@@ -3,8 +3,9 @@
|
||||
Запуск — `make bench_compare BEFORE=<метка> AFTER=<метка> [AA=<метка>]`.
|
||||
Читает `runs.csv` и `meta.json` из `evidence/bench/<метка>/`, пишет
|
||||
`evidence/compare/<до>__<после>.md`. Только stdlib, docker и приложение
|
||||
не нужны. Метки с разной методикой не сравниваются. Правило «эффект или
|
||||
шум» — design change `perf-bottleneck-fix`, решение 7.
|
||||
не нужны. Метки с разной методикой не сравниваются (с лабы 2 методика
|
||||
включает и хранилища: design change `bench-postgres`, решение 8). Правило
|
||||
«эффект или шум» — design change `perf-bottleneck-fix`, решение 7.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
@@ -93,15 +94,40 @@ def load(name: str) -> Label:
|
||||
return Label(name=name, meta=meta, runs=runs)
|
||||
|
||||
|
||||
def flatten(prefix: str, value: Any, into: dict[str, Any]) -> None:
|
||||
"""Вложенные словари паспорта → плоские ключи `a.b.c`."""
|
||||
if isinstance(value, dict):
|
||||
for key, inner in value.items():
|
||||
flatten(f"{prefix}.{key}", inner, into)
|
||||
else:
|
||||
into[prefix] = value
|
||||
|
||||
|
||||
def methodology(label: Label) -> dict[str, Any]:
|
||||
"""Параметры, которые у сравнимых меток обязаны совпадать."""
|
||||
"""Параметры, которые у сравнимых меток обязаны совпадать.
|
||||
|
||||
Профиль, лимиты всех контейнеров стенда, образ генератора, образы и
|
||||
настройки PostgreSQL и Valkey, окружение приложения (решение 8 design
|
||||
change `bench-postgres`).
|
||||
"""
|
||||
meta = label.meta
|
||||
stand = meta.get("stand", {})
|
||||
flat: dict[str, Any] = {}
|
||||
for section in ("profile", "limits"):
|
||||
for key, value in label.meta.get(section, {}).items():
|
||||
flat[f"{section}.{key}"] = value
|
||||
image = label.meta.get("generator", {}).get("image")
|
||||
if image is not None:
|
||||
flat["generator.image"] = image
|
||||
flatten("profile", meta.get("profile", {}), flat)
|
||||
flatten("limits", meta.get("limits", {}), flat)
|
||||
for name, value in (
|
||||
("generator.image", meta.get("generator", {}).get("image")),
|
||||
("stand.postgres.image", stand.get("postgres", {}).get("image")),
|
||||
("stand.valkey.image", stand.get("valkey", {}).get("image")),
|
||||
):
|
||||
if value is not None:
|
||||
flat[name] = value
|
||||
flatten(
|
||||
"stand.postgres.settings",
|
||||
stand.get("postgres", {}).get("settings", {}),
|
||||
flat,
|
||||
)
|
||||
flatten("stand.app_env", stand.get("app_env", {}), flat)
|
||||
return flat
|
||||
|
||||
|
||||
@@ -284,16 +310,18 @@ def memory_table(before: Label, after: Label) -> list[str]:
|
||||
|
||||
first, second = sizes(before), sizes(after)
|
||||
lines = [
|
||||
"| Размер | Байт на сообщение до | после | "
|
||||
"RSS после наполнения до, МиБ | после |",
|
||||
"|---|---|---|---|---|",
|
||||
"| Размер | Байт RSS на сообщение до | после | "
|
||||
"RSS после наполнения до, МиБ | после | "
|
||||
"Байт в БД на сообщение до | после |",
|
||||
"|---|---|---|---|---|---|---|",
|
||||
]
|
||||
for size in sorted(first.keys() & second.keys()):
|
||||
a, b = first[size], second[size]
|
||||
lines.append(
|
||||
f"| {human(size)} | {a.get('bytes_per_message')} | "
|
||||
f"{b.get('bytes_per_message')} | {a.get('rss_after_mib')} | "
|
||||
f"{b.get('rss_after_mib')} |",
|
||||
f"{b.get('rss_after_mib')} | {a.get('db_bytes_per_message')} | "
|
||||
f"{b.get('db_bytes_per_message')} |",
|
||||
)
|
||||
return lines
|
||||
|
||||
|
||||
Reference in New Issue
Block a user