Repository navigation
engine: note that --cpus does not change the reported CPU count - #26348
Open
manunicholasjacob wants to merge 1 commit into
Open
manunicholasjacob wants to merge 1 commit into
manunicholasjacob wants to merge 1 commit into
Conversation
The CPU section explains --cpus as a share of host CPU time but does not say that the operating system inside the container still reports every host CPU. Programs that size a thread pool from that count oversubscribe the quota and get throttled. Add a short paragraph with a getconf example for --cpus, a note that some nproc builds read the quota and others do not, and an nproc example for --cpuset-cpus. Verified on Docker Engine 29.1.3 (cgroup v2, 20-CPU host) with ubuntu:24.04 and ubuntu:26.04. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi, I just wanted to note that we changed the behavior in GNU coreutils 9.8 to follow cgroup v2 CPU quotas. See the following commit: coreutils/coreutils@c4df55b Of course, many images will use older versions, so I don't think it necessarily invalidates your patch. However, I figured you may find that information useful. |
This branch has not been deployed
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.
Description
The CPU section of the resource constraints page explains
--cpusas a share of host CPU time, but it doesn't say that the operating system inside the container still reports every host CPU. Programs that size a thread pool from that count start more busy threads than the quota can run, and the container gets throttled for most of each period.This adds a short paragraph after the
--cpu-period/--cpu-quotaexample: agetconfexample for--cpus, a note thatnprocbehaves differently depending on the image, and annprocexample for--cpuset-cpus.Checked on Docker Engine 29.1.3 (WSL2 kernel 6.18, cgroup v2, 20 logical CPUs), three runs each, all identical:
Because
nprocdepends on the image (ubunturesolves to 26.04, whosenprocreads the quota), the--cpusexample usesgetconf _NPROCESSORS_ONLN, which reported 20 in every image I tried. The--cpuset-cpusexample keepsnproc, since it reads the CPU affinity; the text limits that advice to programs that read their affinity, becausegetconfand Python'sos.cpu_count()still report 20 under--cpuset-cpus=0,1.As a measured example of the effect: in llama.cpp's
llama-benchunder--cpus=2, the default thread count (10) was throttled in 98.6% of CFS periods and decoded at 17.06 tok/s, against 52.83 tok/s with-t 2(ggml-org/llama.cpp#30070).Lint on the changed file with the versions the repo pins: Vale 3.17.0 reports 0 errors, 0 warnings and 0 suggestions, and rumdl 0.2.49 reports no issues.
Related issues or tickets
None found. Older issues about the
cpusflags (#5106, #6979, #5622) are closed and don't cover the reported CPU count.Reviews
This change and description were drafted with help from an AI assistant (Claude). The outputs above come from runs on my own machine.