Repository navigation
Keep the local Whisper model resident between dictations - #13
Merged
Merged
Conversation
Under memory pressure macOS paged the idle model out, so the first request after a quiet period took 14 s instead of about 1 s. Wire the warm-up working set with MLX, cap the idle buffer cache (3.9 GB -> 1.9 GB footprint), and stop running the LaunchAgent as throttled Background work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Dictation latency was inconsistent. On a 16 GB Apple Silicon Mac under memory pressure (about 8.7 GB of swap in use), the first request to an idle local Whisper service took 14.2 s for a 7.5 s clip. The next requests took 0.96–1.1 s.
vmmapshowed the service at a 3.9 GB footprint, with most of the model's Metal buffers swapped out. Two causes:ProcessType: Background, so launchd throttles the service's CPU and disk I/O, including paging the model back in.Change
server.pymx.set_wired_limit(peak + 256 MiB), capped at 90% of the system's recommended working set, so the model can't be paged out. Whisper always decodes padded 30 s windows, so the warm-up peak matches a real request.CLEARFLOW_KEEP_RESIDENT=0opts out. The ready log line reports the wired size.install-agent.py:ProcessTypechanges fromBackgroundtoInteractive.local-stt/README.md: documents the memory trade-off (about 2.3 GB kept resident).Validation
python3 -m unittest discover -s local-sttpasses (22 tests), including new checks for the wired-limit calculation and the agent's process type.wiredMiB: 2295. Footprint dropped from 3.9 GB to 1.9 GB, and warm latency held at 0.92–0.97 s.Risks
CLEARFLOW_KEEP_RESIDENT=0to trade back.Backgrounduntilinstall-agent.pyis rerun.