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
|
|
@ -58,6 +58,7 @@ import {
|
|||
} from './SuggestionRepository'
|
||||
import { SuggestionBudget } from './suggestion/SuggestionBudget'
|
||||
import { ModelWarmTracker } from './suggestion/ModelWarmTracker'
|
||||
import { LOCAL_LLM_KEEP_ALIVE, LOCAL_LLM_KEEP_ALIVE_MS } from './llm/model-residency'
|
||||
import { getForegroundWindowInfo } from '../utils/win32-foreground'
|
||||
|
||||
const logger = getLogger('SuggestionService')
|
||||
|
|
@ -207,21 +208,23 @@ interface ModelRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 모델을 메모리에 유지하는 시간.
|
||||
* 모델을 메모리에 유지하는 시간 — 앱 공통 값(LOCAL_LLM_KEEP_ALIVE)을 그대로 쓴다.
|
||||
*
|
||||
* 콜드 리로드 실측(11.4s)이 요청 타임아웃(8s)보다 길어, 짧은 유휴 유지 시간은
|
||||
* 유휴 후 첫 요청을 항상 타임아웃시켰다 — 충분히 길게 유지한다.
|
||||
* 예전엔 콜드 리로드(11.4s) 회피용으로 30m 을 따로 썼지만, 다른 기능의 짧은 keep_alive 와
|
||||
* 서로 덮어써 리로드를 오히려 부추겼고 유휴 중 RAM 11GB 를 붙잡았다. 쓰는 동안은 아래 연장으로
|
||||
* 식지 않게 하고, 콜드 첫 요청은 _keepWarm 의 첫 키 입력 워밍업이 흡수한다.
|
||||
*/
|
||||
const SUGGESTION_KEEP_ALIVE = '30m'
|
||||
const SUGGESTION_KEEP_ALIVE_MS = 30 * 60_000
|
||||
const SUGGESTION_KEEP_ALIVE = LOCAL_LLM_KEEP_ALIVE
|
||||
const SUGGESTION_KEEP_ALIVE_MS = LOCAL_LLM_KEEP_ALIVE_MS
|
||||
/**
|
||||
* 타이핑 중인데 남은 유지 시간이 이보다 짧으면 1토큰 요청으로 유지 시간을 연장한다.
|
||||
*
|
||||
* 실측(2026-10-03): 50분 자리를 비운 뒤 돌아오자 콜드 로드에 29초가 걸려 그동안 "준비 중" 만
|
||||
* 보였다(GPU 메모리 10.6/12GB — 음성 인식 모델과 함께 올라가 있어 로드가 느리다). 쓰는 동안에는
|
||||
* 절대 식지 않게, 자리를 비우면 keep-alive 뒤에 내려가게 한다.
|
||||
* 절대 식지 않게, 자리를 비우면 keep-alive 뒤에 내려가게 한다. keep-alive(10m)보다 충분히 작아야
|
||||
* 타이핑 중 매분 연장 요청을 쏘지 않는다.
|
||||
*/
|
||||
const KEEP_WARM_REFRESH_MS = 10 * 60_000
|
||||
const KEEP_WARM_REFRESH_MS = 4 * 60_000
|
||||
/** 유지 연장 요청 최소 간격 */
|
||||
const KEEP_WARM_MIN_INTERVAL_MS = 60_000
|
||||
/** keep-alive 만료 직전 여유 — 경계에서 콜드 모델로 요청하지 않는다. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue