fix(cli): detect macOS logical CPU count via sysctl, not just nproc - #5642
Merged
gabsprogrammer merged 1 commit intoSep 19, 2026
Merged
gabsprogrammer merged 1 commit into
gabsprogrammer merged 1 commit into
Conversation
_get_host_logical_cpus() probes `nproc` then `/proc/cpuinfo`, both of which are Linux-only. On macOS neither exists, so the chain always fell through to the degenerate `echo "1"`. That value backs _get_docker_available_cpus()'s fallback, so whenever Docker's own NCPU is unavailable an Apple-silicon host computes its llama-server / bundled- service CPU budget as a single core and throttles the stack. Probe `sysctl -n hw.logicalcpu` (macOS/BSD) between the two Linux sources. Order is preserved on Linux (nproc still wins first), so this only changes the previously-broken macOS path. This is the ods-cli sibling of the same nproc-only gap being fixed for installers/lib/detection.sh in Osmantic#5564 / Osmantic#2827; those PRs do not touch ods-cli. Adds tests/test-ods-cli-host-cpu-fallback.sh (wired into `make test`), which proves the sysctl fallback deterministically by stubbing nproc unavailable, and asserts the true count on a real macOS host. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
ods-cli's_get_host_logical_cpus()reports 1 logical CPU on macOS:cores=$(nproc 2>/dev/null || grep -c '^processor' /proc/cpuinfo 2>/dev/null || echo "1")nprocand/proc/cpuinfoare Linux-only; on macOS both fail and the chain falls through toecho "1". That value backs_get_docker_available_cpus()'s fallback (used whendocker info --format {{.NCPU}}is unavailable), and the result caps the per-service CPU budget — so an Apple-silicon host provisions llama-server and the bundled services for a single core.Reproduced on macOS:
Fix
Probe
sysctl -n hw.logicalcpu(macOS/BSD) between the two Linux sources. Order is preserved on Linux —nprocstill wins first — so only the previously-broken macOS path changes.Sibling of the same
nproc-only gap being fixed forinstallers/lib/detection.shin #5564 / #2827; those PRs do not touchods-cli.Validation
Adds
tests/test-ods-cli-host-cpu-fallback.sh(wired intomake test)._get_host_logical_cpus→1; the new test's stubbed case (nproc unavailable,sysctl→7) returns the Linux/proc/cpuinfocount instead of 7 → FAIL.nprocpresent the result is unchanged (VM: 4 =nproc).bash -nandshellcheck -S error ods-cliclean.Closes 5641