Red Hat's patch slows down overloading in Perl

Vipul Ved Prakash, long-time CPAN author and creator of Vipul's Razor, has reported a big slowdown in Red Hat's Perl package.

Some investigation revealed that there’s a long standing bug in Redhat Perl that causes *severe* performance degradation on code that uses the bless/overload combo. The thread on this is here: https://bugzilla.redhat.com/show_bug.cgi?id=379791.

Vipul's analysis is a beautiful rundown of how these kinds of things should be reported, and the techie details should help you decide whether you want to rebuild Perl from source, or wait for updated packages for RHEL and Fedora.

Pete Krawczyk sent me a few comments:

RedHat acknowledges that their patching of Perl caused slowness; if you're doing serious work with default Perl on RedHat, you might want to consider building your own until a proper patch comes along. The problem currently affects Fedora 9, RedHat 5 and spin-offs like CentOS 5. The main symptom is exponential slowdown during operations involving overloaded operators; many common modules (such as JSON and URI) are also affected.

Some other links:

And here's my code to illustrate the slowdown, based on the original code in Vipul's article:

#!/usr/bin/perl

use Time::HiRes;
use overload q(<) => sub {};

my %h;

$|++;

print "Pass#\tPass time\tTotal time\n";
my $bigstart = Time::HiRes::time();
for my $i ( 1..50 ) {
    my $start = Time::HiRes::time();
    for my $j ( 1..1000 ) {
        $h{$i*1000 + $j} = bless [ ] => 'main';
    }
    my $now = Time::HiRes::time();
    printf( "#%2d\t%f\t%f\n", $i, $now-$start, $now-$bigstart );
}

Categories

4 Comments

I'm shocked, shocked to find that Redhat has screwed up Perl again!

Pedro Melo Author Profile Page said:

err... For quite some time DBIx::Class warns people about this.

Check http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/StartupCheck.pm

Its not the same bug id but it feels the same.

Dave Cross Author Profile Page said:
The problem currently affects Fedora 9, RedHat 5 and spin-offs like CentOS 5.
I don't think that's quite accurate. It seems to work fine on Fedora 9 - which ships with 5.10 installed. Here are my results from running Vipul's test program on Centos 5.2:
$ time ./perlbug 
..................................................
real	1m14.662s
user	0m43.267s
sys	0m0.100s

And Fedora 9:

$ time ./perlbug 
..................................................
real	0m0.279s
user	0m0.220s
sys	0m0.012s

Nick's blog post on the issue seems to back this up too.

It has been a different matter for 5.10.0 in Fedora. For that, the maintainer has been very communicative, and so we were able to help him fix problems and get Perl 5.10.0 into Fedora Core 9.
Dave Rolsky Author Profile Page said:

The title of this post is a bit off. What is slowed down is object creation, for objects that do overloading. It's not the overloading itself that is slowed down. If it were just that, it'd be a much smaller problem.

Leave a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About this Entry

This page contains a single entry by Andy Lester published on August 25, 2008 4:49 PM.

How cool Perl 6 really is was the previous entry in this blog.

Perl 6 apps today: November is a wiki written in Perl 6 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Other Perl Sites

Other Swell Blogs

  • geek2geek: An ongoing analysis of how geeks communicate, how we fail and how to fix it.
Technorati Profile