fix(perf): hand host binaries the host environment in the baseline script
nvidia-smi (vram_mib) and wtype (inject probe) ran without env=host_env(), so under an AppImage bundle they inherit the bundle's library paths. The AST guard now covers the measurement script as well as src/vocalinux, and the script gains the module logger the Style rules require.
This commit is contained in:
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import platform
|
||||
@@ -23,6 +24,8 @@ import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
PROTOCOL_VERSION = "1.0.0"
|
||||
|
||||
_VMRSS_RE = re.compile(r"^VmRSS:\s+(\d+)\s+kB", re.MULTILINE)
|
||||
@@ -117,6 +120,9 @@ def parse_nvidia_smi_memory(csv_text: str) -> Optional[tuple[int, int]]:
|
||||
|
||||
def vram_mib() -> Optional[tuple[int, int]]:
|
||||
"""Return ``(total_mib, free_mib)`` of the first NVIDIA GPU, if any."""
|
||||
# Lazy: the parse-only subcommands must run without the package installed.
|
||||
from vocalinux.utils.host_process import host_env
|
||||
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
[
|
||||
@@ -127,8 +133,10 @@ def vram_mib() -> Optional[tuple[int, int]]:
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
env=host_env(),
|
||||
)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
except (OSError, subprocess.SubprocessError) as error:
|
||||
logger.debug("nvidia-smi unavailable: %s", error)
|
||||
return None
|
||||
if proc.returncode != 0:
|
||||
return None
|
||||
@@ -441,6 +449,8 @@ def cmd_inject_probe(args: argparse.Namespace) -> int:
|
||||
if wayland:
|
||||
import shutil
|
||||
|
||||
from vocalinux.utils.host_process import host_env
|
||||
|
||||
if shutil.which("wtype") is not None and backend != "x11":
|
||||
for _ in range(5):
|
||||
begin = time.monotonic()
|
||||
@@ -449,6 +459,7 @@ def cmd_inject_probe(args: argparse.Namespace) -> int:
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10,
|
||||
env=host_env(),
|
||||
)
|
||||
wtype_roundtrips.append(time.monotonic() - begin)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user