#!/usr/bin/env python3 """THP coverage of a vanilla run: python3 -I baseline-thpcheck.py RUNDIR Prints the largest AnonHugePages (GiB) of the GPU process over state.jsonl, the engine-log line about huge pages, and OK (>= 46.4 GiB) or POOR.""" import json, os, re, sys d = sys.argv[1] best = 0.0 for ln in open(os.path.join(d, "state.jsonl"), errors="replace"): try: s = json.loads(ln) except Exception: continue for p in s.get("procs", []): best = max(best, p.get("smaps_rollup_kb", {}).get("AnonHugePages", 0) / 2**20) note = "" lp = os.path.join(d, "engine.log") if os.path.exists(lp): for ln in open(lp, errors="replace"): if "transparent huge pages" in ln: m = re.search(r"transparent huge pages[^;]*", ln) note = (m.group(0) if m else "")[:140] break print("%s AnonHugePages_max=%.1f GiB [%s]" % ("OK" if best >= 46.4 else "POOR", best, note))