Re:Use `nproc` and not grep /proc/cpuinfo
by skizziepop on Thursday November 26, 2020 @07:09PM
(#25224465)
nproc isn't available on some of the BSDs
[ Parent
| on HN ]
Re:Use `nproc` and not grep /proc/cpuinfo
by sigjuice on Thursday November 26, 2020 @08:52PM
(#25224940)
$ nproc
ksh: nproc: not found
$ uname -a
OpenBSD obsd64.example.xyz 6.8 GENERIC.MP#828 arm64
$ sysctl hw.ncpu
hw.ncpu=2
Re:Use `nproc` and not grep /proc/cpuinfo
by oso2k on Thursday November 26, 2020 @07:12PM
(#25224472)
Right. So on Mac or other BSDs, you want use a ‘sysctl’.
Re:Use `nproc` and not grep /proc/cpuinfo
by floatingatoll on Thursday November 26, 2020 @07:30PM
(#25224560)
On Macs, this "total cores available" strategy might not be a valid approach, since you probably only want to be using the high-performance cores and not also the low-power ones — and the CPU might well overbook all your threads to high-perf to leave room for the OS and other programs, even if you try to do otherwise.
Re:Use `nproc` and not grep /proc/cpuinfo
by stewartesmith on Thursday November 26, 2020 @08:31PM
(#25224851)
Not just Macs, plenty of Linux systems have a big.LITTLE design.
with a big.LITTLE system it'll really depend what you're doing. Just compiling something? It's probably fine (if all cores can be active at once). If you're wanting more consistent performance for some calculations? You might need to think a bit more.
Re:Use `nproc` and not grep /proc/cpuinfo
by oso2k on Thursday November 26, 2020 @07:15PM
(#25224483)
Another thought, I don’t know if Alpine Linux or other musl-libc based systems will have ‘nproc’ if, for instance, you’re running containers or other minimal systems.