Fail model load early when free RAM is below the catalog estimate - #251
Merged
Conversation
Before WhisperKit starts, refuse loads that cannot fit in installed or available memory so the spinner does not hang (vocamac#250).
✅ Deploy Preview for voca-mac canceled.
|
Swift imports the probe as Int; coerce non-positive readings to zero so availableMemoryBytes matches its UInt64 return type.
os_proc_available_memory is unavailable on macOS and broke App CI. Use free+inactive pages from HOST_VM_INFO64 instead; return 0 on probe failure.
CI free+inactive pages often sit under Medium's 5 GB estimate, so the new pre-load check rejected mock medium loads and broke serialization/restore tests.
jatinkrmalik
marked this pull request as ready for review
September 4, 2026 01:45
|
| Filename | Overview |
|---|---|
| Sources/VocaMac/Models/AppState.swift | Adds the preflight refusal before loading-state mutations and leaves any active model untouched when memory is insufficient. |
| Sources/VocaMac/Services/SystemInfo.swift | Adds installed- and available-memory capacity checks using free plus inactive Darwin pages with balanced Mach-port cleanup. |
| Tests/VocaMacTests/AppStateTests.swift | Verifies that rejection avoids a Whisper load and preserves the previously loaded model and selection. |
| Tests/VocaMacTests/Mocks/MockServices.swift | Makes test model loads deterministic by bypassing host-memory variability unless a test explicitly overrides the gate. |
| Tests/VocaMacTests/ModelTests.swift | Covers insufficient physical memory, insufficient available memory, unavailable probe data, and sufficient capacity. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Request model load] --> B{Concrete model size known?}
B -- No --> D[Continue existing load flow]
B -- Yes --> C{Installed and available memory meet estimate?}
C -- No --> E[Show error and preserve active model]
C -- Yes --> D
D --> F[Start WhisperKit/CoreML load]
Reviews (5): Last reviewed commit: "Use free+inactive only for the low-RAM p..." | Re-trigger Greptile
jatinkrmalik
marked this pull request as draft
September 4, 2026 01:56
Refuse the load without restoring or clearing an already loaded model. Count speculative, purgeable, and compressor pages in the host probe, and release the mach_host_self send right.
Empty commit so Greptile re-scores the low-RAM gate fixes after the prior review on 8108205. No code changes.
Member
Author
|
@greptileai please re-review the current head (low-RAM gate fixes in e47f66a + empty retrigger commit). |
Do not add speculative pages on top of free_count (Darwin already includes them), and drop compressor pages which still occupy RAM.
Member
Author
|
@greptileai please re-review eaf05b9 — VM accounting now uses free+inactive+purgeable only (no speculative double-count, no compressor). |
Purgeable often overlaps the inactive queue on Darwin, so summing both overstates reclaimable memory. Keep the gate conservative.
Member
Author
|
@greptileai please re-review 94c7c65 — available memory is free+inactive only (no speculative/purgeable/compressor overcount). |
jatinkrmalik
marked this pull request as ready for review
September 4, 2026 07:34
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.
Summary
Fixes #250. Before WhisperKit/CoreML starts, refuse a load when installed RAM or
os_proc_available_memory()is below that model's catalog estimate. The UI shows an error instead of spinning forever under memory pressure.Test plan
SystemInfo.canFitModelInMemoryphysical / available / unknown / enough casesKnown limits
size == nil) skips the gate until a concrete size is known