fix(desktop): stop pinning local models in memory and cap audio buffers
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Successful in 56s
ci / .NET API 서버 테스트 (push) Successful in 10s
deploy-site / deploy (push) Successful in 38s
ci / 모바일 린트·타입·Jest (push) Successful in 44s
ci / 워크스페이스 빌드 검증 (push) Successful in 54s
ci / Supabase Edge Functions + Cloudflare Worker (push) Successful in 22s
portable-unsigned / portable-windows (push) Failing after 35s
release / release-windows (push) Failing after 13s
Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Successful in 56s
ci / .NET API 서버 테스트 (push) Successful in 10s
deploy-site / deploy (push) Successful in 38s
ci / 모바일 린트·타입·Jest (push) Successful in 44s
ci / 워크스페이스 빌드 검증 (push) Successful in 54s
ci / Supabase Edge Functions + Cloudflare Worker (push) Successful in 22s
portable-unsigned / portable-windows (push) Failing after 35s
release / release-windows (push) Failing after 13s
The PC-wide slowdown was not a leak but model residency: boot warmup loaded gemma4:e4b (~11.6 GB RAM incl. 5.9 GB pinned host buffer, no mmap on Windows CUDA) and kept it for 30m, next to the large-v3 sidecar. Measured on the HEAD build: free RAM 7.9 GB -> 32 MB within 20 s; after this change 10.8 GB with no Ollama model loaded until typing starts. - single LOCAL_LLM_KEEP_ALIVE (10m) for every local request; no boot warmup - unload this app's resident Ollama models (keep_alive 0) on quit - sidecar POST /unload for the aux slot; captions release it on stop - partial dictation copies only the tail window, not the whole recording - cap the voice-conversation listen buffer at 5 minutes - mic test: generation guard so re-entry cannot orphan lease/timers - startRealtime: single-flight and removeChannel to stop duplicate bindings - meeting WAV save writes header and PCM without a concat copy Docs: AI-01 policy note, GAP-PERF-01 with remaining work.
This commit is contained in:
parent
a7c0d6fb21
commit
d63854db67
19 changed files with 268 additions and 45 deletions
|
|
@ -177,6 +177,24 @@ function describe(err: unknown): string {
|
|||
return err instanceof Error ? err.message : String(err)
|
||||
}
|
||||
|
||||
/**
|
||||
* 청크 목록의 끝에서 maxBytes 만큼만 새 버퍼로 모은다.
|
||||
* 예전엔 1.5초마다 녹음 전체를 concat 한 뒤 잘라 30분 녹음이면 초당 ~38MB 의 가비지를 만들었고,
|
||||
* subarray 라 진행 중 부분 전사가 원본 전체를 붙잡았다. 끝부분 청크만 복사한다.
|
||||
*/
|
||||
function tailAudio(chunks: readonly Buffer[], maxBytes: number): Buffer {
|
||||
const picked: Buffer[] = []
|
||||
let total = 0
|
||||
for (let i = chunks.length - 1; i >= 0 && total < maxBytes; i -= 1) {
|
||||
picked.push(chunks[i])
|
||||
total += chunks[i].length
|
||||
}
|
||||
picked.reverse()
|
||||
const merged = Buffer.concat(picked, total)
|
||||
// 청크 경계에서 넘친 앞부분은 버린다 (merged 는 창 크기 + 청크 하나 정도라 subarray 로 충분)
|
||||
return total > maxBytes ? merged.subarray(total - maxBytes) : merged
|
||||
}
|
||||
|
||||
/** LLM 을 실제로 부르는 경로 */
|
||||
type LlmProcessingRoute = Exclude<VoiceLlmRoute, { kind: 'insert-raw' }>
|
||||
|
||||
|
|
@ -786,9 +804,7 @@ class VoiceModeService extends EventEmitter {
|
|||
if (!run.sttReady) return
|
||||
if (run.audioBufferBytes < PARTIAL_MIN_AUDIO_MS * BYTES_PER_MS) return
|
||||
|
||||
const merged = Buffer.concat(run.audioBuffer)
|
||||
const maxBytes = PARTIAL_MAX_WINDOW_MS * BYTES_PER_MS
|
||||
const window = merged.length > maxBytes ? merged.subarray(merged.length - maxBytes) : merged
|
||||
const window = tailAudio(run.audioBuffer, PARTIAL_MAX_WINDOW_MS * BYTES_PER_MS)
|
||||
const language = configGet('sttLanguage')
|
||||
|
||||
const task = (async (): Promise<void> => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue