develooper Front page | perl.perl5.porters | Postings from March 2017

Re: [perl #122099] Perl regression bug since 5.13.11 (masked by CoWsince 5.19.1)

Thread Previous
From:
Dave Mitchell
Date:
March 29, 2017 15:44
Subject:
Re: [perl #122099] Perl regression bug since 5.13.11 (masked by CoWsince 5.19.1)
Message ID:
20170329154404.GM3342@iabyn.com
On Wed, Jun 18, 2014 at 12:45:17PM +0100, Dave Mitchell wrote:
> On Tue, Jun 17, 2014 at 10:17:51AM -0400, Deven T. Corzine wrote:
> > On Fri, Jun 13, 2014 at 5:31 PM, Dave Mitchell <davem@iabyn.com> wrote:
> > 
> > > Fixing this for maint releases would be hard. Simply reverting
> > > acdea6f060081
> > >  would have fairly significant performance issues (and it wouldn't fix my
> > > simpler test case above). The whole OPpASSIGN_COMMON
> > > pessimisation/optimisation thing has been batted backwards and forwards in
> > > various releases, it proving surprisingly tricky to determine all the
> > > cases where there are common elements in a list assignment, and we've at
> > > various times broken performance by being overly cautious (5.10.0?) and/or
> > > broken the perl-level logic by not being cautious enough.
> > >
> > 
> > So what's the solution?  Prioritizing performance over correctness doesn't
> > sound like the right thing to do.  Can the bug be fixed without undue
> > performance impact?
> 
> I can't think of an easy solution. The string swiping code has been there
> for 20+ years, and is a pretty significant optimisation. Without it,
> something like
> 
>     sub f {
>         my $s = .... some very long string ...;
>         return $s;
>     }
> 
>     my $t = f()
> 
> would involve copying the long string multiple times. Its an optimisation
> that's ok 99.9999% of the time.
> 
> The other part of the problem is that perl's argument stack isn't
> reference counted, which is a well-known long-standing bug that is deeply
> non-trivial to fix.
> 
> The only easy way to fix this for your use-case would be for 
> List::MoreUtils::minmax to to make a copy of its second return value if
> both return values map to the same SV. That would be List::MoreUtils
> working round a perl bug, but it's the only simple fix I can think of.

Since then I've heavily reworked list assignment and I think all the
issues described above have been sorted. So I'm closing this ticket.

-- 
In my day, we used to edit the inodes by hand.  With magnets.

Thread Previous


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