compile ports and base using both cores

Erik Cederstrand erik at cederstrand.dk
Wed Nov 7 23:01:59 PST 2007


Chris Whitehouse wrote:
> Chris Whitehouse wrote:
>> Hi,
>>
>> Installing ports or upgrading the base system only uses around 50% cpu 
>> utilization (measured with the top utility) on my dual core machine. 
>> Is there some way I can get higher cpu usage?
>>
>> /usr/src/UPDATING says don't use make -j. I tried installing 
>> openoffice.org-2 with make -j 2 but it failed at some stage saying it 
>> couldn't find a directory. It works not using -j.
>>
>> I'm using 7.0-BETA1.5 i386 on an AMD 64 system.
>>
>> Thanks
>>
>> Chris
>>
> Hi again,
> 
> I was wondering if anyone could give me some ideas about this. Btw I 
> confess the subject line is not quite right, I think both cores are 
> being used but cpu is only around 50% - or it is being measured so that 
> it looks like 50% but is really more. If I make buildworld and compile a 
>  port at the same time then cpu usage really does go up to 100%

AFAIK, parallel compilation using 'make -j' is not guaranteed to work. 
The concurrent threads might interfere with or depend on each other. If 
it does work for you then great, you saved some time, but don't submit 
PRs before you have tried compiling without the -j option.

Since make without -j runs single-threaded, it will only use one CPU at 
a time. The scheduler may move the process around between CPUs depending 
on which CPU is more idle at any given time. The reason a simultaneous 
make buildworld and port compilation uses 100% CPU is that these are two 
separate processes which do not interfere with one another, so they can 
be run on the two CPUs simultaneously.

Erik


More information about the freebsd-questions mailing list