[Melbourne-pm] Perl much slower on freebsd than solaris

Andrew McNaughton andrewmcnnz at gmail.com
Wed Apr 25 23:05:58 PDT 2012


You're copying a lot of numbers into your hash, and performing hashes on
those numbers.  I suspect then that the value of something like longsize
might be important, and you can see from the perl config info that it's
different.  also ptrsize, use64bitint and use64bitall, ivsize, etc.  the
stackprotector bit probably makes a bit of difference too, but I'd have
expect that to be only a few percent.

What happens if you do it this way?

foreach $i ("0000001" .. "1000000") {
    $i{$i}=$i;
}

I suspect that removes a lot of the 4 byte vs 8 byte bits.

As you say, doubling seems like an upper limit for copying type
operations.  I wonder what the hashing algorithm looks like though.

What's the comparison like if you take both the integer and the hashing
operations out like so?

$p = "1234567";
foreach $i ("0000001" .. "1000000") {
    $p |= $i;
}



Andrew




On 26/04/12 15:17, Tim Hogard wrote:
> Hi,
>
> I'm trying to moving my sparc systems from using solaris 9 over to
> freebsd 9.0 but I'm finding perl to be very slow.
>
> Freebsd 9.0 seemed slow so I fired up this:
> #!/usr/bin/perl
> foreach $i (1..1000000) {
>         $i{$i}=$i;
> }
>
> It takes 4 second on the solaris machine and 24+ seconds on the
> freebsd machine.  I backed up to freebsd 8.3 and perl 5.10.1 and
> had the same results.  My next step is to drop back to the exact
> versions but I don't think the minor version differences are the
> main problem.
>
> Both systems have the same clock speed and model of cpu but the
> free bsd system is slightly slower.
> main() { int i; double a; for(i=0;i<1000000000;i++) { a=i*a; } }
> Takes 12 sec on the sol9 and 16 sec on freebsd.  33% slower is ok,
> 600% is not.
>
> Both systems have a gig of unused memory and haven't touched swap.
> The sol9 server is doing other things like email, squid, web serving
> stuff too.  The freebsds system is not doing anything other than
> these tests.  The sol9 system does have 2 cpus and the freebsd one
> has one but tests of running the programs 4 times in parallel gives
> the correct results of a 2x increase in time for the 2 cpu system
> and a 4x increase for the single cpu.
>
> Does anyone have any hints on where to look next?  I was thinking
> the sol9 was 32 bit so it was moving less data around but that
> should only cover a 2x speed decrease at the worst.  Version details
> are below.
>
> Thanks,
>
> -tim
>
> ---------------------------
> Version info
>
> From the sol 9:
> bash-2.05$ perl -V
> Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
>   Platform:
>     osname=solaris, osvers=2.9, archname=sun4-solaris
>     uname='sunos v210-2 5.9 generic_122300-15 sun4u sparc sunw,netra-210 '
>     config_args='-Dcc=gcc'
>     hint=recommended, useposix=true, d_sigaction=define
>     useithreads=undef, usemultiplicity=undef
>     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
>     use64bitint=undef, use64bitall=undef, uselongdouble=undef
>     usemymalloc=n, bincompat5005=undef
>   Compiler:
>     cc='gcc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
>     optimize='-O',
>     cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
>     ccversion='', gccversion='4.2.3', gccosandvers=''
>     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
>     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
>     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
>     alignbytes=8, prototype=define
>   Linker and Libraries:
>     ld='gcc', ldflags =' -L/usr/local/lib '
>     libpth=/usr/local/lib /usr/lib /usr/ccs/lib
>     libs=-lsocket -lnsl -ldb -ldl -lm -lc
>     perllibs=-lsocket -lnsl -ldl -lm -lc
>     libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
>     gnulibc_version=''
>   Dynamic Linking:
>     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
>     cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
>
>
> Characteristics of this binary (from libperl): 
>   Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
>                         USE_LARGE_FILES USE_PERLIO
>   Built under solaris
>   Compiled at Aug 22 2008 01:59:34
>   @INC:
>     /usr/local/lib/perl5/5.10.0/sun4-solaris
>     /usr/local/lib/perl5/5.10.0
>     /usr/local/lib/perl5/site_perl/5.10.0/sun4-solaris
>     /usr/local/lib/perl5/site_perl/5.10.0
>
>
>
> From the freebsd: (built from source using the Policy from the other machine.  Building from ports was just as slow)
> [thogard at v210-2 ~/src/perl-5.10.1]$ perl -V
> Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
>    
>   Platform:
>     osname=freebsd, osvers=8.3-release, archname=sparc64-freebsd
>     uname='freebsd v210-2.umd.com.au 8.3-release freebsd 8.3-release #0: tue apr 10 03:28:23 utc 2012 root at araz.cse.buffalo.edu:usrobjusrsrcsysgeneric sparc64 '
>     config_args=''
>     hint=recommended, useposix=true, d_sigaction=define
>     useithreads=undef, usemultiplicity=undef
>     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
>     use64bitint=define, use64bitall=define, uselongdouble=undef
>     usemymalloc=n, bincompat5005=undef
> ude',
>     optimize='-O',
>     cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
>     ccversion='', gccversion='4.2.2 20070831 prerelease [FreeBSD]', gccosandvers=''
>     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=87654321
>     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
>     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
>     alignbytes=8, prototype=define
>   Linker and Libraries:
>     ld='cc', ldflags ='-Wl,-E  -fstack-protector -L/usr/local/lib'
>     libpth=/usr/lib /usr/local/lib
>     libs=-lm -lcrypt -lutil -lc
>     perllibs=-lm -lcrypt -lutil -lc
>     libc=, so=so, useshrplib=false, libperl=libperl.a
>     gnulibc_version=''
>   Dynamic Linking:
>     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
>     cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib -fstack-protector'
>
>
> Characteristics of this binary (from libperl): 
>   Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL
>                         USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
>   Built under freebsd
>   Compiled at Apr 26 2012 14:38:36
>   @INC:
>     /usr/local/lib/perl5/5.10.1/sparc64-freebsd
>     /usr/local/lib/perl5/5.10.1
>     /usr/local/lib/perl5/site_perl/5.10.1/sparc64-freebsd
>     /usr/local/lib/perl5/site_perl/5.10.1
>
>
> The sol 9 box uses gcc:
> bash-2.05$ gcc -v
> Using built-in specs.
> Target: sparc-sun-solaris2.9
> Configured with: ./configure --enable-languages=c,c++
> Thread model: posix
> gcc version 4.3.2 (GCC) 
>
> And the freebsd box uses:
> Using built-in specs.
> Target: sparc64-undermydesk-freebsd
> Configured with: FreeBSD/sparc64 system compiler
> Thread model: posix
> gcc version 4.2.2 20070831 prerelease [FreeBSD]
>
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm



More information about the Melbourne-pm mailing list