New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Carp backtrace performance #16195
Comments
From @bdracoCreated by @bdracoPlease see attached patch Perl Info
|
From @bdracoThe patch is attached. |
From @bdraco0001-Optimize-format_arg-_cgc-and-utf-8-downgrade-calls-i.patchFrom a40b93e033fbfcab7fb97a722c2909da5a139db5 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@cpanel.net>
Date: Thu, 12 Oct 2017 01:57:36 -0500
Subject: [PATCH] Optimize format_arg,_cgc, and utf-8 downgrade calls in
Carp.pm
---
dist/Carp/Changes | 14 ++++++++++++++
dist/Carp/lib/Carp.pm | 21 +++++++++++----------
dist/Carp/lib/Carp/Heavy.pm | 2 +-
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..3ebf87fd81 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,17 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
+ The format_arg call now avoids the expensive logic for
+ checking each argument if the argument will not have
+ CARP_TRACE such as a simple hashref or arrayref.
+ In testing this decreased the Carp backtrace time by about
+ 35% in production code.
+
+ * Reduce overhead of checking for caller() being overridden
+
+ * Avoid a utf-8 downgrade when there are only printable ASCII characters
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 6127b26f54..4109998a6a 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -116,7 +116,7 @@ BEGIN {
;
}
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
our $MaxEvalLen = 0;
@@ -159,8 +159,7 @@ sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ }
sub _cgc {
no strict 'refs';
- return \&{"CORE::GLOBAL::caller"} if defined &{"CORE::GLOBAL::caller"};
- return;
+ return defined &{"CORE::GLOBAL::caller"} ? \&{"CORE::GLOBAL::caller"} : undef;
}
sub longmess {
@@ -280,11 +279,11 @@ sub caller_info {
# Transform an argument to a function into a string.
our $in_recurse;
sub format_arg {
- my $arg = shift;
+ my ($arg) = @_;
if ( ref($arg) ) {
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && UNIVERSAL::isa( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;
@@ -332,12 +331,14 @@ sub format_arg {
substr $arg, $i, 1, sprintf("\\x{%x}", $o)
unless is_safe_printable_codepoint($o);
}
- } else {
+ downgrade($arg, 1);
+ } elsif ($arg =~ tr{"\\@$}{} || $arg =~ tr/ !"\$\%#'()*+,\-.\/0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz\{|}~//c) {
$arg =~ s/([\"\\\$\@])/\\$1/g;
# This is all the ASCII printables spelled-out. It is portable to all
# Perl versions and platforms (such as EBCDIC). There are other more
# compact ways to do this, but may not work everywhere every version.
$arg =~ s/([^ !"#\$\%\&'()*+,\-.\/0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz\{|}~])/sprintf("\\x{%x}",ord($1))/eg;
+ downgrade($arg, 1);
}
downgrade($arg, 1);
return "\"".$arg."\"".$suffix;
@@ -383,7 +384,7 @@ sub get_status {
# Takes the info from caller() and figures out the name of
# the sub/require/eval
sub get_subname {
- my $info = shift;
+ my ($info) = @_;
if ( defined( $info->{evaltext} ) ) {
my $eval = $info->{evaltext};
if ( $info->{is_require} ) {
@@ -397,7 +398,7 @@ sub get_subname {
# this can happen on older perls when the sub (or the stash containing it)
# has been deleted
- if ( !defined( $info->{sub} ) ) {
+ elsif ( !defined( $info->{sub} ) ) {
return '__ANON__::__ANON__';
}
@@ -409,9 +410,9 @@ sub get_subname {
sub long_error_loc {
my $i;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
++$i;
- my $cgc = _cgc();
my @caller = $cgc ? $cgc->($i) : caller($i);
my $pkg = $caller[0];
unless ( defined($pkg) ) {
@@ -508,8 +509,8 @@ sub short_error_loc {
my $cache = {};
my $i = 1;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
- my $cgc = _cgc();
my $called = $cgc ? $cgc->($i) : caller($i);
$i++;
my $caller = $cgc ? $cgc->($i) : caller($i);
diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm
index 4b8cbe1b94..84b1106545 100644
--- a/dist/Carp/lib/Carp/Heavy.pm
+++ b/dist/Carp/lib/Carp/Heavy.pm
@@ -2,7 +2,7 @@ package Carp::Heavy;
use Carp ();
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
# Carp::Heavy was merged into Carp in version 1.12. Any mismatched versions
--
2.14.2
|
From @jkeenanOn Thu, 12 Oct 2017 07:36:50 GMT, bdraco wrote:
I have made this patch available for smoke-testing in the following branch: smoke-me/jkeenan/132274-carp-backtrace Would it be possible to add some description of the motivation for this patch to this RT? Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @bdracoHi James, In our production code we log failures with a backtrace. We use this patch to reduce the overhead of doing so because the amount of time it was taking to the format_arg call was having noticeable impact on production machines. On Thu, 12 Oct 2017 05:53:23 -0700, jkeenan wrote:
|
From zefram@fysh.orgJ. Nick Koston via RT wrote:
I'm dubious about this change. There's a trivial bug here in that this repetition of the ASCII printable Even if done correctly, I question the value of this extra conditional But even stranger is the additional downgrade operations, quite Overall, it looks like this patch was formulated against an older Generally I question the value of making this code more complicated in
The changes of this type (and some others) are just distracting.
This change makes no actual difference to execution, because in all -zefram |
From @bdracoOn Thu, 12 Oct 2017 08:21:40 -0700, zefram@fysh.org wrote:
It may be my ignorance here, but I don't know how to combine them when one has a 'c' on the end
It will save time and avoid the downgrade if I merged the patch correctly. I've attached the fixed on to this.
Fixed the forward merge conflict in the attached patched.
|
From @bdraco0001-Optimize-format_arg-_cgc-and-utf-8-downgrade-calls-i.patchFrom 4d98ed451064ea7564516046f04b936bc49f423f Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@cpanel.net>
Date: Thu, 12 Oct 2017 01:57:36 -0500
Subject: [PATCH] Optimize format_arg,_cgc, and utf-8 downgrade calls in
Carp.pm
---
dist/Carp/Changes | 14 ++++++++++++++
dist/Carp/lib/Carp.pm | 22 +++++++++++-----------
dist/Carp/lib/Carp/Heavy.pm | 2 +-
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..3ebf87fd81 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,17 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
+ The format_arg call now avoids the expensive logic for
+ checking each argument if the argument will not have
+ CARP_TRACE such as a simple hashref or arrayref.
+ In testing this decreased the Carp backtrace time by about
+ 35% in production code.
+
+ * Reduce overhead of checking for caller() being overridden
+
+ * Avoid a utf-8 downgrade when there are only printable ASCII characters
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 6127b26f54..bfd4e3d88f 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -116,7 +116,7 @@ BEGIN {
;
}
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
our $MaxEvalLen = 0;
@@ -159,8 +159,7 @@ sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ }
sub _cgc {
no strict 'refs';
- return \&{"CORE::GLOBAL::caller"} if defined &{"CORE::GLOBAL::caller"};
- return;
+ return defined &{"CORE::GLOBAL::caller"} ? \&{"CORE::GLOBAL::caller"} : undef;
}
sub longmess {
@@ -280,11 +279,11 @@ sub caller_info {
# Transform an argument to a function into a string.
our $in_recurse;
sub format_arg {
- my $arg = shift;
+ my ($arg) = @_;
if ( ref($arg) ) {
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && UNIVERSAL::isa( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;
@@ -332,14 +331,15 @@ sub format_arg {
substr $arg, $i, 1, sprintf("\\x{%x}", $o)
unless is_safe_printable_codepoint($o);
}
- } else {
+ downgrade($arg, 1);
+ } elsif ($arg =~ tr{"\\@$}{} || $arg =~ tr/ !"#\$\%\&'()*+,\-.\/0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz\{|}~//c) {
$arg =~ s/([\"\\\$\@])/\\$1/g;
# This is all the ASCII printables spelled-out. It is portable to all
# Perl versions and platforms (such as EBCDIC). There are other more
# compact ways to do this, but may not work everywhere every version.
$arg =~ s/([^ !"#\$\%\&'()*+,\-.\/0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]^_`abcdefghijklmnopqrstuvwxyz\{|}~])/sprintf("\\x{%x}",ord($1))/eg;
+ downgrade($arg, 1);
}
- downgrade($arg, 1);
return "\"".$arg."\"".$suffix;
}
@@ -383,7 +383,7 @@ sub get_status {
# Takes the info from caller() and figures out the name of
# the sub/require/eval
sub get_subname {
- my $info = shift;
+ my ($info) = @_;
if ( defined( $info->{evaltext} ) ) {
my $eval = $info->{evaltext};
if ( $info->{is_require} ) {
@@ -397,7 +397,7 @@ sub get_subname {
# this can happen on older perls when the sub (or the stash containing it)
# has been deleted
- if ( !defined( $info->{sub} ) ) {
+ elsif ( !defined( $info->{sub} ) ) {
return '__ANON__::__ANON__';
}
@@ -409,9 +409,9 @@ sub get_subname {
sub long_error_loc {
my $i;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
++$i;
- my $cgc = _cgc();
my @caller = $cgc ? $cgc->($i) : caller($i);
my $pkg = $caller[0];
unless ( defined($pkg) ) {
@@ -508,8 +508,8 @@ sub short_error_loc {
my $cache = {};
my $i = 1;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
- my $cgc = _cgc();
my $called = $cgc ? $cgc->($i) : caller($i);
$i++;
my $caller = $cgc ? $cgc->($i) : caller($i);
diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm
index 4b8cbe1b94..84b1106545 100644
--- a/dist/Carp/lib/Carp/Heavy.pm
+++ b/dist/Carp/lib/Carp/Heavy.pm
@@ -2,7 +2,7 @@ package Carp::Heavy;
use Carp ();
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
# Carp::Heavy was merged into Carp in version 1.12. Any mismatched versions
--
2.14.2
|
From zefram@fysh.orgJ. Nick Koston via RT wrote:
It turns into one tr///c, with the character set consisting of those
Downgrade of an already-downgraded string is dirt cheap. Comparing it The only part of the patch that looks potentially worthwhile is the -zefram |
From @bdracoOn Thu, 12 Oct 2017 09:43:48 -0700, zefram@fysh.org wrote:
I have re-worked the patch and removed the downgrade optimization. |
From @bdraco0001-Optimize-format_arg-and-_cgc-calls-in-Carp.pm.patchFrom 2b6d84c8f79d520997f2f88d4e3d82c7f28d2f15 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@cpanel.net>
Date: Thu, 12 Oct 2017 01:57:36 -0500
Subject: [PATCH] Optimize format_arg and _cgc calls in Carp.pm
---
dist/Carp/Changes | 12 ++++++++++++
dist/Carp/lib/Carp.pm | 17 ++++++++---------
dist/Carp/lib/Carp/Heavy.pm | 2 +-
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..ad523ddd48 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,15 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
+ The format_arg call now avoids the expensive logic for
+ checking each argument if the argument will not have
+ CARP_TRACE such as a simple hashref or arrayref.
+ In testing this decreased the Carp backtrace time by about
+ 35% in production code.
+
+ * Reduce overhead of checking for caller() being overridden
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 6127b26f54..c42a701b8e 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -116,7 +116,7 @@ BEGIN {
;
}
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
our $MaxEvalLen = 0;
@@ -159,8 +159,7 @@ sub export_fail { shift; $Verbose = shift if $_[0] eq 'verbose'; @_ }
sub _cgc {
no strict 'refs';
- return \&{"CORE::GLOBAL::caller"} if defined &{"CORE::GLOBAL::caller"};
- return;
+ return defined &{"CORE::GLOBAL::caller"} ? \&{"CORE::GLOBAL::caller"} : undef;
}
sub longmess {
@@ -280,11 +279,11 @@ sub caller_info {
# Transform an argument to a function into a string.
our $in_recurse;
sub format_arg {
- my $arg = shift;
+ my ($arg) = @_;
if ( ref($arg) ) {
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && UNIVERSAL::isa( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;
@@ -383,7 +382,7 @@ sub get_status {
# Takes the info from caller() and figures out the name of
# the sub/require/eval
sub get_subname {
- my $info = shift;
+ my ($info) = @_;
if ( defined( $info->{evaltext} ) ) {
my $eval = $info->{evaltext};
if ( $info->{is_require} ) {
@@ -397,7 +396,7 @@ sub get_subname {
# this can happen on older perls when the sub (or the stash containing it)
# has been deleted
- if ( !defined( $info->{sub} ) ) {
+ elsif ( !defined( $info->{sub} ) ) {
return '__ANON__::__ANON__';
}
@@ -409,9 +408,9 @@ sub get_subname {
sub long_error_loc {
my $i;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
++$i;
- my $cgc = _cgc();
my @caller = $cgc ? $cgc->($i) : caller($i);
my $pkg = $caller[0];
unless ( defined($pkg) ) {
@@ -508,8 +507,8 @@ sub short_error_loc {
my $cache = {};
my $i = 1;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
- my $cgc = _cgc();
my $called = $cgc ? $cgc->($i) : caller($i);
$i++;
my $caller = $cgc ? $cgc->($i) : caller($i);
diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm
index 4b8cbe1b94..84b1106545 100644
--- a/dist/Carp/lib/Carp/Heavy.pm
+++ b/dist/Carp/lib/Carp/Heavy.pm
@@ -2,7 +2,7 @@ package Carp::Heavy;
use Carp ();
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
# Carp::Heavy was merged into Carp in version 1.12. Any mismatched versions
--
2.14.2
|
From @SmylersJ. Nick Koston via RT writes:
Hi, Nick. Unfortunately your latest patch still has some trivial This one stood out to me: - return \&{"CORE::GLOBAL::caller"} if defined &{"CORE::GLOBAL::caller"}; That would change what the function returns in list context: a list Now it may well be that function could never be called in list context. It isn't that changes like this make the code worse. It isn't even that It's that merely making unnecessary changes like this increases the Smylers |
From @bdracoHi Smylers, Thank you for the explanation. I have reduced the noise in the patch and re-attached. -Nick On Thu, 12 Oct 2017 14:59:44 -0700, smylers@stripey.com wrote:
|
From @bdraco0001-Optimize-format_arg-and-_cgc-calls-in-Carp.pm.patchFrom 0a97074a77bd722316a782f3b55e5a50fa2de060 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@cpanel.net>
Date: Thu, 12 Oct 2017 01:57:36 -0500
Subject: [PATCH] Optimize format_arg and _cgc calls in Carp.pm
---
dist/Carp/Changes | 12 ++++++++++++
dist/Carp/lib/Carp.pm | 10 +++++-----
dist/Carp/lib/Carp/Heavy.pm | 2 +-
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..ad523ddd48 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,15 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
+ The format_arg call now avoids the expensive logic for
+ checking each argument if the argument will not have
+ CARP_TRACE such as a simple hashref or arrayref.
+ In testing this decreased the Carp backtrace time by about
+ 35% in production code.
+
+ * Reduce overhead of checking for caller() being overridden
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 6127b26f54..06b9051bec 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -116,7 +116,7 @@ BEGIN {
;
}
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
our $MaxEvalLen = 0;
@@ -280,11 +280,11 @@ sub caller_info {
# Transform an argument to a function into a string.
our $in_recurse;
sub format_arg {
- my $arg = shift;
+ my ($arg) = @_;
if ( ref($arg) ) {
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && UNIVERSAL::isa( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;
@@ -409,9 +409,9 @@ sub get_subname {
sub long_error_loc {
my $i;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
++$i;
- my $cgc = _cgc();
my @caller = $cgc ? $cgc->($i) : caller($i);
my $pkg = $caller[0];
unless ( defined($pkg) ) {
@@ -508,8 +508,8 @@ sub short_error_loc {
my $cache = {};
my $i = 1;
my $lvl = $CarpLevel;
+ my $cgc = _cgc();
{
- my $cgc = _cgc();
my $called = $cgc ? $cgc->($i) : caller($i);
$i++;
my $caller = $cgc ? $cgc->($i) : caller($i);
diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm
index 4b8cbe1b94..84b1106545 100644
--- a/dist/Carp/lib/Carp/Heavy.pm
+++ b/dist/Carp/lib/Carp/Heavy.pm
@@ -2,7 +2,7 @@ package Carp::Heavy;
use Carp ();
-our $VERSION = '1.43';
+our $VERSION = '1.44';
$VERSION =~ tr/_//d;
# Carp::Heavy was merged into Carp in version 1.12. Any mismatched versions
--
2.14.2
|
From zefram@fysh.orgJ. Nick Koston via RT wrote:
This still has a bunch of noise. The *only* parts of the patch that are -zefram |
From @atoomicI came with a very minimal patch, readable online p5h/perl5demo#31 On Thu, 12 Oct 2017 20:31:55 -0700, bdraco wrote:
|
From @atoomic0001-Carp-optimize-format_arg-when-arguments-contain-many.patchFrom cf420df5c15793318fbe4811a8a1900e8d4eb874 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@cpanel.net>
Date: Thu, 12 Oct 2017 01:57:36 -0500
Subject: [PATCH] Carp: optimize format_arg when arguments contain many
references
RT #132274
This is a very minimal patch after RT discussion.
---
dist/Carp/Changes | 4 ++++
dist/Carp/lib/Carp.pm | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..db187e9443 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,7 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 623558aada..08dc73e439 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -284,7 +284,7 @@ sub format_arg {
if ( ref($arg) ) {
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && UNIVERSAL::isa( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;
--
2.13.6 (Apple Git-96)
|
From @atoomicnote version bump is not required as it already occurred since v5.27.5 release On Wed, 15 Nov 2017 11:01:02 -0800, atoomic@cpan.org wrote:
|
From @xsawyerxOn 11/15/2017 09:25 AM, Zefram wrote:
Can you please clarify this statement?
What do you mean by "OK"? Do you mean "relevant" or "correct" or "can be |
From zefram@fysh.orgSawyer X wrote:
I mean "suitable to be applied". Of the other parts, the Changes patch The various no-op parts of the patches that have been proposed on this -zefram |
From @atoomicso the minimal patch still breaks UNIVERSAL::isa on CPAN... I will also submit the extra patch to UNIVERSAL::isa to avoid the infinite loop on Carp.... If no one has objections on this minor&light patch I will merge it in the next day. thanks On Wed, 15 Nov 2017 11:01:02 -0800, atoomic@cpan.org wrote:
|
From @atoomic0001-Carp-optimize-format_arg-when-arguments-contain-many.patchFrom dd951f261eaf8b800d00d3cf8f6ea5ce5b2eee6e Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@cpanel.net>
Date: Thu, 12 Oct 2017 01:57:36 -0500
Subject: [PATCH] Carp: optimize format_arg when arguments contain many
references
RT #132274
This is a very minimal patch after RT discussion.
Note version bump is not required as it already occurred
since v5.27.5 release.
---
dist/Carp/Changes | 4 ++++
dist/Carp/lib/Carp.pm | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dist/Carp/Changes b/dist/Carp/Changes
index 0498eeb885..db187e9443 100644
--- a/dist/Carp/Changes
+++ b/dist/Carp/Changes
@@ -1,3 +1,7 @@
+version 1.44
+
+ * Optimize format_arg when arguments contain many references
+
version 1.43
* fix problems introduced by the partial EBCDIC support from version
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
index 623558aada..3c5764cefc 100644
--- a/dist/Carp/lib/Carp.pm
+++ b/dist/Carp/lib/Carp.pm
@@ -283,8 +283,13 @@ sub format_arg {
my $arg = shift;
if ( ref($arg) ) {
+
+ # lazy check if the CPAN module UNIVERSAL::isa is used or not
+ # if we use a rogue version of UNIVERSAL this would lead to infinite loop
+ my $isa = $UNIVERSAL::isa::VERSION ? sub { 1 } : \&UNIVERSAL::isa;
+
# legitimate, let's not leak it.
- if (!$in_recurse &&
+ if (!$in_recurse && $isa->( $arg, 'UNIVERSAL' ) &&
do {
local $@;
local $in_recurse = 1;
--
2.13.6 (Apple Git-96)
|
From @atoomicmerged to blead with 915a681 On Wed, 15 Nov 2017 22:01:37 -0800, atoomic@cpan.org wrote:
|
@atoomic - Status changed from 'open' to 'pending release' |
From @atoomicfixed up the release version after 5.27.6.... via 8510c6c On Tue, 21 Nov 2017 13:37:30 -0800, atoomic@cpan.org wrote:
|
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#132274 (status was 'resolved')
Searchable as RT132274$
The text was updated successfully, but these errors were encountered: