perl malloc slow?

Holger Kipp Holger.Kipp at alogis.com
Tue Jan 6 03:29:15 PST 2004


Happy new year to all!

I experience an interesting Problem with perl (both 5.0 and 5.8.0) and
Compress::Zlib::memGunzip on FreeBSD 4.9-STABLE (Oct. 28th 2003):

Uncompressing a larger ascii-file (200-300kB compressed, 20-40MB
uncompressed) in memory takes a ___long____ time (the larger the
uncompressed file, the more time it takes per extracted MB):

uncompressed size
 5 MB   => ca.   25 seconds  ( 5 seconds/MB)
40 MB   => ca. 1200 seconds  (30 seconds/MB)

gunzip only needs slightly more than 1 second for the 40MB file.
I don't have this problem with SuSE Linux 8.1 where extraction
with memGunzip only needs about 1.5 seconds and with gunzip
around 0.5 seconds (Linux is on a faster system).

I am not sure if this problem still exists with CURRENT.

Searching on the internet gave the impression that this might be
malloc/FreeBSD related. Any chance of this being resolved?

Regards,
Holger Kipp

Example perl program:

--- 8< -------------------------------------------------------
  use Compress::Zlib;
  use Time::HiRes qw(gettimeofday tv_interval) ;

  my $start = [ gettimeofday ] ;

  my $file = shift ;
  open FILE, "<$file" || die "Cannot open file $file: $!\n" ;
  undef $/ ;
  my $in = <FILE>;
  close FILE ;

  my $out = Compress::Zlib::memGunzip($in);

  die "undefined\n" if ! defined $out ;

  open FILE, ">$file.tmp" || die "Cannot open file $file: $!\n" ;
  print FILE $out;

  my $elapsed = tv_interval ( $start, [gettimeofday]);

  print "elapsed time is $elapsed\n" ;
--- 8< -------------------------------------------------------


More information about the freebsd-stable mailing list