Add an option for fast compiling

If you have any suggestions or ideas about improving Salix, here's the place to post them.

Add an option for fast compiling

Postby starsc » 13. Oct 2011, 17:27

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?
starsc
 
Posts: 19
Joined: 5. Oct 2011, 17:21

Re: Add an option for fast compiling

Postby thenktor » 13. Oct 2011, 17:41

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)
last.fm (my last.fm profile)
User avatar
thenktor
Salix Wizard
 
Posts: 2396
Joined: 6. Jun 2009, 14:47
Location: Franconia

Re: Add an option for fast compiling

Postby coroner » 12. Nov 2011, 17:12

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"
coroner
 
Posts: 15
Joined: 12. Nov 2011, 16:59

Re: Add an option for fast compiling

Postby Shador » 12. Nov 2011, 18:09

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
Shador
Salix Warrior
 
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Add an option for fast compiling

Postby coroner » 13. Nov 2011, 03:56

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. :)
coroner
 
Posts: 15
Joined: 12. Nov 2011, 16:59

Re: Add an option for fast compiling

Postby Shador » 13. Nov 2011, 13:12

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
Shador
Salix Warrior
 
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria


Return to Suggestions