http://qs321.pair.com?node_id=184652


in reply to relative speed of 5.8.0

I compiled threaded and non-threaded versions of 5.8.0 today and I timed the wc.pl script shown above on a largish file using both 5.8.0's and my earlier 5.6.1. The threaded-5.8.0 was in the neighborhood 50% slower than the 5.6.1 release --- the unthreaded-5.8.0 was about 20% slower. So I decided to run perlbench to compare these three perls and try to pinpoint the problem. Follow the readmore tag for discussion and results ...

The standard perlbench tests did not uncover a cause: Overall 5.8.0 with threads performed about 15% slower than 5.6.1. The only serious areas of slowdown (see below) were for startup costs --- but since that cost is amortized over the runtime of the wc.script, it wouldn't account for the large spread. So I added another directory of tests (xtra/) to test length and split (and open and join) to see if they were the cuplrits (since basic arithmetic had been tested and though the threaded result wasn't pretty, it couldn't account for a 50% relative difference).

The length test showed no big surprise, and while the open is very much slower in 5.8.0 (moreso in the threaded version), it is hardly a factor as only one file was opened when I tested the wc.pl script. (Note: both 5.8.0's were compiled with perlio support, and 5.6.1 was not). Notable, however, is the result for split --- a *very* sizable slowdown for 5.8.0-threaded, and the causative factor of the greater than expected slowdown. Replacing the split call in wc.pl with a constant array and I only saw a 5% difference between 5.6.1 and 5.8.0-threaded --- which is somewhat less of a difference than I might have predicted after viewing the perlbench results.

Someone else might review the 5.8.0 source to see what happened to split and if anything can be done to improve the performance of such an oft-used routine --- as for me, now that I've got two shiny new 5.8.0's, I'm off to CPAN to start fetching packages ...

## results of perlbench ## NOTE: 5.6.1 used -O2, while both 5.8.0's used -O3 (those were the ## defaults for each version). ## Platform is: Linux 2.4.18 A) perl-5.006001 path = /usr/local/bin/perl5.6.1 cc = cc optimize = -O2 ccflags = -fno-strict-aliasing -I/usr/local/include -D_LARGEFI +LE_SOURCE -D_FILE_OFFSET_BITS=64 usemymalloc = n B) perl-5.008 path = /usr/local/bin/perl5.8.0 cc = cc optimize = -O3 ccflags = -fno-strict-aliasing -I/usr/local/include -D_LARGEFI +LE_SOURCE -D_FILE_OFFSET_BITS=64 usemymalloc = n C) perl-5.008 path = /opt/bin/perl5.8.0 cc = cc optimize = -O3 ccflags = -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/u +sr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 usemymalloc = n A B C ---- ---- ---- arith/mixed 100 76 71 arith/trig 100 88 85 array/copy 100 100 99 array/foreach 100 86 71 array/index 100 89 82 array/pop 100 102 83 array/shift 100 104 83 array/sort-num 100 91 63 array/sort 100 96 69 call/0arg 100 103 93 call/1arg 100 93 82 call/2arg 100 91 81 call/9arg 100 96 88 call/empty 100 102 95 call/fib 100 102 91 call/method 100 94 91 call/wantarray 100 97 83 hash/copy 100 115 108 hash/each 100 103 94 hash/foreach-sort 100 100 96 hash/foreach 100 106 99 hash/get 100 94 79 hash/set 100 85 81 loop/for-c 100 94 88 loop/for-range-const 100 94 82 loop/for-range 100 91 81 loop/getline 100 88 85 loop/while-my 100 91 86 loop/while 100 91 84 re/const 100 97 93 re/w 100 94 74 startup/fewmod 100 62 43 startup/lotsofsub 100 95 60 startup/noprog 100 87 68 string/base64 100 102 94 string/htmlparser 100 98 80 string/index-const 100 99 93 string/index-var 100 90 88 string/ipol 100 106 99 string/tr 100 99 99 xtra/join 100 100 96 xtra/length 100 96 87 xtra/open 100 72 44 xtra/split 100 74 41 AVERAGE 100 94 83

The code used to test split is as follows (stored in "t/xtra/split.t" under perlbench):

# Name: Simple split # Require: 4 require 'benchlib.pl'; $_ = "this is just an ordinary string to test with."; &runtest(1,<<'ENDTEST'); my @words = split; ENDTEST __END__