Bug 212592 - Default MAKE_JOBS_NUMBER should come from cpuset, not kern.smp.cpus
Summary: Default MAKE_JOBS_NUMBER should come from cpuset, not kern.smp.cpus
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-11 23:52 UTC by Colin Percival
Modified: 2019-09-05 08:45 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Percival freebsd_committer 2016-09-11 23:52:15 UTC
The default MAKE_JOBS_NUMBER comes from `sysctl -n kern.smp.cpus`.  This is fine in most cases, but if cpuset(1) has been used to limit the CPUs available, we will end up running too many parallel build steps -- one per CPU present, rather than one per CPU available.

Unfortunately cpuset(1) doesn't seem to have an obvious "tell me how many CPUs I have access to" flag, but something like

-_SMP_CPUS!=             ${SYSCTL} -n kern.smp.cpus
+_SMP_CPUS!=             cpuset -g -p $$ | cut -f 2 -d : | tr , '\n' | wc -l

should probably do the job.  (Or, we could just fix cpuset(1) and check OSVERSION to decide whether to query the sysctl or query cpuset.)
Comment 1 Baptiste Daroussin freebsd_committer 2019-09-05 08:45:33 UTC
when trying with:
cpuset -g -p $$ | awk -F: '/^pid [0-9]+ mask/ { print split($$2,a, ",") }'

(your example didn't work out of box, due to cpuset reporting 2 lines now.)

Anyway using this we end up with cpuset: getaffinity: Operation not permitted