Skip to content

perf(audio): avoid idle buffer conversion#491

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-audio-capturer-idle
Closed

perf(audio): avoid idle buffer conversion#491
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-audio-capturer-idle

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

Summary

  • skip AVAudioConverter work on warm idle audio taps unless a meter update is due
  • compute idle meter levels directly from the input buffer, while keeping recording conversion/output unchanged
  • keep warmup and command behavior unchanged; conversion still happens for recording buffers and recording meters

Evidence

Focused temporary instrumentation around processBuffer counted converted, recorded, and metered buffers over matching 1.2s windows:

Scenario Before After
Warm idle conversions 12 0
Warm idle recorded buffers 0 0
Warm idle meter updates 7 7
Recording conversion delta 12 12
Recording append delta 12 12
Recording meter delta 8 8

This removes idle converter work while preserving recording conversion and meter cadence in the measured run.

Checks

  • mcp__lsp.diagnostics on src/native/audio-capturer.swift: no errors
  • swiftc -O -o /tmp/supercmd-audio-capturer-final src/native/audio-capturer.swift -framework AVFoundation -framework Foundation: passed
  • git diff --check: passed
  • node scripts/check-i18n.mjs: completed; existing it locale missing keys were reported and are unrelated to this native-only change
  • npm run build:native: blocked by local policy; npm is disabled on this Mac, pnpm attempted install, then failed with ERR_PNPM_IGNORED_BUILDS

Risks

  • Idle meter levels are now calculated from the input buffer instead of the converted 16 kHz mono buffer. The code reads channel 0 with the same RMS/peak scaling, matching the converter's channel map for typical mic formats.

@JustYannicc JustYannicc changed the title [codex] Avoid idle audio buffer conversion perf(audio): avoid idle buffer conversion Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated upstream PR #534 (perf(mac): reduce native polling and async IO stalls), which carries this change together with the related macOS/native/audio/camera async IO performance fixes. Closing this source PR so review can continue on #534.

@JustYannicc JustYannicc closed this Jul 3, 2026
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.

1 participant