httk.core.memguard¶
Run a command inside a Linux memory-guarded process group.
The child command starts in its own session (and therefore its own process
group), every process it forks inherits an optional per-process virtual
address-space rlimit, and a watchdog sums the resident memory of the whole
group at a fixed interval. When the group’s total RSS exceeds the budget the
entire group receives SIGKILL — sacrificing the run, never the machine.
This is the userland fallback for environments without a delegatable cgroup v2
subtree (where memory.max on a dedicated cgroup would do the same job in
the kernel). It guards against the failure mode that motivated it: a parallel
test or benchmark run whose workers independently grow until the system-wide
OOM killer takes down unrelated processes.
The process-group sampler requires Linux and a visible /proc filesystem.
On other platforms, or when /proc is unavailable, the command exits with a
clear error instead of running without its memory guard.
Usage:
python -m httk.core.memguard [--max-rss-gb N] [--as-gb N] [--interval SECONDS] -- command args...
The exit status is the child’s status, or 137 when the watchdog killed the group.
Functions¶
|
Run the requested command under the process-group memory guard. |
Module Contents¶
- httk.core.memguard.main(argv=None)[source]¶
Run the requested command under the process-group memory guard.
- Parameters:
argv (collections.abc.Sequence[str] | None) – Command-line arguments, excluding the program name. When omitted, arguments are read from
sys.argv.- Returns:
The child exit status, 137 for a budget breach, or 2 when the platform cannot provide the Linux process-group sampler.
- Return type: