develooper Front page | perl.perl5.porters | Postings from August 2013

[perl #116326] COW: big slowdown in simple pattern matches

Thread Next
From:
Father Chrysostomos via RT
Date:
August 3, 2013 00:54
Subject:
[perl #116326] COW: big slowdown in simple pattern matches
Message ID:
rt-3.6.HEAD-2552-1375491281-1348.116326-15-0@perl.org
On Mon Jan 07 04:53:20 2013, davem wrote:
> 
> This is a bug report for perl from davem@iabyn.com,
> generated with the help of perlbug 1.39 running under perl 5.17.8.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> Since the following commit:
> 
>     commit cd298ce42eb3c82a651608c3fbd658ec616b0297
>     Merge: 08bf00b f5a0fd1
>     Author:     Father Chrysostomos <sprout@cpan.org>
>     AuthorDate: Tue Nov 27 07:08:08 2012 -0800
>     Commit:     Father Chrysostomos <sprout@cpan.org>
>     CommitDate: Tue Nov 27 07:08:50 2012 -0800
> 
>         [Merge] New COW mechanism
> 
> The code below takes about 3 times longer to execute:
> 
>     $a = ("-" x 100);
>     for (1..100_000) {
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>         $a =~ /---/;
>     }
> 
> It's because of the following in pp_match:
> 
>     :         s = CALLREG_INTUIT_START(rx, TARG, (char *)s, (char
> *)strend,
>     :                                         r_flags, NULL);
>     :
>     :         if (!s)
>     :             goto nope;
>     : #ifdef PERL_SAWAMPERSAND
>     :         if ( (RX_EXTFLAGS(rx) & RXf_CHECK_ALL)
>     :              && !PL_sawampersand
>     :              && !(RX_EXTFLAGS(rx) & RXf_PMf_KEEPCOPY)
>     :              && !SvROK(TARG))
>     :             goto yup;
>     : #endif
>     :     }
>     :     if (!CALLREGEXEC(rx, (char*)s, (char *)strend,
> (char*)truebase,
> 
> 
> The #ifdef was added by the COW merge.
> 
> In this case, the call to intuit successfully matches quickly,
> and previously this would in simple cases (e.g. no captures) trigger
> an
> immediate return (goto yup) and skip the full match; this test is now
> disabled, so it always does the full match.

4d2e8fb57 fixed this, didn’t it?

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=116326

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