Skip to content

[WIP] Fix GPU helper CPU usage during idle state#235

Draft
Claude wants to merge 3 commits into
mainfrom
claude/fix-gpu-helper-cpu-usage
Draft

[WIP] Fix GPU helper CPU usage during idle state#235
Claude wants to merge 3 commits into
mainfrom
claude/fix-gpu-helper-cpu-usage

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Apr 25, 2026

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>Review CPU performance — GPU helper sustained ~110% CPU</issue_title>
<issue_description>## Summary

Log4YM is consuming significantly more CPU than expected during normal idle/use, contributing to system-wide audio breakup on macOS when run alongside other apps (OBS, Chrome, Zeus).

Observed on macOS (10-core, Darwin 25.3.0)

Snapshot of ps -Ao pid,pcpu,pmem,comm -r while Log4YM was running:

Process %CPU
Log4YM Helper (GPU) ~110%
Log4YM Helper (Renderer) ~51%
WindowServer 98%
OBS 51%
coreaudiod 27%

System load average: 30.5 on a 10-CPU machine (3× saturation).

After pkill -f Log4YM:

  • WindowServer dropped 98% → 39%
  • OBS dropped 51% → 37%
  • coreaudiod eased 27% → 23%
  • Audio breakup cleared

The GPU helper burning >1 full core while idle suggests a render-loop issue (animation, unthrottled redraw, or a runaway canvas/CSS animation) rather than normal workload. The Renderer at ~51% reinforces that.

What to investigate

  • Is there a render loop / requestAnimationFrame running even when the window is idle or backgrounded?
  • Any CSS animations, spinners, or canvas redraws that don't pause when offscreen?
  • Does CPU drop when the window is minimized vs visible-but-idle?
  • GPU process specifically — check for compositor layers being invalidated every frame.
  • Throttle/pause work when document.hidden or visibilitychange fires.

Acceptance

Idle Log4YM (open, no user interaction) should sit at single-digit % CPU for both the GPU and Renderer helpers.


Assigning to @claude for triage.</issue_description>

Comments on the Issue (you are @claude[agent] in this section)

@Claude Claude AI linked an issue Apr 25, 2026 that may be closed by this pull request
5 tasks
- GlobePlugin: Pause requestAnimationFrame loop when document is hidden
- AnalogClockPlugin: Stop setInterval timer when page is hidden
- HeaderPlugin: Stop time update interval when page is hidden
- LogEntryPlugin: Stop time update interval when page is hidden

These changes prevent unnecessary rendering and timer callbacks when the window is minimized or hidden, dramatically reducing CPU usage of the GPU helper process.

Agent-Logs-Url: https://github.com/brianbruff/Log4YM/sessions/3df02ab9-8529-4c1f-9d7d-e41295378fbf

Co-authored-by: brianbruff <753297+brianbruff@users.noreply.github.com>
@Claude Claude AI requested a review from brianbruff April 25, 2026 10:09
…e rAF

The previous implementation ran a requestAnimationFrame loop at 60 Hz that
called renderBeam every frame, rebuilding pathsData (~150 trig calls per
frame) and re-uploading geometry to globe.gl/three.js, even when nothing
had changed. A per-frame Math.sin pulse on the beam alpha further forced
the GPU helper to recomposite continuously, pegging it at >100% CPU on
macOS while the app was idle.

Replace the rAF loop with a useEffect that re-renders the beam only when
its inputs change (azimuth, rotator-enabled, target lat/lon), gated on a
new globeReady state so it doesn't fire before init completes. Drop the
oscillating alpha pulse for a static value at the midpoint of the old
range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review CPU performance — GPU helper sustained ~110% CPU

2 participants