develooper Front page | perl.perl5.porters | Postings from January 2008

[PATCH] Big slowdown in 5.10 @_ parameter passing

Thread Next
From:
Rick Delaney
Date:
January 6, 2008 11:14
Subject:
[PATCH] Big slowdown in 5.10 @_ parameter passing
Message ID:
20080106191439.GF13935@bort.ca
On Jan 05 2008, David Landgren wrote:
> This Week on perl5-porters - 22 December 2007-29 December 2007

Hooray for summaries!  Three cheers for David and his beneficiaries!

> Big slowdown in 5.10 @_ parameter passing
> 
>   Yves Orton forwarded a message from the DBIx-Class mailing list, where
>   they had discovered with horror that
> 
>     my ($x, $y, $z) = @_;
> 
>   has become unacceptably slow in 5.10 (whereas a semantically
>   equivalent code block using "shift" ran as swiftly as ever). Dave
>   Mitchell discovered that the optimiser had become confused, and was
>   running the list assignment through the code path that spends the
>   extra cycles that makes sure that
> 
>     ($x, $y) = ($y, $x)
> 
>   works as expected. That is, extra care has to be taken when there are
>   variables common to both sides of the assignment, otherwise things get
>   clobbered.
> 
>     wish they had taken 5.10 for a spin earlier
>     http://xrl.us/bdtgx
> 
>   Paul Johnson identified the patch responsible. No solution as yet.
> 
>     it was just a teeny bug fix
>     http://public.activestate.com/cgi-bin/perlbrowse?patch=28488

The attached patch fixes the issue Dave Mitchell points out but I don't
think it has much effect on performance.  I assume the benchmarks in the
above linked thread are to point out different cycles/sec for the
different perl versions?  If not, I don't understand what they are
supposed to show.  For difference between the two perls as large as the
benchmarks show, I'd bet the 5.10 perl was built with DEBUGGING.

Anyway, the small performance to be gained by avoiding OPpASSIGN_COMMON
when unnecessary (which I estimate at none) should be regained with this
patch.  As a bonus, there should now be no difference in performance
between

    my ($x, $y);

and

    (my $x, my $y);

.

-- 
Rick Delaney
rick@bort.ca

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About