Commit 90afa239 by PLN (Algolia)

perf-tray + gig-up: default-on 'Cut GPU at gig launch' (kill TuParles, verify…

perf-tray + gig-up: default-on 'Cut GPU at gig launch' (kill TuParles, verify dGPU RTD3, name holders if it won't sleep)
parent da1c7c73
...@@ -59,6 +59,58 @@ ensure_perf(){ ...@@ -59,6 +59,58 @@ ensure_perf(){
fi fi
} }
# --- dGPU headroom: TuParles pins the RTX for faster-whisper inference, which
# keeps the discrete GPU awake and drawing power for a feature that has no
# business running mid-gig. Kill it, then CONFIRM the dGPU actually drops to
# D3cold (power/control=auto + runtime_status=suspended) rather than trust that
# killing the one known client is enough — a stray /dev/nvidia* fd elsewhere
# holds it awake just as well. Skip with GIG_CUTGPU=off or the tray toggle
# (~/.cache/parvagues/cut-gpu-disabled — present means opted out). ---
cut_gpu(){
[ "${GIG_CUTGPU:-on}" = off ] && { info "cut-gpu: disabled (GIG_CUTGPU=off)."; return; }
local flag="$HOME/.cache/parvagues/cut-gpu-disabled"
[ -f "$flag" ] && { info "cut-gpu: disabled (tray toggle off — $flag)."; return; }
if pgrep -x tuparles >/dev/null 2>&1; then
pkill -x tuparles
ok "cut-gpu: TuParles killed."
else
info "cut-gpu: TuParles not running."
fi
local d cls ven found=0
for d in /sys/bus/pci/devices/*/; do
cls=$(cat "$d/class" 2>/dev/null)
case "$cls" in 0x0300*|0x0302*) ;; *) continue ;; esac # VGA / 3D controller
ven=$(cat "$d/vendor" 2>/dev/null)
[ "$ven" = "0x8086" ] && continue # skip Intel iGPU
found=1
break
done
if [ "$found" = 0 ]; then
ok "cut-gpu: no dGPU on the bus — already D3cold (root port powered down)."
return
fi
local ctrl; ctrl=$(cat "$d/power/control" 2>/dev/null)
[ "$ctrl" != auto ] && warn "cut-gpu: dGPU power/control='$ctrl' (not auto) — fix: sudo perf-audio --silent"
local waited=0 st
while :; do
st=$(cat "$d/power/runtime_status" 2>/dev/null)
[ "$st" = suspended ] && { ok "cut-gpu: dGPU asleep (suspended, ${waited}s)."; return; }
[ "$waited" -ge 15 ] && break
sleep 1; waited=$((waited + 1))
done
warn "cut-gpu: dGPU still '$st' after ${waited}s — something is holding it awake."
if command -v fuser >/dev/null 2>&1; then
warn "cut-gpu: holders of /dev/nvidia*:"
fuser -v /dev/nvidia* 2>&1 | sed 's/^/ /'
else
warn "cut-gpu: fuser not found — try: lsof /dev/nvidia*"
fi
}
# --- generate the set-specific sample preload the boot will warm --- # --- generate the set-specific sample preload the boot will warm ---
gen_preload(){ gen_preload(){
[ "${PRELOAD_TRACKS}" = 0 ] && { info "preload: disabled (PRELOAD_TRACKS=0)."; return; } [ "${PRELOAD_TRACKS}" = 0 ] && { info "preload: disabled (PRELOAD_TRACKS=0)."; return; }
...@@ -131,6 +183,7 @@ launch_bin(){ # launch_bin "<label>" <binary names...> — first found, detache ...@@ -131,6 +183,7 @@ launch_bin(){ # launch_bin "<label>" <binary names...> — first found, detache
echo echo
info "gig-up — ordered launch from $DIR" info "gig-up — ordered launch from $DIR"
ensure_perf ensure_perf
cut_gpu
# 1) SuperDirt (skip if already running) # 1) SuperDirt (skip if already running)
if scsynth_up; then if scsynth_up; then
......
...@@ -115,6 +115,28 @@ def set_autostart(on): ...@@ -115,6 +115,28 @@ def set_autostart(on):
pass pass
# gig-up.sh reads this same flag (default ON = absent) so the tray and the
# launcher never need to agree on anything but a file's existence.
CUT_GPU_FLAG = Path.home() / ".cache" / "parvagues" / "cut-gpu-disabled"
def cut_gpu_enabled():
"""True if gig-up should kill TuParles + verify the dGPU is asleep at launch."""
return not CUT_GPU_FLAG.exists()
def set_cut_gpu_enabled(on):
"""Flip the opt-out flag. Does not touch anything already running."""
try:
if on:
CUT_GPU_FLAG.unlink(missing_ok=True)
else:
CUT_GPU_FLAG.parent.mkdir(parents=True, exist_ok=True)
CUT_GPU_FLAG.touch()
except OSError:
pass
def temp_color(c): def temp_color(c):
if c is None: if c is None:
return QColor("#607d8b") return QColor("#607d8b")
...@@ -348,6 +370,10 @@ class PerfTray: ...@@ -348,6 +370,10 @@ class PerfTray:
self.autostart_action.toggled.connect(self.on_autostart_toggled) self.autostart_action.toggled.connect(self.on_autostart_toggled)
self.menu.addAction(self.autostart_action) self.menu.addAction(self.autostart_action)
self.cutgpu_action = QAction("Cut GPU at gig launch", self.menu, checkable=True)
self.cutgpu_action.toggled.connect(self.on_cutgpu_toggled)
self.menu.addAction(self.cutgpu_action)
self.menu.addSeparator() self.menu.addSeparator()
# Live stats block — refreshed whenever the menu is about to show. # Live stats block — refreshed whenever the menu is about to show.
self.stat_actions = [] self.stat_actions = []
...@@ -558,6 +584,9 @@ class PerfTray: ...@@ -558,6 +584,9 @@ class PerfTray:
set_autostart(on) set_autostart(on)
QTimer.singleShot(200, self.refresh) QTimer.singleShot(200, self.refresh)
def on_cutgpu_toggled(self, on):
set_cut_gpu_enabled(on)
def refresh(self): def refresh(self):
t = self.therm t = self.therm
pkg = t.package_c() pkg = t.package_c()
...@@ -594,6 +623,10 @@ class PerfTray: ...@@ -594,6 +623,10 @@ class PerfTray:
self.autostart_action.setChecked(autostart_enabled()) self.autostart_action.setChecked(autostart_enabled())
self.autostart_action.blockSignals(False) self.autostart_action.blockSignals(False)
self.cutgpu_action.blockSignals(True)
self.cutgpu_action.setChecked(cut_gpu_enabled())
self.cutgpu_action.blockSignals(False)
fmax, favg = t.freq_mhz() fmax, favg = t.freq_mhz()
fans = t.fans_rpm() fans = t.fans_rpm()
cores = t.cores_c() cores = t.cores_c()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment