Skip to content

perf(recording): wake the audio mixer on input instead of polling every 5 ms - #2764

Open
richiemcilroy wants to merge 1 commit into
mainfrom
perf/audio-mixer-wait-on-input
Open

richiemcilroy wants to merge 1 commit into
mainfrom
perf/audio-mixer-wait-on-input

Conversation

@richiemcilroy

Copy link
Copy Markdown
Member

What

The audio mixer's run loop slept a fixed 5 ms between ticks for the whole recording, about 200 wakeups/s. Most ticks found nothing new.

Now:

  • Input wakes the mixer. Input channels are polled with a waker that unparks the mixer thread (poll_next_unpin instead of try_next; the same empty/ready/closed semantics), so a producer's send wakes it straight away.
  • Idle wait. With no input, it waits park_timeout(idle_wait()): half the shortest source buffer timeout, clamped to 5–25 ms (10 ms for a wired mic's 20 ms minimum). A source that goes quiet is still filled with silence, and stalls are still observed, within half its timeout.
  • Unchanged: output placement stays sample-based, so tick timing doesn't move audio. The stop/drain path (finish) is untouched.

Expected effect: the mixer ticks per input frame (tens per second for a mic, ~100 for system audio) plus the occasional idle timeout, instead of a fixed 200/s, and input is processed up to 5 ms sooner.

Proof

  • Unit tests:
    • input_wake::a_frame_arriving_after_a_drain_wakes_the_mixer
    • input_wake::idle_wait_is_half_the_shortest_buffer_timeout_within_bounds
  • A/V sync and real-capture A/B against main: the Verify recording dispatch runs are linked in the comments below.

No Hona-authored lines are touched.

@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 20, 2026 12:39pm UTC

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile has paused reviews on this repository — it used its 1000 free open-source review credits for this billing period. Reviews resume automatically on October 26. To continue before then, an organization admin can keep reviews running past the free credits — those bill as normal usage.

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

This branch was successfully deployed

2 active deployments
Preview – cap-web — ef264e7a Deployed Oct 20, 2026 by vercel[bot]
Preview – cap-status — ef264e7a Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant