Skip to content

meta: Polling and busy-spin audit (CPU burn, UI stalls) #1273

Open
16 of 16 issues completed
Open

Description

@zackees

Audit of every place that polls or waits by polling (CPU/RAM/GPU/disk/stats metrics, retry loops, worker threads, UI timers), looking for loops that can busy-spin, collapse to a ~0 interval, or stall the UI. Done against origin/master 8e729be3d.

Summary: nothing polls in a tight loop with no sleep at all. The main hazard is on Windows: os_sleep_ms(1) becomes Sleep(0) (a yield), so "sleep 1 ms" retry loops become yield-spins at ~100% of a core. The other findings are intentional per-frame spinning, UI-thread work, and one rare error-path spin.

Each finding is a sub-issue. Ranking:

  • A: can busy-spin or reach a ~0 interval
  • B: expensive or on the UI thread
  • gap: not yet audited

Each sub-issue's fix should come with a test that bounds the work: iterations per second, time on the UI thread, or wake-ups while idle, so a regression shows up as a number.

Already tracked elsewhere: the Windows PDH GPU sampler, which reopens the query every second. Its cost and a slow-card backoff are covered on #1022 (follow-up comment there), with the persistent-query change owned by @vpacher.

Fine as is:

  • CPU label: 3 s, times() / task_info.
  • Stats window: RAM via statm every 2 s, only while visible.
  • Status bar: 1 s while active.
  • Hotkey thread: 25 ms timedwait.
  • Audio thread: os_sleepto_ns_fast sleeps at least 1 ms.
  • Media playback: waits capped at 200 ms, semaphore while paused.
  • ALSA reopen: growing timedwait.
  • v4l2 capture: select with timeout.
  • Image source: one stat per second.
  • AJA source: 250 ms backoff.
  • Output reconnect: single timedwait.
  • obs-ffmpeg-source reconnect: 0 forced to 10 s.
  • Rust video_output: semaphore.

Activity

  1. zackees commented on Oct 17, 2026

    @zackees
    MemberAuthor

    Follow-up left over from #1284 (PR #1326): when the ingest list's HTTP request itself fails, file-updater never calls the update callback, so the refresh-done event is never signalled and the caller still waits the full timeout (3 s from rtmp_common_url, 5 s on the UI thread in the auto-config wizard). Fixing it needs shared/file-updater to report failure to the callback, or signal completion either way.

  2. vpacher commented on Oct 17, 2026

    @vpacher
    Member

    obs-websocket part of #1285 audited: #1344 (Stop() UI-thread deadlock), #1345 (GetStats disk query stalls the pool on a hung path, relates to #1282), #1346 (GetStats CPU usage data race).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions