sahiljagtap's picture
Drums launch benchmarks reproduction + paired Drums/Prime/E2B re-run (scrubbed)
4ef198a
Raw History Blame Contribute Delete
4.07 kB
"""phases.py RAW_DIR: descriptive tables (not pre-registered): fork phases and quiescence basis in W1 and W2, reset phases,
failure causes, the activity watch at the end of W2. Reads only RAW_DIR/*.jsonl."""
import collections, json, math, os, re, sys
def pct(v, p):
v = sorted(x for x in v if x is not None)
return v[max(1, math.ceil(p / 100 * len(v))) - 1] if v else None
f3 = lambda x: "-" if x is None else f"{x:.3f}"
raw = sys.argv[1]
print("| arm | wl | forks | quiescence basis events / sampler (fallback reasons) | wait p50 / p95 | dump p50 | adopt p50 | children ready p50 / p95 | child CRIU p50 | capture attempts > 1 |")
print("|---|---|---|---|---|---|---|---|---|---|")
for arm in ("old", "new", "rep-old", "rep-new"):
for w in ("w1", "w2"):
p = os.path.join(raw, f"{arm}-{w}.jsonl")
if not os.path.exists(p): continue
R = [json.loads(l) for l in open(p)]
ramp = next((r["epoch"] for r in R if r["kind"] == "ramped"), None)
F = [r for r in R if r["kind"] == "fork" and not r.get("error") and (ramp is None or r["epoch"] - r["wall_s"] >= ramp)]
if not F: continue
basis = collections.Counter(); why = collections.Counter(); wait = []; dump = []; adopt = []; kids = []; kc = []; multi = 0
for r in F:
at = (r.get("quiescence") or {}).get("attempts", [])
multi += len(at) > 1
for a in at:
wv = a.get("wait", {})
basis[wv.get("basis") or "sampler"] += 1
if wv.get("events_fallback"): why[re.sub(r"[0-9.]+", "N", wv["events_fallback"])[:60]] += 1
wait.append(sum(a.get("wait_s", 0) for a in at))
if at:
dump.append(at[-1].get("dump_s"))
if at[-1].get("source_check_after_s"): adopt.append(at[-1]["source_check_after_s"] - at[-1]["dump_s"])
kids.append(r["server"].get("children_ready_s"))
kc.extend((c.get("timings") or {}).get("criu_clock") for c in r["children"])
print(f"| {arm} | {w} | {len(F)} | {basis.get('events', 0)} / {basis.get('sampler', 0)} ({'; '.join(f'{k}: {v}' for k, v in why.most_common(3))}) | "
f"{f3(pct(wait, 50))} / {f3(pct(wait, 95))} | {f3(pct(dump, 50))} | {f3(pct(adopt, 50))} | {f3(pct(kids, 50))} / {f3(pct(kids, 95))} | {f3(pct(kc, 50))} | {multi} |")
print()
print("| arm | wl | resets ok | reset CRIU p50 / p95 | task setup p50 | failures by cause |")
print("|---|---|---|---|---|---|")
for arm in ("old", "new", "rep-old", "rep-new"):
for w in ("w1", "w2"):
p = os.path.join(raw, f"{arm}-{w}.jsonl")
if not os.path.exists(p): continue
R = [json.loads(l) for l in open(p)]
S = [r for r in R if r["kind"] == "reset"]
ok = [r for r in S if not r.get("error")]
causes = collections.Counter()
for r in R:
e = r.get("error") or ""
if r["kind"] in ("reset", "create", "fork") and e:
m = re.search(r"Error \(([^)]*)\): ([^/|]*)", e)
causes[(r["kind"], (m.group(2).strip()[:50] if m else e[:50]))] += 1
for v in r.get("validity", []):
if not v["valid"]: causes[("fork child", (v.get("why") or "")[:50])] += 1
if r["kind"] == "reset" and r.get("valid") is False and not e: causes[("reset", "invalid: " + (r.get("why") or "")[:40])] += 1
print(f"| {arm} | {w} | {len(ok)} | {f3(pct([(r.get('timings') or {}).get('criu_clock') for r in ok], 50))} / {f3(pct([(r.get('timings') or {}).get('criu_clock') for r in ok], 95))} | "
f"{f3(pct([(r.get('timings') or {}).get('task_setup') for r in ok], 50))} | {'; '.join(f'{k[0]} {k[1]!r}: {v}' for k, v in causes.most_common(4)) or 'none'} |")
for arm in ("old", "new", "rep-new"):
p = os.path.join(raw, f"{arm}-w2.jsonl")
if os.path.exists(p):
for l in open(p):
r = json.loads(l)
if r["kind"] == "health_end": print(f"\n{arm} W2 end: activity_watch {r.get('activity_watch')}; crash_watch {r.get('crash_watch')}")