On Mon, 2003-11-10 at 21:31, Stas Bekman wrote:
Thanks Perrin for this comparison numbers, but I think you didn't provide enough build information. Default build opts vary from release to release and from OS to OS, you really need to show the whole perl -V to make these numbers more useful.
Well, I'm not trying to do an analysis of compiler optimizations here. I built these the way I suspect almost everyone else does: all
defaults. The main point was to see if there has been a degradation in
performance since 5.6.1, since I have been hearing that a lot. The
results show clearly enough to me that there has not been, and they
agree with my previous benchmarks. They also show that if you don't
need threads, it is very easy to build a Perl that performs
significantly better than the one that comes with Red Hat 9, so it's
worth doing if you are thinking about deploying a mod_perl app on Red
Hat 9 and concerned about performance.
Sure, Perrin, I understand your point. My goal is different, I'm not interested in defaults or perls shipped with distros. I'm interested in providing an advisory on how to build perl in such a way so that you will get the best performance.
Though I think it's also compiled with ithreads, whereas all others are without, so it's not a fair comparison across different perl versions.
That was actually the reason I included it: to get a sense of how much ithreads hurt performance. As you say though, the other options might be affecting it as well.
OK, I did an extensive benchmarking, this time using the same stock perl 5.8.1, built in different ways. Here it is:
OK, let's look at the same perl build differently and make comparisons. In the following comparison you will see the performance variations by as much as 50% without even starting to talk about enabling threads or not, removing threads will further improve the performance by some 20% and may be more. I've manually added -V:config_args, without which the benchmark is incomplete.
A) perl-5.008001 (+shrplib, -ithreads, +perlio)
path = /home/stas/perl/5.8.1/bin/perl
cc = cc
optimize = -g
ccflags = -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
usemymalloc = n
config_args = '-des -Dprefix=/home/stas/perl/5.8.1 -Doptimize=-g -Duseshrplib -Dusedevel';
B) perl-5.008001 (+shrplib, +ithreads, +perlio)
path = /home/stas/perl/5.8.1-ithread/bin/perl
cc = cc
optimize = -g
ccflags = -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
usemymalloc = n
config_args = '-des -Dprefix=/home/stas/perl/5.8.1-ithread -Dusethreads -Doptimize=-g -Duseshrplib -Dusedevel';
C) perl-5.008001 (-shrplib, +ithreads, +perlio)
path = /home/stas/perl/5.8.1-ithread-nouseshrplib/bin/perl
cc = cc
optimize = -g
ccflags = -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
usemymalloc = n
config_args = '-des -Dprefix=/home/stas/perl/5.8.1-ithread-nouseshrplib -Dusethreads -Doptimize=-g -Uuseshrplib -Dusedevel';
D) perl-5.008001 (+shrplib, -ithreads, +perlio)
path = /home/stas/perl/5.8.1-nodebug/bin/perl5.8.1
cc = cc
optimize = -O3
ccflags = -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
usemymalloc = n
config_args='-des -Dprefix=/home/stas/perl/5.8.1-nodebug -Duseshrplib -Dusedevel'
E) perl-5.008001 (-shrplib, -ithreads, -perlio)
path = /home/stas/perl/5.8.1-nouseperlio/bin/perl
cc = cc
optimize = -g
ccflags = -DDEBUGGING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
usemymalloc = n
config_args = '-des -Dprefix=/home/stas/perl/5.8.1-nouseperlio -Doptimize=-g -Uuseperlio -Dusedevel'
F) perl-5.008001 (+shrplib, +ithreads, +perlio)
path = /usr/bin/perl
cc = gcc
optimize = -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro
ccflags = -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
usemymalloc = n
config_args = '-des -Dinc_version_list=5.8.0/i386-linux-thread-multi 5.8.0 5.6.1 5.6.0 -Darchname=i386-linux -Dcc=gcc -Doptimize=-O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dman3ext=3pm -Dcf_by=MandrakeSoft -Dmyhostname=localhost [EMAIL PROTECTED] -Dd_dosuid -Ud_csh -Duseshrplib -Dusethreads'
libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so
A B C D E F
---- ---- ---- ---- ---- ----
arith/mixed 100 59 96 108 107 132
arith/trig 100 108 123 152 133 174
array/copy 100 100 113 121 107 122
array/foreach 100 76 110 131 130 157
array/index 100 68 111 136 127 146
array/pop 100 88 104 133 113 125
array/shift 100 82 99 132 112 122
array/sort-num 100 71 78 135 109 96
array/sort 100 77 86 117 112 103
call/0arg 100 94 112 124 118 149
call/1arg 100 100 108 127 129 149
call/2arg 100 98 105 131 121 146
call/9arg 100 99 122 147 136 164
call/empty 100 87 115 132 118 150
call/fib 100 104 116 133 125 152
call/method 100 85 111 78 97 159
call/wantarray 100 84 122 133 131 152
hash/copy 100 98 117 123 124 139
hash/each 100 96 132 122 123 144
hash/foreach-sort 100 89 112 120 116 143
hash/foreach 100 92 124 137 129 165
hash/get 100 68 69 118 119 115
hash/set 100 101 87 141 137 172
loop/for-c 100 87 111 118 126 158
loop/for-range-const 100 77 98 106 83 126
loop/for-range 100 71 102 121 116 133
loop/getline 100 92 115 146 56 156
loop/while-my 100 57 90 99 126 150
loop/while 100 94 114 124 127 148
re/const 100 96 106 179 117 155
re/w 100 84 83 100 113 121
startup/fewmod 100 78 96 124 112 112
startup/lotsofsub 100 73 97 134 122 111
startup/noprog 100 79 102 101 136 80
string/base64 100 98 112 137 126 148
string/htmlparser 100 85 113 129 126 127
string/index-const 100 73 112 146 122 155
string/index-var 100 79 91 126 112 155
string/ipol 100 82 119 116 127 131
string/tr 100 101 111 165 89 164AVERAGE 100 86 106 128 118 140
So using the average numbers and the major config options I've done a new table sorted from the best performance to the worst.
F (+shrplib, +ithreads, +perlio, -debug) 140 D (+shrplib, -ithreads, +perlio, -debug) 128 E (-shrplib, -ithreads, -perlio, +debug) 118 C (-shrplib, +ithreads, +perlio, +debug) 106 A (+shrplib, -ithreads, +perlio, +debug) 100 B (+shrplib, +ithreads, +perlio, +debug) 86
Conclusions:
1)
F (+shrplib, +ithreads, +perlio, -debug) 140 B (+shrplib, +ithreads, +perlio, +debug) 86
B and F are almost exact the same perl builds (+perlio, +threads, +shrplib). The major difference is that F is built with optimizations '-O2 -fomit-frame-pointer -pipe -march=i586', whereas B is compiled with -DDEBUGGING + -g, which takes the performance down by more than 50% for B! F is Mandrake 9.2 stock Perl.
2)
D (+shrplib, -ithreads, +perlio, -debug) 128 A (+shrplib, -ithreads, +perlio, +debug) 100
D and A are the same builds, and similar to B&F the only difference is debugging enabled in A. As you can see with ithreads disabled enabled debugging affects the performance much less. Still it clearly shows that you don't want the debugging enabled on your production perl.
What puzzles me greatly is that why F w/ ithreads outperforms D w/o ithreads. Go figure. I'm starting to be suspicios of making hard conclusions from running perlbench. The only possible reason I can think of is that:
F: -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro D: -O2 -finline-functions, -fweb, -funit-at-a-time, -ftracer, -funswitch-loops and -frename-registers
F has better a better choice of optimizations. (D has -03 and I have expanded it according to the gcc manpage), e.g., D doesn't use the -mcpu optimization, which may be the crucial factor.
3) I guess I needed quite a few more builds to tell exactly how much enabling each of shrplib, ithreads, perlio affects performance, but you can clearly see that enabling the three of them, brings the performance down by about 30%. Though you can't build ithreads without perlio.
At the moment it looks like if you build your perl with -Uuseshrplib -Uusethreads and don't enable debugging, and use a good selection of optimization flags (like Mandrake 9.2's perl does), you will get the best performance.
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
