View previous topic :: View next topic |
Author |
Message |
roofy Tux's lil' helper

Joined: 01 Sep 2003 Posts: 86 Location: miami
|
Posted: Wed Nov 12, 2003 5:45 pm Post subject: genmark - gentoo smp benchmarker |
|
|
Tired of trying to find out how many cc1 instances your smp system can handle....try this
Code: |
#!/bin/bash
#Genmark v.05
#very primitive gentoo benchmarker
#licensed under the GPL license
#chanelog
#v.02 removed pointless sed scripts
#v.03 spelling errors
#v.04 improved time framework
#v.05 added the html framework
#future: v.06* sed extracting script, that only outputs real time
#create the varibles
export KERNDIR=/usr/src/linux
export GENMARK=/root/genmark-results.html
#lets clean the kernel directory
echo "Welcome to Genmark v0.05"
echo
echo "Cleaning benchmark tree..."
cd ${KERNDIR}
make clean >>/dev/null
#creating genmark html
touch /root/genmark.results
echo "<html>" > ${GENMARK}
echo "<head><title>Genmark v0.05 Results Page</title></head>" >> ${GENMARK}
echo "<body style=\"font-size: 8pt; font-family: Arial; color: #FFFFFF\" bgcolor=\"black\" >" >> ${GENMARK}
echo "<center><h1>Genmark v0.05 Results</h1></center>" >> ${GENMARK}
#starting baseline test (-j2)
echo "Starting baseline test..."
echo "<center><h2>Baseline results:<h2></center>" >> ${GENMARK}
echo "<center><p>" >> ${GENMARK}
(time make -j2 bzImage >/dev/null 2>&1) 2>>${GENMARK}
echo "</center>" >> ${GENMARK}
#clean the kernel for j3
make clean >>/dev/null
#starting test with -j3
echo "Testing 2 parralel compiler instances..."
echo "<center><h2>Two Compiler instances(-j3):<h2></center>" >> ${GENMARK}
echo "<center><p>" >> ${GENMARK}
(time make -j3 bzImage >/dev/null 2>&1) 2>> ${GENMARK}
echo "</center>" >> ${GENMARK}
#clean the kernel for j4
make clean >>/dev/null
#starting test with -j4
echo "Testing 3 parralel compiler instances..."
echo "<center><h2>Three Compiler instances(-j4):<h2></center>" >> ${GENMARK}
echo "<center><p>" >> ${GENMARK}
(time make -j4 bzImage >/dev/null 2>&1) 2>> ${GENMARK}
echo "</center>" >> ${GENMARK}
#clean the kernel for j5
make clean >>/dev/null
#starting test with -j5
echo "Testing 4 parralel compiler instances..."
echo "<center><h2>Four Compiler instances(-j5):<h2></center>" >> ${GENMARK}
echo "<center><p>" >> ${GENMARK}
(time make -j5 bzImage >/dev/null 2>&1) 2>> ${GENMARK}
echo "</center>" >> ${GENMARK}
#reverting make.conf to original state
echo "Cleaning up.."
echo "</body>" >> ${GENMARK}
echo "</html>" >> ${GENMARK}
make clean >>/dev/null
echo "Point your browser to genmark-results.html, to view your results."
|
its my 1st script tel me what you think
[/code] _________________ /* event horizon */
Athlon XP 2100+ (o/c'ed to 2.1ghz)
LanParty NForce2 Ultra
80GB Maxtor HD
48x CD-RW
ATI 9700 Pro |
|
Back to top |
|
 |
tomchuk Guru

Joined: 23 Mar 2003 Posts: 317 Location: Brooklyn, NY
|
Posted: Thu Nov 13, 2003 5:06 am Post subject: |
|
|
Great Idea.
A couple things I'd change:
1. "Testing 2 parralel compiler instances..." and make -j3 don't go together. The -j number (jobs) is the number of compiler instances.
2. Having make running at the same nice level as everything else won't yeild very reliable results. Opening a transparent terminal during the test would skew the results a noticeable amount.
3. A simple for loop would be a little cleaner that writing everything over and over.
4. In my own experience I see gains on my dualie all the way up to -j13. Although there is only a difference of 4 seconds between -j8 and -j13 so something like -j8 or -j9 may be the sweet spot.
5. Your script doesn't really make much sense for someone with 1 cpu (90%+ of the population). It should check for the number of CPUs and use that number as the baseline number of jobs.
6. The script pukes when not run as root. There should be a chack for this.
7. Not sure why you're touching /root/genmark.results
8. ...and a nitpick: If you to release this under the GPL, you must be a little more specific. ie. version 2 or greater of the GNU General Plublic License. (RMS tends to be a little pissy about these things)
Here's how I'd do it:
Code: |
#!/bin/bash
#
# Genmark
# A general purpose benchmarking script
#
# (c) roofy
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
if [ `whoami` != "root" ]
then
echo "Please run this script as root"
exit 1
fi
KERNDIR=/usr/src/linux
GENMARK=/root/genmark-results.html
NUM_CPU=`grep -c processor /proc/cpuinfo`
J_LEVELS=$NUM_CPU
for N in 1 2 3 4 5 6 7 8 9 10
do
let NEXT=$NUM_CPU+$N
J_LEVELS="$J_LEVELS $NEXT"
done
echo -e "<html>\n\t<head>\n\t\t<title>Results Page</title>\n\t</head>\n\t \
<body style=\"font-size: 8pt; font-family: Arial; color: #FFFFFF\" bgcolor=\"black\">\n \
\t\t<center><h1>Genmark v0.05 Results</h1></center>" > $GENMARK
echo
cd $KERNDIR
for M in $J_LEVELS
do
make clean > /dev/null
echo "Testing $M parralel compiler instances..."
echo -e "\t\t<center><h2>$M Compiler instances (-j$M):<h2></center> \
\t\t<center><p>" >> $GENMARK
(time nice --adjustment=-10 make -j$M bzImage > /dev/null 2>&1) 2>> $GENMARK
echo -e "\n\t\t</center>" >> $GENMARK
done
echo -e "\t</body>\n</html>" >> $GENMARK
make clean > /dev/null
echo -e "Point your browser to $GENMARK, to view your results.\n"
exit 0
|
Of course, I'm no bash pro either, I've just finished reading through the Advanced Bash Scripting Guide myself. So there's probably a better way to do it than the way I have.
Edit: A note of caution: doing nice --adjustmnet=-10 make -j13 bzImage will bring your computer to its knees. It could take as much as a minute to focus and raise a terminal in X to Cltl-C the scipt. |
|
Back to top |
|
 |
xunil n00b


Joined: 18 Jun 2003 Posts: 36 Location: Blacksburg, VA, USA
|
Posted: Thu Nov 13, 2003 4:27 pm Post subject: |
|
|
If you really want to benchmark your system, you shouldn't be running this script in X in any case. You should boot to single-user mode, stop any extraneous services which are unnecessary for the script, and then run the script.
Here's a suggestion:
Instead of make clean, use make mrproper. It sterlilizes the source tree, so you have to start the kernel build from the absolute beginning (including making a config file). 2.6 kernels include make targets to generate config files w/ certain characteristics:
defconfig: new config with default answer to all options
allmodconfig: new config selecting modules when possible
allyesconfig: new config where all options are accepted with yes
allnoconfig: new minimal config
So, perhaps you can add a command-line option to tell the benchmark which config to make and benchmark against? |
|
Back to top |
|
 |
roofy Tux's lil' helper

Joined: 01 Sep 2003 Posts: 86 Location: miami
|
Posted: Thu Nov 13, 2003 5:38 pm Post subject: |
|
|
good idea, i wish i knew more bash  _________________ /* event horizon */
Athlon XP 2100+ (o/c'ed to 2.1ghz)
LanParty NForce2 Ultra
80GB Maxtor HD
48x CD-RW
ATI 9700 Pro |
|
Back to top |
|
 |
xunil n00b


Joined: 18 Jun 2003 Posts: 36 Location: Blacksburg, VA, USA
|
Posted: Thu Nov 13, 2003 7:16 pm Post subject: |
|
|
Add this near the top:
Code: | if [ "x$1" = "x" ]; then
configtarget="defconfig"
else
configtarget=$1
fi
|
Feel free to replace defconfig w/ any of the other config targets I mentioned in my previous post if you prefer a different default. Then anywhere you make clean, do make mrproper instead, and anywhere you actually build the kernel, do the following instead:
Code: | make $configtarget && make all |
That'll configure the source and (if configuring succeeded) build the kernel and any modules.
One thing to note is that this only works for 2.6 kernels, so you might want to check the source to make sure it's for a 2.6 kernel:
Code: | if grep -e "VERSION[[:space:]]*=[[:space:]]*2" $KERNDIR/Makefile >/dev/null && grep -e "PATCHLEVEL[[:space:]]*=[[:space:]]*6" $KERNDIR/Makefile >/dev/null; then
echo "Sorry! This only works with 2.6 kernels."
exit 1
fi
|
|
|
Back to top |
|
 |
Joffer Guru


Joined: 10 Sep 2002 Posts: 585 Location: Arendal, Norway
|
Posted: Thu Nov 13, 2003 11:13 pm Post subject: |
|
|
tomchuk wrote: | 5. Your script doesn't really make much sense for someone with 1 cpu (90%+ of the population). It should check for the number of CPUs and use that number as the baseline number of jobs. | Just a sidequestion.. would those 90% (I'm one of them) gain anything by raising the 'j-option' to -j3 or more? (I'm using -j2 at the moment as the comments in make.conf says)... |
|
Back to top |
|
 |
tomchuk Guru

Joined: 23 Mar 2003 Posts: 317 Location: Brooklyn, NY
|
Posted: Fri Nov 14, 2003 1:10 am Post subject: |
|
|
Joffer wrote: | tomchuk wrote: | 5. Your script doesn't really make much sense for someone with 1 cpu (90%+ of the population). It should check for the number of CPUs and use that number as the baseline number of jobs. | Just a sidequestion.. would those 90% (I'm one of them) gain anything by raising the 'j-option' to -j3 or more? (I'm using -j2 at the moment as the comments in make.conf says)... |
What I meant is that the baseline in the original script was calculating the time for -j2. An ideal baseline for a UP system would be -j1. Would you benefit? Sure, try increasing the number of jobs untill you stop seeing improvements, or run the script and see what it says. Be warned that if you nice portage to 10 or 15 but use something like -j8 the parallel compiler instances will most likley peg your memeory and disk useage which you'll definately feel in the form or reduced responsiveness. Usually -j(num CPU + 1) is good as it gives your CPU enough to do without making you feel like you're loged in over a dialup connection. |
|
Back to top |
|
 |
|