Bug#839600: perl: concatenating string instead of sprintf takes all computation power of server

Niko Tyni ntyni at debian.org
Sun Oct 2 19:44:35 UTC 2016


Control: found -1 5.24.1~rc3-3

On Sun, Oct 02, 2016 at 06:40:32PM +0200, Leszek Dubiel wrote:
> Package: perl
> Version: 5.20.2-3+deb8u6
> Severity: normal
> 
> Dear Maintainer,
> 
> >From time to time my server get locked, all computation power was
> consumed by that perl script. 
 
> People were testing program and didn't have the same effect. So it
> appeared that this is problem only on my server. I have moved script to
> another computer with the same version of Debian (jessie, stable), and
> script still did run very slow. Problem dissapeared on new version
> (stretch). I have tested on my ubuntu (run fast), and the same hardware
> under VirtualBox with fresh installation of Debian Jessie -- script did
> run very slow. 
> 
> So the problem exists on current debian stable version (jessie), and
> doesn't exist on newer versions. 

I see this on current sid/amd64 (Perl 5.24) too fwiw, and also in an
amd64 chroot with Perl 5.22. I've no idea why it goes away for you on
stretch. Can you confirm that? Are you only testing on i386 or on amd64
as well?

It looks like the difference between
  $par = "(" . $inp . ")"; # is slow
and
  $par = sprintf "(%s)", $inp; # is fast
internally is that the first one uses copy on write semantics, meaning
it doesn't have to copy the whole string in memory. Of course, this
is supposed to improve performance rather than degrade it.

AFAICS the regexp behaviour stays unchanged, it's just the performance
that drops. I tried some debugging with 'debugperl -Dr' but it mostly
hides the problem by slowing down the execution by itself.

It would be nice to distill the issue to a smaller test case but it's
rather sensitive to the input as you noted so that doesn't seem to be
easy.

Thanks for the report, will try to investigate more.
-- 
Niko Tyni   ntyni at debian.org




More information about the Perl-maintainers mailing list