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
|
|
@ -37,7 +37,7 @@ Status quick-reference: `[x]` done+verified · `[~]` partial/unverified · `[ ]`
|
|||
|
||||
| ID | Feature | D | W | M | B | Anchors / notes |
|
||||
|---|---|---|---|---|---|---|
|
||||
| AI-01 | Local LLM (Ollama) | [~] | [-] | [ ] | [-] | Desktop bundled Ollama. 2026-09-22 guard contract: no boot warmup; suggestion `keep_alive: 2m`; request-owned cancellation; generate/stream 2048 tokens / 120 s and chat 512 / 60 s; `done` frame required with incomplete-stream cleanup; deduplicated Ollama spawn/poll plus lifecycle disposal. GAP-LLM-03 has targeted evidence (6 test files / 69 passed / 0 failed; changed code/tests ESLint and diff check exit 0). Raw Ollama confirms cold timeout cleanup, a 553 ms `num_predict=1`/`keep_alive='2m'` response, and after the about-119.9 s expiry a 19:48:59 +09:00 `/api/ps` HTTP 200 / 45.8 ms `{models:[]}` observation with no intervening generate/unload/kill/retry; `/api/version` was HTTP 200 / 7.3 ms / `0.32.13`. This is raw API expiry/unload evidence, not app-restart or GUI/runtime proof (GAP-LLM-04). |
|
||||
| AI-01 | Local LLM (Ollama) | [~] | [-] | [ ] | [-] | Desktop bundled Ollama. 2026-09-22 guard contract: no boot warmup; suggestion `keep_alive: 2m`; request-owned cancellation; generate/stream 2048 tokens / 120 s and chat 512 / 60 s; `done` frame required with incomplete-stream cleanup; deduplicated Ollama spawn/poll plus lifecycle disposal. GAP-LLM-03 has targeted evidence (6 test files / 69 passed / 0 failed; changed code/tests ESLint and diff check exit 0). Raw Ollama confirms cold timeout cleanup, a 553 ms `num_predict=1`/`keep_alive='2m'` response, and after the about-119.9 s expiry a 19:48:59 +09:00 `/api/ps` HTTP 200 / 45.8 ms `{models:[]}` observation with no intervening generate/unload/kill/retry; `/api/version` was HTTP 200 / 7.3 ms / `0.32.13`. This is raw API expiry/unload evidence, not app-restart or GUI/runtime proof (GAP-LLM-04). **2026-10-11 residency policy (supersedes 2m / later 30m):** single `LOCAL_LLM_KEEP_ALIVE='10m'` for every local request (`services/llm/model-residency.ts`), no boot warmup (first keystroke warms via `SuggestionService._keepWarm`), keep-warm refresh only when <4 min left, and `keep_alive: 0` unload of this app's resident models on quit (`LocalLLMService.unloadResidentModels`). Reason: gemma4:e4b holds ~11.6 GB RAM (5.9 GB pinned host buffer, no mmap on Windows CUDA) — boot warmup took free RAM 7.9 GB→32 MB within 20 s (GAP-PERF-01). |
|
||||
| AI-02 | Cloud LLM (Claude/OpenAI) | [x] | [x] | [x] | [x] | Desktop `PremiumLLMService`; web/mobile via `llm-proxy`; .NET `LlmProxyService` |
|
||||
| AI-03 | Auto Polish (cleanup/filler removal) | [x] | [~] | [~] | [x] | Desktop built-in; web/mobile via commands. Desktop Auto Polish is the plain `refine` action (`llm-prompts.ts:14`), not a custom instruction, so it was **not** affected by the 2026-09-21 instruction-prompt fix (AI-05); regression cases now pin `refine`/`summarize`/`grammar`/`expand` (`VoiceModeService.test.ts:435`, `llm-prompts.test.ts:153`) |
|
||||
| AI-04 | Translate / summarize / rephrase | [~] | [x] | [x] | [x] | Built-in instructions. **Desktop has two paths and only one of them worked.** The plain-action path (Settings → `defaultLLMAction`, `SettingsModal.tsx:653`) reads `BASE_SYSTEM_PROMPTS` directly and was always correct. The built-in *instruction* presets (`CustomInstructionService.ts:26/35/44/53/62`) ran through the custom-instruction path and inserted the instruction's own wording instead of the result — see AI-05. Fixed in `9c2b4d4` (2026-09-21), **not verified in a running app** (`11` GAP-LLM-02). Translate still always targets English: `AppConfig` has no target-language key and neither `language` (UI locale) nor `sttLanguage` (source language) can stand in (`llm-prompts.ts:37-52`, `11` GAP-LLM-01) |
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ Legend: `[ ]` open · `[~]` in progress · `[!]` blocked externally · `[x]` res
|
|||
| GAP-INPUT-04 | Input intelligence | **UIA 브리지가 Windows 전용이다.** `uiautomation` 은 Windows UI Automation 래퍼이므로 macOS 는 AX API, Linux 는 AT-SPI 구현이 따로 필요하다. 그래서 입력 인텔리전스는 카탈로그에서 데스크톱(`D`)만 표기하고 나머지 표면은 `[-]` 다. 또한 Chromium 138 미만 앱은 접근성 트리가 켜져 있으면 입력창 텍스트를 노출하지 않는데, 그 앱들을 `--force-renderer-accessibility` 로 켜도록 강제할 방법이 없다(우리 자신은 `app.setAccessibilitySupportEnabled(true)` 로 처리했다 — `bootstrap.ts`). | `apps/desktop/sidecar/uia_bridge.py`, `apps/desktop/src/main/bootstrap.ts`(`initInputIntelligence`) | macOS AX 경로를 붙일지 결정한다. 붙이지 않으면 카탈로그에서 macOS 를 명시적 N/A 로 유지한다. |
|
||||
| GAP-INPUT-05 | Input intelligence | **수락/닫기 키가 사용자 습관과 충돌할 수 있다.** 기본값을 `Alt+Shift+←/↓/↑` 로 둔 이유는 Tab·Escape·Ctrl+Space 같은 관례 키를 뺏지 않기 위해서다(우리는 키를 삼키지 않으므로 원래 동작이 함께 실행된다). 그 대가는 "Tab 으로 수락" 같은 자연스러운 조작이 아니라는 점이고, 인라인 컴플리션 도구 대부분(Tab)과 다르다. | `packages/core/src/keybinding.ts`(`suggestion-accept`/`next`/`dismiss`), `apps/desktop/src/main/bootstrap.ts`(트리거 구독) | 오버레이가 보일 때만 Tab 을 삼키는 경로(전역 후킹에서 조건부 suppress)를 검토한다. 지금은 불가능하지 않지만 포커스 없는 창에서 키를 가로채는 설계가 필요하다. |
|
||||
| GAP-LLM-03 | LLM | `[x]` **2026-09-22 코드 구현 완료.** 공유 `_abortController`를 요청별 controller로 대체하고 외부 signal을 각 요청에 연결/정리한다. generate/stream은 2048 tokens / 120 s, chat은 512 / 60 s로 제한하며, stream은 `done` frame 없이는 성공 처리하지 않고 불완전 응답을 정리한다. VoiceConversation은 single-flight와 request signal을 통해 local cancel을 실제 chat 취소로 전달한다. | `apps/desktop/src/main/services/LocalLLMService.ts`, `VoiceConversationService.ts` | 독립 표적 검증: 6 test files / 69 tests passed / 0 failed. 변경 코드·테스트 ESLint exit 0, `git diff --check` exit 0. 이는 전체 strict typecheck 또는 GUI 검증이 아니다. 앱 재시작 뒤 동시 제안·음성 요청의 요청별 취소와 `done` 누락 실패 처리는 GAP-LLM-04에서 계속 확인한다. |
|
||||
| GAP-PERF-01 | Memory | `[~]` **2026-10-11 PC 전체 멈춤 = 누수가 아니라 모델 상주 정책.** HEAD 로컬 빌드 실측: 앱 기동 20초 만에 커밋 34.2→52.3 GB, 여유 RAM 7.9 GB→32 MB. 내역은 llama-server(gemma4:e4b) 11.4 GB(`CUDA_Host` pinned 5.9 GB + mmproj 1.1 GB, Ollama 가 Windows CUDA 에서 mmap 을 끈다), Whisper 사이드카(large-v3) 5.8 GB, Electron 8프로세스 약 400 MB(6분간 평탄). 실시간 자막의 보조 모델(large-v3-turbo)은 VRAM 11.8/12 GB 상태에서 로딩에 100.5 s 가 걸려 첫 전사가 타임아웃됐다. 부팅 워밍업·30m 상주는 9/22 에 한 번 제거됐다가 콜드 로딩 UX 때문에 되돌아온 이력이 있다(GAP-LLM-04, GAP-INPUT-06). | `services/llm/model-residency.ts`, `LocalLLMService.ts`, `SuggestionService.ts`, `bootstrap.ts`, `sidecar/main.py`(`/unload`), `LocalSTTService.releaseAuxModel`, `CaptionService.stop`, `VoiceModeService`(`tailAudio`), `VoiceConversationService`(5분 상한), `ipc/audio-handlers.ts`(세대 가드), `CloudSyncService.startRealtime`(단일 실행 + `removeChannel`), `MeetingModeService._saveWav` | 수정 완료(데스크톱 vitest 2545 passed): keep_alive 10m 단일화·부팅 워밍업 제거·종료 시 언로드·자막 종료 시 보조 STT 모델 언로드·부분 전사 끝부분만 복사·음성 대화 듣기 버퍼 5분 상한·마이크 테스트 재진입 고아 방지·Realtime 바인딩 중복 방지·회의 WAV 저장 concat 제거. **남은 일:** (1) 사이드카 재빌드 전까지 설치본 `sidecar.exe` 엔 `/unload` 가 없어 언로드가 HTTP 404 로 조용히 실패한다, (2) 기본 모델을 텍스트 전용 소형 모델로 바꾸거나 제안 전용으로 분리할지 결정(가장 큰 절감, 품질 확인 필요), (3) primary Whisper idle 언로드, (4) 회의 PCM 을 메모리 대신 디스크로 스트리밍(시간당 115 MB 상주), (5) 받아쓰기 녹음 길이 상한(UX 결정 필요), (6) 수정 후 앱 재시작·자막·타이핑 실측. |
|
||||
| GAP-LLM-04 | LLM | `[~]` **Gemma/Ollama residency·burst·unbounded chat root cause (2026-09-22).** 19:14:12 boot warmup의 `keep_alive: 30m`가 `gemma4:e4b`를 expiry 19:44:12까지 VRAM 3,226,342,521 bytes / context 4096으로 상주시켰다. Windows GPU Engine PID 표본에는 활성 Ollama compute가 없어 무한 추론이 아니라 강제 residency였다. 19:11:17–19:11:58 자동 제안 반복은 기존 900 ms / 12 per min / 5 candidates / 128 tokens / 1-char growth가 허용한 burst였다. 위험 경로는 chat의 무제한 `num_predict`(Ollama 기본 `-1`), timeout·외부 abort 부재, 공유 취소, `done` 없는 EOF 성공, voice cancel 미전파, watchdog의 비취소였다. | `apps/desktop/src/main/services/{LocalLLMService,SuggestionService,VoiceConversationService}.ts`, Ollama `/api/ps` and Windows GPU Engine observations | 구현 계약: boot warmup 제거, suggestion `keep_alive: 2m`; 600 ms debounce / 5 s interval / 6 per min (hard max 12) / 3 candidates / 64 tokens / 12-char growth / 8 s timeout; 요청별 cancellation, bounded requests, done/cleanup, voice single-flight, spawn/poll dedupe와 dispose. Raw Ollama 증거: cold bounded 요청은 client hard timeout 15.044 s에 취소된 뒤 `/api/ps` empty와 `/api/version` 80 ms 회복을 보였고, explicit warmup HTTP 200은 16.639 s, 후속 `num_predict=1` / `keep_alive='2m'` 요청은 553 ms HTTP 200 / `done:true` / `eval_count:1` / `response=OK` / `done_reason:length`였으며 `/api/ps` expiry는 약 119.9 s였다. 이어 19:48:59 +09:00에는 새 generate/unload/kill/retry 없이 충분히 지난 뒤 단일 `/api/ps`가 HTTP 200 / 45.8 ms / `{models:[]}`였고 `/api/version`은 HTTP 200 / 7.3 ms / `0.32.13`이었다. 이는 raw API 수준의 expiry 뒤 unload 확인이다. **남은 조건:** 앱 재시작·GUI·실제 자동제안 타이핑 증거는 아니므로 그 경로에서 rate limit, timeout/cancel, 2분 residency를 확인한다. |
|
||||
| GAP-INPUT-06 | Input intelligence | `[~]` **제안 폭주 상한 및 runtime 확인.** 이전 24.7 s / 4.9 s, boot warmup, `keep_alive: 30m`, 48/96/128 tokens 및 2/5 candidates 기록은 역사적 가설/완화 이력이며 현재 정책이 아니다. 현 정책은 600 ms debounce, 5 s minimum interval, 6 requests/min default (hard max 12), 3 candidates, 64 output tokens, 12-character growth, 8 s timeout, `keep_alive: 2m` 및 boot warmup 제거다. | `apps/desktop/src/main/services/SuggestionService.ts`, `packages/core/src/input-intelligence.ts`, `LocalLLMService.ts` | 표적 자동 검증은 6 files / 69 passed / 0 failed이며 raw Ollama의 15.044 s cold timeout cleanup, 약 119.9 s residency expiry, 그리고 19:48:59 +09:00에 새 generate/unload/kill/retry 없이 확인한 `/api/ps` HTTP 200 / 45.8 ms / `{models:[]}` (`/api/version` HTTP 200 / 7.3 ms / `0.32.13`)도 확인됐다. 전체 strict typecheck는 green이 아니며, 이 raw API unload 증거는 앱 재시작·GUI·실제 자동제안 타이핑 검증이 아니다. 그 경로에서 rate limit, 8 s abort, 3-candidate/64-token 상한을 확인한다. |
|
||||
| GAP-INPUT-08 | Input intelligence | `[~]` **오타 자동 교정(INPUT-19)·문맥 제안(INPUT-20) 실앱 확인 (2026-10-03).** 자동 테스트와 실제 `gemma4:e4b` 프롬프트 프로브는 통과했지만, 외부 앱에서 "백스페이스 N + 붙여넣기" 교체가 정확히 동작하는지는 GUI 로 확인하지 않았다. | `apps/desktop/src/main/services/{TypoCorrectionService,SuggestionService,PersonalGraphService,TextInsertService}.ts`, `packages/core/src/{typo-correction,writing-context,personal-graph}.ts` | `run-desktop.bat` 재시작 후 메모장·카톡·크롬 입력창에서: (1) `됬어요 ` 치고 멈추면 `됐어요 ` 로 바뀌는지, (2) 한글 문장 중 `dkssudgktpdy` 가 `안녕하세요` 로 바뀌는지, (3) 교체 도중 계속 치면 교체가 취소되고 글이 섞이지 않는지, (4) 고친 단어를 원래대로 되돌리면 다시 고치지 않는지, (5) 앱마다 백스페이스 한 번이 한 글자를 지우는지(리치 에디터·웹 에디터), (6) 교정 뒤 제안이 고친 문장 기준으로 뜨는지. 문제가 있는 앱은 제외 목록 또는 앱별 차단 규칙으로 다룬다. |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue