shirleyian / pentoo

Automatically exported from code.google.com/p/pentoo
1 stars 1 forks source link

LiveCD: Script to auto configure stuff in make.conf #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Script to auto configure cpu number in make.conf
================================================
I often run Pentoo from usb sticks on different computers.
They have different numbers of cpu cores, so I wrote a script to auto-edit 
make.conf accordingly.

Placed in /etc/local.d/ and made executable, it works like a charm.

Example:
========
We have 8 cpu cores, so anything like:

    MAKEOPTS=”-j2
    MAKEOPTS=”-j2 -l1“
    MAKEOPTS=”${MAKEOPTS} -j5 -l3.85“
    EMERGE_DEFAULT_OPTS=”${EMERGE_DEFAULT_OPTS} -j4 –load-average=3.75“

becomes this:

    MAKEOPTS=”-j9
    MAKEOPTS=”-j9 -l7.95“
    MAKEOPTS=”${MAKEOPTS} -j9 -l7.95“
    EMERGE_DEFAULT_OPTS=”${EMERGE_DEFAULT_OPTS} -j8 –load-average=7.85“

Optional
========
I always replace this:
MAKEOPTS="-j2 -l1"
with:
MAKEOPTS="${MAKEOPTS} -j5 -l3.95"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} -j4 --load-average=3.85"
FEATURES="${FEATURES} parallel-fetch"

The script processes both, but we could add some of that to the default 
make.conf in the repo IMHO.

Original issue reported on code.google.com by Wuod...@gmail.com on 10 Dec 2012 at 6:17

Attachments:

GoogleCodeExporter commented 9 years ago
Wouldn't this override what the user wants? I don't want it to automatically 
trounce what the user sets. I wonder if we could set this as bash environment 
in the profile if it would work... remind me to talk to zmedico next week when 
I'm not underwater.

Original comment by sidhayn on 11 Dec 2012 at 9:56

GoogleCodeExporter commented 9 years ago
Don't do it on startup, this is bad idea. Change default settings once and let 
user to control his computer.

We can probably use that script during installation process.

Original comment by blshkv on 11 Dec 2012 at 11:39

GoogleCodeExporter commented 9 years ago
I was thinking we can remove the lines from make.conf and have the profile set 
sane defaults and then the user can override as normal in make.conf.

This does require a little testing and magic on my end though, so give me a 
week.

Original comment by sidhayn on 12 Dec 2012 at 6:37

GoogleCodeExporter commented 9 years ago
Interesting:
http://blogs.gentoo.org/ago/2013/01/14/makeopts-jcore-1-is-not-the-best-optimiza
tion/

Please test with -j${core} and change the script if required.

Original comment by blshkv on 14 Jan 2013 at 10:36

GoogleCodeExporter commented 9 years ago
local CORES="$(grep -c ^proc /proc/cpuinfo)"
echo ${MAKEOPTS} | grep -q -e -j || export MAKEOPTS="-j${CORES} -l${CORES}"

I've added this to profile.bashrc

If the user doesn't have MAKEOPTS set, it will set default to use all cores as 
much as possible without going over the load.

Next livecd will not set MAKEOPTS at all by default

I cannot find a way to do the same for EMERGE_DEFAULT_OPTS yet, so this bug 
stays open

Original comment by sidhayn on 24 Jan 2013 at 8:41

GoogleCodeExporter commented 9 years ago
While we have a bug for it let's tune INPUT_DEVICES and VIDEO_CARDS as well.  
Obviously that needs to be done in the installer, but the same is likely going 
to be true for EMERGE_DEFAULT_OPTS

Original comment by sidhayn on 24 Jan 2013 at 8:50