Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Hypothesis: some magic string optimalization in perl kills my server from time to time

by tybalt89 (Monsignor)
on Sep 30, 2016 at 13:37 UTC ( [id://1172996]=note: print w/replies, xml ) Need Help??


in reply to Hypothesis: some magic string optimalization in perl kills my server from time to time

I had what I think is a similar problem. When I changed my whitespace eater to

my $ws = qr/(?:#.*|\s+)*+/; # white space

the problem went away. Try it and let us know. Also something like

my $ws = qr/(?:#.*+|\s++)*/; # white space

should work, or

my $ws = qr/(?>(?:#.*|\s+)*)/; # white space

anything that will not give back after matching.

  • Comment on Re: Hypothesis: some magic string optimalization in perl kills my server from time to time
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Hypothesis: some magic string optimalization in perl kills my server from time to time
by leszekdubiel (Scribe) on Sep 30, 2016 at 15:26 UTC

    I have changed to possesive version -- unfortunatelly it didn't help... Still the same effect

    $$a =~ /\G(?:\s++|#.*+)*+\(/gc or croak "parenthesis expected"

      And do you have a small input case where the slowness happens (so I can do testing at home :) ?

        Here is the file -- 200 kilobytes (... small one):

        download from Poland

        download from we transfer

        There is minimal test and description. Below is how I run tests. See -- one is half a seconds, and other is 20 seconds.

        # ./show_me_the_problem.sh **************************** here are the two programs: -rwxr-xr-x 1 root root 177 wrz 30 17:57 run_fast.pl -rwxr-xr-x 1 root root 190 wrz 30 17:57 run_slow.pl **************************** the difference is: 10c10,11 < my $lst = list_extr(\( "(" . $inp . ")" )); --- > my $par = "(" . $inp . ")"; > my $lst = list_extr(\$par); **************************** data is the same... let's run them... time ./run_fast.pl | wc -l 9506 real 0m0.476s user 0m0.456s sys 0m0.016s **************************** time ./run_slow.pl | wc -l 9506 real 0m22.591s user 0m22.556s sys 0m0.012s **************************** seee... programs are almost the same... but their time is totally dife +erent

      Which regex does it stop at?

        The program doesn't stop at any of regexpes. It finishes computations sucessfully, but sometimes it takes quite short, and sometimes it takes very long.

        For example on 2Mb of data, when I call "list_extr" like this:

        list_extr(\( "(" . $big_string . ")" ));

        it takes only half a second. But if I call like this:

        my $ttt = "(" . $big_string . ")"; list_extr(\$ttt);

        it takes 20 seconds (slower 40x times). Why? Both ways look the same -- make string with parentheses around old string, take reference to it, do same computations. So if they are the same why the difference in time? I think perl is doing some magic here, but only someone more expierenced would tell.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1172996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (9)
As of 2024-04-18 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found