Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

917 B
Raw Blame
"""Peak memory of the workload executable, in MiB."""

from pathlib import Path
import sys


def peak_rss_mib():
    if sys.platform == "linux":
        # ru_maxrss can retain the spawning process's pre-exec high-water
        # mark. VmHWM describes the current executable image instead.
        try:
            for line in Path("/proc/self/status").read_text().splitlines():
                if line.startswith("VmHWM:"):
                    return int(line.split()[1]) / 1024
        except (OSError, ValueError, IndexError):
            pass
    try:
        import resource
    except ImportError:
        raise RuntimeError(
            "RSS guard requires procfs or resource.getrusage"
        ) from None
    peak = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
    # The fallback is conservative on Linux when procfs is unavailable.
    return peak / (1024 * 1024 if sys.platform == "darwin" else 1024)