Skip to content

perf(whisper): avoid unused local STT file reads#570

Closed
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-whisper-file-buffer-lazy-read
Closed

perf(whisper): avoid unused local STT file reads#570
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-whisper-file-buffer-lazy-read

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Extracted the file-based Whisper IPC transcription flow into a testable helper.
  • Deferred fs.readFileSync(audioPath) until the selected STT provider requires a Buffer; whispercpp continues to send the captured file path directly.
  • Added a focused harness covering provider read behavior, cleanup order, and instrumentation evidence.

Why

The default local whispercpp path already transcribes by file path, so the previous eager read created an unused full-file Node heap allocation for native-captured audio.

Compatibility impact

No user-visible behavior changes expected. Buffer-backed providers still read the captured WAV once and successful transcriptions still unlink the temp file before removing its directory.

How tested

  • node --test scripts/test-whisper-file-buffer-read.mjs
  • node --test scripts/test-whisper-file-buffer-read.mjs scripts/test-native-helper-process-lifecycle.mjs scripts/test-local-model-status-probe-cache.mjs scripts/test-ai-model-status-polling.mjs scripts/test-ai-chat-stream-batching.mjs scripts/test-ai-stream-ipc-batching.mjs scripts/test-use-ai-stream-batching.mjs scripts/test-raycast-ai-abort-listeners.mjs scripts/test-speak-settings-listener.mjs
  • ./node_modules/.bin/tsc -p tsconfig.main.json --noEmit
  • git diff --cached --check

Performance evidence

The new harness logs an eager-read baseline of readCalls=1 nodeBufferBytes=73400320; after the change whispercpp logs readCalls=0 nodeBufferBytes=0 avoidedNodeBufferBytes=73400320, while openai logs readCalls=1 nodeBufferBytes=73400320.

Stack validation

Started from fork/codex/perf-consolidated-integration-stack at 264fb89dc5c867d6c3d77bc4b95e26e235e326ea. Codex LSP diagnostics on src/main/main.ts and src/main/whisper-transcribe-file.ts: no diagnostics found.

Replaces

None

…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
… into codex/perf-consolidated-integration-stack
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated lifecycle/media wave-2 PR: #575

@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #575.

@JustYannicc JustYannicc closed this Jul 4, 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