Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
T
Tidal
  • Overview
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • PLN
  • Tidal
  • Repository

Switch branch/tag
  • Tidal
  • tools
  • bridge
  • bridge.py
Find file
BlameHistoryPermalink
  • PLN (Algolia)'s avatar
    feat(bridge): power-aware perf watcher — reassert the chosen regime across AC/battery & resume · e94163f1
    The incident: mid-session on battery the pstate held turbo down (~2.5 GHz, 60°C,
    CPU pressure ~0 — the set never needed more). Plugging in on AC at 4% silently
    lifted that limit; the SAME workload jumped to 4.4–4.5 GHz and 85–93°C with fans
    maxed. Nothing was working harder — the platform just reset the frequency cap
    underneath our "cool" mode, and the tooling never noticed. set_mode() was
    fire-and-forget: it wrote the cap once and moved on.
    
    Fix: treat the perf mode as DESIRED STATE and reconcile it whenever the platform
    can drift it (AC/battery flip, resume-from-suspend), with a periodic drift check
    as the safety net.
    
    perf.py
      - write_desired()/read_desired(): persist the user-chosen mode (~/.cache/
        parvagues/perf-desired). "normal"/absent == maintenance off, so we never
        fight a deliberate switch back to platform defaults.
      - set_mode() records intent on every successful switch.
      - on_ac(): mains state from /sys/class/power_supply/A*/online.
      - reconcile(force): reassert desired if detect_mode() drifted (idempotent —
        "cool holding" when already in force, so no thrash).
      - run_watcher(): daemon loop. Reasserts (force) on a power-source edge and on
        resume (detected via a monotonic-clock gap), settling 2s for the platform;
        periodic force=False drift check otherwise. Seeds desired from the live mode
        on startup so an already-cool session is maintained immediately.
    
    bridge.py: launch run_watcher() as a daemon thread from `serve` (the always-on
    --user service is the right home; the tray is just a face).
    
    perf-tray.py: record intent (write_desired) on a successful tray switch too, so
    both faces agree and the watcher respects tray-initiated changes.
    
    Bonus: because "cool" also RT-schedules scsynth/sclang/Ardour/PipeWire, every
    reassert re-guarantees audio-chain priority after a power event — cheap insurance
    against post-transition xruns.
    
    Validated: compiles; reconcile idempotent; force reassert exercises the real
    perf-audio path (cool->cool, no disturbance); watcher thread confirmed live in
    the daemon with "on_ac=True desired=cool". Real power-transition proof lands on
    the next unplug/replug (logged to the bridge journal).
    PLN (Algolia) authored Jul 23, 2026
    e94163f1
bridge.py 2.02 KB
EditWeb IDE
×

Replace bridge.py

Attach a file by drag & drop or click to upload


Cancel
A new branch will be created in your fork and a new merge request will be started.