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

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:
Yun Chan 2026-10-11 11:35:15 +09:00
parent a7c0d6fb21
commit d63854db67
19 changed files with 268 additions and 45 deletions

View file

@ -21,7 +21,7 @@ import { getTextInsertService } from './services/TextInsertService'
import { getCustomInstructionService } from './services/CustomInstructionService'
import { getVoiceCommandService } from './services/VoiceCommandService'
import { getInputTelemetryService } from './services/InputTelemetryService'
import { getSuggestionService, hasInputContextConsent } from './services/SuggestionService'
import { getSuggestionService } from './services/SuggestionService'
import { initTypoCorrectionService } from './services/TypoCorrectionService'
import { getPersonalGraphService } from './services/PersonalGraphService'
import { getForegroundWindowInfo } from './utils/win32-foreground'
@ -228,8 +228,7 @@ async function initInputIntelligence(): Promise<void> {
systemPrompt: options.systemPrompt,
temperature: 0,
maxTokens: options.maxTokens,
signal: options.signal,
keepAlive: '10m'
signal: options.signal
})
})
typo.on('settled', ({ context }) => suggestion.handleTypingContext(context))
@ -307,15 +306,9 @@ async function initInputIntelligence(): Promise<void> {
logger.info('[bootstrap] accessibility tree enabled for UIA context capture')
}
// 제안이 켜져 있으면 켜진 시점부터 모델을 미리 올려 둔다 — 토글 시에만 워밍업하면
// 앱을 새로 켤 때마다 첫 제안이 콜드 로딩으로 타임아웃된다.
// 입력 수집 동의가 없으면 입력 맥락이 오지 않아 제안이 뜰 수 없다 — 모델을 데우지 않는다.
if (configGet('suggestionEnabled') && hasInputContextConsent()) void suggestion.warmUp()
// Ollama 서버가 나중에 뜨는 경우(느린 부팅 등) 가용해지는 시점에도 워밍업한다.
getLocalLLMService().on('availability-changed', ({ available }) => {
if (available && configGet('suggestionEnabled') && hasInputContextConsent()) void suggestion.warmUp()
})
// 부팅 시에는 제안 모델을 미리 올리지 않는다. gemma4:e4b 는 올라가는 순간 RAM 을 11GB 넘게
// 붙잡아(2026-10-11 실측: 앱 기동 20초 만에 여유 RAM 7.9GB→32MB) 타이핑하지 않는 사용자까지
// PC 전체가 느려졌다. 첫 키 입력 때 SuggestionService._keepWarm 이 조용히 워밍업한다.
telemetry.start()