forked from mtusi2026/mtusi2026lab2
docs: REPORT lab2, доказательства со стенда из чистого clone, размеры индексов
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
eb92e8e91e
commit
d65ba991d7
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Index sizes of every variant on the SAME 121 120-row dataset (no writes in between).
|
||||
|
||||
python bench/track2/index_sizes.py # ~2 min, writes evidence/track2/index-sizes.csv
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import csv
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
import plans # noqa: E402 (same image, limits, schema and deterministic seed)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
plans.start_container("2", "2g")
|
||||
try:
|
||||
plans.psql("".join(p.read_text(encoding="utf-8") for p in sorted((plans.ROOT / "migrations").glob("*.sql"))))
|
||||
plans.psql(plans.SEED)
|
||||
rows = int(plans.psql("SELECT count(*) FROM messages;"))
|
||||
out = []
|
||||
for variant in plans.VARIANTS:
|
||||
info = plans.use_variant(variant)
|
||||
secondary = sum(int(b) for name, b in info["index_bytes"].items() if name != "messages_pkey")
|
||||
out.append({"variant": variant, "rows": rows, "table_bytes": info["table_bytes"],
|
||||
"pkey_bytes": int(info["index_bytes"]["messages_pkey"]), "secondary_index_bytes": secondary,
|
||||
"secondary_bytes_per_row": round(secondary / rows, 1), "index_build_seconds": info["index_build_s"]})
|
||||
print(out[-1], flush=True)
|
||||
finally:
|
||||
plans.sh(["docker", "rm", "-f", "-v", plans.CLIENT, plans.NAME], check=False)
|
||||
path = plans.ROOT / "evidence/track2/index-sizes.csv"
|
||||
with path.open("w", newline="", encoding="utf-8") as f:
|
||||
writer = csv.DictWriter(f, fieldnames=list(out[0]))
|
||||
writer.writeheader()
|
||||
writer.writerows(out)
|
||||
print("done:", path)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user