# Question about Ports system and SMP



## dkrypt (Jun 1, 2009)

Hi all,

Just a quick question that someone should hopefully be able to answer for me pretty easily.

With the Ports system, assuming you have an SMP kernel, does the compiler use all cores for compiling the ports you install, or is there a configuration file pertaining to the ports system that a flag (e.g. -j3) needs to be added to?

Just want to squeeze every drop of power I can out of my dual Opteron system I've installed FreeBSD 7.2 on  

Thanks!


----------



## SirDice (Jun 1, 2009)

Usually, while compiling, the bottleneck is I/O. Not so much the processor. But yes, adding the -j flag would be the flag. You can either add it on the command line or add it to /etc/make.conf.


----------



## ale (Jun 1, 2009)

If a port supports parallel build, _-j_ with a number equal to the core number will be passed to the port Makefile.
This can be controlled and tuned. For example, look in /usr/ports/bsd.port.mk and search for _MAKE_JOBS_SAFE_.


----------



## dkrypt (Jun 1, 2009)

Thank you SirDice.

Is it like the make.conf in gentoo linux where you add something along the lines of MAKE_OPTS="-j3"?

Just having trouble finding information on how to do this (perhaps I'm not searching for the right terms?)



			
				SirDice said:
			
		

> Usually, while compiling, the bottleneck is I/O. Not so much the processor. But yes, adding the -j flag would be the flag. You can either add it on the command line or add it to /etc/make.conf.


----------



## SirDice (Jun 1, 2009)

dkrypt said:
			
		

> Is it like the make.conf in gentoo linux where you add something along the lines of MAKE_OPTS="-j3"?


I don't know Gentoo but it looks similar. Have a look at the examples in */usr/share/examples/etc/make.conf* and the man page make.conf(5).


----------



## dkrypt (Jun 1, 2009)

Unfortunately I've already gone through them and can't see anywhere where you can specify how many processes to kick off.

Perhaps there is no way?



			
				SirDice said:
			
		

> I don't know Gentoo but it looks similar. Have a look at the examples in */usr/share/examples/etc/make.conf* and the man page make.conf(5).


----------



## ale (Jun 1, 2009)

Did you read my post?


----------



## dkrypt (Jun 1, 2009)

There's no such file in that location?



			
				ale said:
			
		

> Did you read my post?


----------



## ale (Jun 1, 2009)

dkrypt said:
			
		

> There's no such file in that location?


Sorry, I've missed the Mk dir
/usr/ports/Mk/bsd.port.mk


----------



## phoenix (Jun 1, 2009)

It's all done automatically, now.

If a port is known to work correctly with "make -j", then it will have MAKE_JOBS_SAFE set in the Makefile, and it will automatically use as many jobs as there are CPU cores.

If a port is known to not work with "make -j", then it will have MAKE_JOBS_UNSAFE set in the Makefile, and it will refuse to build if you try to use -j (will only build using 1 CPU core).

All other ports will continue to build using a single CPU core until someone determines that it can use MAKE_JOBS_SAFE or MAKE_JOBS_UNSAFE.


----------

