3

I have a perl script which does some mysql connections to fire select query. I used DBI perl module to do the same.

Sometimes it consumes 100% cpu and does nothing. I got gdb backtrace of the live process while it was consuming 99% to 100% cpu.

#0  0x0000003990a7c680 in memcpy () from /lib64/libc.so.6
#1  0x0000003992ae6e27 in Perl_regexec_flags () from /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
#2  0x0000003992a922d5 in Perl_pp_subst () from /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
#3  0x0000003992a8a39e in Perl_runops_standard () from /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
#4  0x0000003992a37ecc in perl_run () from /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
#5  0x00000000004017bc in main ()

what should i do ? (I am using CentOS release 5.8 (Final) kernel-2.6.18-308.el5)

4

1 回答 1

1

有时,即使在数据量适中的情况下,正则表达式处理也可能需要很长时间。

假设你有一个这样的正则表达式:

my $data =~ s!.*findit:(.+)!$1!gis;

这个正则表达式做同样的事情,但它要快得多:

my $data =~ s!\A.*findit:(.+)\z!$1!is;
于 2013-07-19T15:59:17.113 回答