using coreutils in production
using coreutils in production
Posted Feb 12, 2025 17:27 UTC (Wed) by intelfx (subscriber, #130118)In reply to: using coreutils in production by garyguo
Parent article: Rewriting essential Linux packages in Rust
> We had some scripts that invoke `nproc` to determine the parallelism to use, and we want to move this into containers. Then we realized that in containers with resource restrictions, `nproc` from coreutils still report number of total cores, but not the amount of CPUs available to it by the cgroup. It turns out that the nproc haven't received meaningful updates since its inception and obviously doesn't know what to do with groups.
You might have been using a very old coreutils. I've been relying on this behavior of coreutils' nproc for a few years already, and as far as I can tell, it very much exists:
# pacman -Qo nproc /usr/bin/nproc is owned by coreutils 9.6-2 # nproc 8 # systemd-run --pipe -p AllowedCPUs=0,1 nproc Running as unit: run-p1960742-i1961042.service 2
