mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-27 20:49:04 +01:00
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
The C6 live check failed: global memory PSI full avg10 rose during host runs. Global PSI full counts moments when every busy task is stalled, which the bench scope causes by itself, so no global figure measures the desktop. A host run now fails (exit 3, row kept) when the login session scopes stall over 1 s, and records outside_pswpout: zram's pool is not charged to the scope, so global reclaim swaps other processes too (153k-224k pages per run vs 111k idle). DOCS corrected: the scope does not keep the desktop out of swap, and a nonzero zram disk_wb_pages on the host is background (20k pages over an idle 28 s). Bug-class-check: linux_configuration/fixes/lib/tests/test_swap_bench.sh (pressed-desktop case) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.3 KiB
Python
97 lines
3.3 KiB
Python
"""``python -m python_pkg.swap_bench run|row|summary`` for swap_bench.sh."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
from python_pkg.swap_bench.stats import compute_row, format_row
|
|
from python_pkg.swap_bench.summary import summarize
|
|
from python_pkg.swap_bench.workload import Spec, run
|
|
|
|
|
|
def _snapshot(text: str) -> tuple[Path, Path]:
|
|
src, sep, dest = text.partition("=")
|
|
if not sep:
|
|
msg = f"--snapshot wants SRC=DEST, got {text!r}"
|
|
raise argparse.ArgumentTypeError(msg)
|
|
return Path(src), Path(dest)
|
|
|
|
|
|
def _parser() -> argparse.ArgumentParser:
|
|
parser = argparse.ArgumentParser(prog="swap_bench")
|
|
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
p_run = sub.add_parser("run", help="run the seeded workload once")
|
|
p_run.add_argument("--size-mib", type=int, required=True)
|
|
p_run.add_argument("--seed", type=int, required=True)
|
|
p_run.add_argument("--rounds", type=int, default=3)
|
|
p_run.add_argument("--hot-share", type=float, default=0.25)
|
|
p_run.add_argument("--snapshot", type=_snapshot, action="append", default=[])
|
|
p_row = sub.add_parser("row", help="print one TSV row for a run directory")
|
|
p_row.add_argument("--dir", type=Path, required=True)
|
|
p_row.add_argument("--env", required=True)
|
|
p_row.add_argument("--setup", required=True)
|
|
p_row.add_argument("--seed", type=int, required=True)
|
|
p_row.add_argument("--size-mib", type=int, required=True)
|
|
p_row.add_argument("--date", required=True)
|
|
p_row.add_argument("--header", action="store_true", help="print the header first")
|
|
p_row.add_argument(
|
|
"--max-desktop-ms",
|
|
type=int,
|
|
help="exit 3 when a host run stalled the login sessions longer",
|
|
)
|
|
p_sum = sub.add_parser("summary", help="medians and the winner for a TSV")
|
|
p_sum.add_argument("tsv", type=Path)
|
|
return parser
|
|
|
|
|
|
def _cmd_run(args: argparse.Namespace) -> int:
|
|
try:
|
|
spec = Spec(
|
|
size_mib=args.size_mib,
|
|
seed=args.seed,
|
|
rounds=args.rounds,
|
|
hot_share=args.hot_share,
|
|
)
|
|
except ValueError as exc:
|
|
sys.stderr.write(f"swap_bench: {exc}\n")
|
|
return 2
|
|
result = run(spec, args.snapshot)
|
|
for field in ("pages", "fill_crc", "touch_crc", "majflt", "seconds"):
|
|
sys.stdout.write(f"{field}={getattr(result, field)}\n")
|
|
return 0
|
|
|
|
|
|
def _cmd_row(args: argparse.Namespace) -> int:
|
|
row = compute_row(
|
|
args.dir,
|
|
env=args.env,
|
|
setup=args.setup,
|
|
seed=args.seed,
|
|
size_mib=args.size_mib,
|
|
date=args.date,
|
|
)
|
|
if args.header:
|
|
sys.stdout.write(format_row(None) + "\n")
|
|
sys.stdout.write(format_row(row) + "\n")
|
|
stall, limit = row["desktop_full_ms"], args.max_desktop_ms
|
|
if limit is not None and stall != "na" and int(stall) > limit:
|
|
sys.stderr.write(
|
|
f"swap_bench: the login sessions stalled {stall} ms "
|
|
f"(limit {limit} ms): this run pressed the desktop\n"
|
|
)
|
|
return 3
|
|
return 0
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
"""Dispatch a subcommand; return its exit code."""
|
|
args = _parser().parse_args(argv)
|
|
if args.cmd == "run":
|
|
return _cmd_run(args)
|
|
if args.cmd == "row":
|
|
return _cmd_row(args)
|
|
sys.stdout.write(summarize(args.tsv))
|
|
return 0
|