Package: perl-base
Version: 5.8.8-4
Severity: minor
Tags: patch

Hi,

when doing perl coverage analysis with the module Devel::Cover a deep recursion 
warning usually happens:
Deep recursion on subroutine "B::Deparse::find_scope" at 
/usr/lib/perl/5.8.8/B/Deparse.pm line 1321

For preventing this, I rewrote the find_scope function for using a queue 
instead of doing recursions. My complete test set now runs without any deep 
recursion error any more. I also made some benchmark analysis (twice for every 
implementation) and it seems to run almost 10% faster now:

--- with recursion (old) ---
real    0m31.184s
user    0m29.490s
sys     0m0.460s

real    0m31.198s
user    0m29.494s
sys     0m0.448s

--- with queue of objects ---
real    0m30.052s
user    0m28.414s
sys     0m0.400s

real    0m30.277s
user    0m28.542s
sys     0m0.388s

--- with queue of references to objects (new) ---
real    0m29.969s
user    0m28.062s
sys     0m0.392s

real    0m29.609s
user    0m27.974s
sys     0m0.420s

I have not made any analysis on memory consumption yet. But using a queue 
against recursion, should be better too.

Please include this in perl-base. It could be interesting for upstream too.

With kind regards,
  Tobias Lorenz
  

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (910, 'testing-proposed-updates'), (800, 
'unstable'), (700, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.4
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages perl-base depends on:
ii  libc6                         2.3.6-3    GNU C Library: Shared libraries an

perl-base recommends no packages.

-- no debconf information
1308,1322c1308,1327
<     for (my $o=$op->first; $$o; $o=$o->sibling) {
<       if ($o->name =~ /^pad.v$/ && $o->private & OPpLVAL_INTRO) {
<           my $s = int($self->padname_sv($o->targ)->NVX);
<           my $e = $self->padname_sv($o->targ)->IVX;
<           $scope_st = $s if !defined($scope_st) || $s < $scope_st;
<           $scope_en = $e if !defined($scope_en) || $e > $scope_en;
<       }
<       elsif (is_state($o)) {
<           my $c = $o->cop_seq;
<           $scope_st = $c if !defined($scope_st) || $c < $scope_st;
<           $scope_en = $c if !defined($scope_en) || $c > $scope_en;
<       }
<       elsif ($o->flags & OPf_KIDS) {
<           ($scope_st, $scope_en) =
<               $self->find_scope($o, $scope_st, $scope_en)
---
>     my @queue = (\$op);
>     while(@queue) {
>       $op = ${(shift(@queue))};
>       for (my $o=$op->first; $$o; $o=$o->sibling) {
>           if ($o->name =~ /^pad.v$/ && $o->private & OPpLVAL_INTRO) {
>               my $s = int($self->padname_sv($o->targ)->NVX);
>               my $e = $self->padname_sv($o->targ)->IVX;
>               $scope_st = $s if !defined($scope_st) || $s < $scope_st;
>               $scope_en = $e if !defined($scope_en) || $e > $scope_en;
>               return ($scope_st, $scope_en);
>           }
>           elsif (is_state($o)) {
>               my $c = $o->cop_seq;
>               $scope_st = $c if !defined($scope_st) || $c < $scope_st;
>               $scope_en = $c if !defined($scope_en) || $c > $scope_en;
>               return ($scope_st, $scope_en);
>           }
>           elsif ($o->flags & OPf_KIDS) {
>               push(@queue, \$o);
>           }

Reply via email to