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:

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:


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 );


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

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


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

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.

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

Job hunting for programmers

Land the Tech Job You Love, Andy Lester's guide to job hunting for programmers and other technical professionals, is available in PDF, ePub and .mobi formats, all DRM-free, as well as good old-fashioned paper.