Add an option for fast compiling

If you have any suggestions or ideas about improving Salix, here's the place to post them.
Post Reply
starsc
Posts: 19
Joined: 5. Oct 2011, 17:21

Add an option for fast compiling

Post by starsc »

Hi guys,
I think it would be a good thing to add an option in gslapt and in sourcery for sayin' to the compiler the number of cpu, somethin' similar to -j5 ( for my quadcore ) for traditional shell.
What do you think about it? Is it possible for you?
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Add an option for fast compiling

Post by thenktor »

We already have that. Depending on the SLKBUILD or SlackBuild you are compiling this should work:
export numjobs=5
export NUMJOBS="-j5"

EDIT: You can add these lines to your /etc/bashrc
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
coroner
Donor
Posts: 29
Joined: 12. Nov 2011, 16:59
Contact:

Re: Add an option for fast compiling

Post by coroner »

thenktor wrote:We already have that. Depending on the SLKBUILD or SlackBuild you are compiling this should work:
export numjobs=5
export NUMJOBS="-j5"

EDIT: You can add these lines to your /etc/bashrc
Good evening. What do you think about add this strings in profile or bashrc for next realese?

MAX_CPU=`cat /sys/devices/system/cpu/kernel_max`
let "CPU=( MAX_CPU + 2 )"
export numjobs=$CPU
export NUMJOBS="-j$CPU"
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Add an option for fast compiling

Post by Shador »

This outputs 31 on my system? Would be way too much. It's probably up to every user himself to define this variables. Because some users may prefer low number for better interactivity and less loads, some take something in the middle and others (like me) tend to set quite high values to get a decent load onto their CPU or to make use of distcc.

At the other hand I'm not completely opposed to this. But this command would be the way to go:

Code: Select all

getconf _NPROCESSORS_ONLN
I think it's the only solution which works properly on a wide variety of systems. I think it's also no good idea to run more parallel jobs than there are processors.

On a sidenote, some programs can't be built with multiple jobs. So this could introduce problems, although actually in this case the build script should just ignore the variable and default to one job.
Image
coroner
Donor
Posts: 29
Joined: 12. Nov 2011, 16:59
Contact:

Re: Add an option for fast compiling

Post by coroner »

Hi.
You right, all choose what preferring.
This outputs 31 on my system?
Very Interesting, some kind error? Two pc with salixos working correctly.

Code: Select all

getconf _NPROCESSORS_ONLN
Thanks, I didn`t knew this.
p.s. I prefer set to maximum, "sometimes waiting for a compilation like death". sorry, but i do not know how explain more literary language this sentence. :)
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Add an option for fast compiling

Post by Shador »

coroner wrote:
This outputs 31 on my system?
Very Interesting, some kind error? Two pc with salixos working correctly.
That's the maximum number supported by the running kernel. Not the number of cpus available or online. For that you would need to look at '/sys/devices/system/cpu/online'. But CPUs are listed in the form 0-3 (that's e.g. on a 4 processor system).
BTW max_cpu also says 1 here on a dual-core 32bit system, but 31 on 64-bit quad-core system.
Image
Post Reply