"""Run five separate native one-page COW observations. No global cache eviction.""" import argparse import hashlib import json import os from pathlib import Path import platform import subprocess import tempfile from datetime import datetime, timezone def main(): parser = argparse.ArgumentParser() parser.add_argument("--output", type=Path, required=True) args = parser.parse_args() if args.output.exists(): parser.error("refusing to overwrite an existing capture") source = Path(__file__).with_name("probe.c") compiler = os.environ.get("CC", "cc") with tempfile.TemporaryDirectory(prefix="mincore-cow-build-") as build: binary = Path(build) / "probe" subprocess.run([compiler, "-std=c11", "-Wall", "-Wextra", "-Werror", "-O2", str(source), "-o", str(binary)], check=True) observations = [] for trial in range(1, 6): result = subprocess.run([str(binary)], check=True, text=True, capture_output=True) observations.append({"trial": trial, **json.loads(result.stdout)}) record = { "schema_version": 1, "generated_at": datetime.now(timezone.utc).isoformat(), "method": "Five separate self-owned one-page files; private COW page locked; file-only DONTNEED; untouched second mapping queried before read.", "environment": { "kernel": platform.release(), "machine": platform.machine(), "python": platform.python_version(), "compiler": subprocess.check_output([compiler, "--version"], text=True).splitlines()[0], "effective_uid": os.geteuid(), }, "sha256": { "probe.c": hashlib.sha256(source.read_bytes()).hexdigest(), "run.py": hashlib.sha256(Path(__file__).read_bytes()).hexdigest(), }, "observations": observations, } with args.output.open("x") as stream: json.dump(record, stream, indent=2) stream.write("\n") print(json.dumps(record, indent=2)) if __name__ == "__main__": main()