mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-04 04:53:04 -05:00
Revert "Log Ubuntu memory during the LightCraft draft gate"
This reverts commit c90026ff8e.
This commit is contained in:
1 parent
adb1d4c13f
commit
75310cfa96
1 file changed
-97
@@ -31,103 +31,6 @@ jobs:
|
||||
gate-timeout-minutes: 140
|
||||
# xtask ci runs cargo test: the demo scene cache is per process, so nextest is slower here.
|
||||
tools: ""
|
||||
# Temporary diagnostic for one approved #4750 Ubuntu run; remove before merge.
|
||||
command: |
|
||||
if [[ "${GITHUB_REF:-}" != refs/pull/4750/merge || "${GITHUB_RUN_ATTEMPT:-}" != 1 ]]; then
|
||||
exec cargo xtask ci
|
||||
fi
|
||||
python3 -u - <<'PY' &
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
def read(path):
|
||||
try:
|
||||
return path.read_text(errors="replace").strip()
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
def cgroups(proc=Path("/proc"), root=Path("/sys/fs/cgroup"), pid=os.getpid()):
|
||||
# Runner Ubuntu uses the standard unified cgroup mount. Verify membership
|
||||
# before using it; do not silently sample the host root as a job limit.
|
||||
member = next((line[3:] for line in read(proc / "self/cgroup").splitlines()
|
||||
if line.startswith("0::/")), "")
|
||||
if not member or ".." in Path(member).parts:
|
||||
return None
|
||||
leaf = root / member.lstrip("/")
|
||||
if str(pid) not in read(leaf / "cgroup.procs").split():
|
||||
return None
|
||||
return [leaf, *(parent for parent in leaf.parents if parent.is_relative_to(root))]
|
||||
|
||||
def kib(value):
|
||||
fields = value.split()
|
||||
return int(fields[0]) if len(fields) == 2 and fields[0].isdigit() and fields[1] == "kB" else None
|
||||
|
||||
def sample(groups, proc=Path("/proc")):
|
||||
mem = {key: None for key in ("MemAvailable", "SwapFree")}
|
||||
for line in read(proc / "meminfo").splitlines():
|
||||
key, _, value = line.partition(":")
|
||||
if key in mem:
|
||||
mem[key] = kib(value)
|
||||
return {"meminfo_kib": mem, "cgroup_v2_leaf_up": None if groups is None else [
|
||||
{"level": level, "current_bytes": read(group / "memory.current") or None,
|
||||
"max_bytes": read(group / "memory.max") or None,
|
||||
"events": read(group / "memory.events").splitlines() or None}
|
||||
for level, group in enumerate(groups) if level < 16
|
||||
]}
|
||||
|
||||
def ui_memory(parent, proc=Path("/proc")):
|
||||
def status(path):
|
||||
return dict(line.split(":", 1) for line in read(path / "status").splitlines() if ":" in line)
|
||||
|
||||
def descends_from(pid):
|
||||
for _ in range(32):
|
||||
if pid == parent:
|
||||
return True
|
||||
fields = status(proc / str(pid)).get("PPid", "").split()
|
||||
if len(fields) != 1 or not fields[0].isdigit() or int(fields[0]) <= 1:
|
||||
break
|
||||
pid = int(fields[0])
|
||||
return False
|
||||
|
||||
rows = []
|
||||
for path in proc.glob("[0-9]*/comm"):
|
||||
if read(path) != "lightcraft_ui_e": # Linux truncates comm to 15 bytes.
|
||||
continue
|
||||
try:
|
||||
exe = os.readlink(path.parent / "exe").rsplit("/", 1)[-1]
|
||||
except OSError:
|
||||
continue
|
||||
if not re.fullmatch(r"lightcraft_ui_egui-[a-f0-9]+(?: \(deleted\))?", exe):
|
||||
continue
|
||||
if not descends_from(int(path.parent.name)):
|
||||
continue
|
||||
info = status(path.parent)
|
||||
rows.append({key: kib(info.get(key, "")) for key in ("VmRSS", "VmHWM")})
|
||||
return rows
|
||||
|
||||
def main():
|
||||
groups = cgroups()
|
||||
start = time.monotonic()
|
||||
parent = os.getppid()
|
||||
for n in range(281): # sample immediately, then every 30 s; at most 140 min
|
||||
if os.getppid() != parent or parent == 1:
|
||||
return
|
||||
now = time.monotonic()
|
||||
if n and now - start > 140 * 60:
|
||||
return
|
||||
print("lc-ci-memory " + json.dumps({"elapsed_s": round(now - start), **sample(groups), "ui_rss_kib": ui_memory(parent)}), flush=True)
|
||||
if n < 280:
|
||||
time.sleep(30)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
PY
|
||||
sampler=$!
|
||||
trap 'kill %1 2>/dev/null || true; wait "$sampler" 2>/dev/null || true' EXIT
|
||||
cargo xtask ci
|
||||
packages: >-
|
||||
pkg-config libxkbcommon-dev libwayland-dev libx11-dev libxcb1-dev libxcursor-dev
|
||||
libxrandr-dev libxi-dev libfontconfig1-dev libfreetype-dev mesa-vulkan-drivers
|
||||
|
||||
Reference in new issue
Block a user