This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
temporary fix for [perl #121975] COW speedup lost after e8c6a474
authorYves Orton <demerphq@gmail.com>
Thu, 29 May 2014 09:33:56 +0000 (11:33 +0200)
committerYves Orton <demerphq@gmail.com>
Thu, 29 May 2014 09:34:07 +0000 (11:34 +0200)
Disable use of Perl_safesysmalloc_size by default. Only use it when PERL_USE_MALLOC_SIZE is defined.

Using Perl_safesysmalloc_size() perl cannot tell a deliberately preallocated buffer
which we probably dont want to COW from a malloc() preallocated buffer where we probably
dont care. Hopefully this fixes the slowdown observed on some platforms.

sv.c

diff --git a/sv.c b/sv.c
index 06c0b83..ac1d972 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -1574,14 +1574,19 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen)
         newlen++;
 #endif
 
+#if defined(PERL_USE_MALLOC_SIZE) && defined(Perl_safesysmalloc_size)
+#define PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC
+#endif
+
     if (newlen > SvLEN(sv)) {          /* need more room? */
        STRLEN minlen = SvCUR(sv);
        minlen += (minlen >> PERL_STRLEN_EXPAND_SHIFT) + 10;
        if (newlen < minlen)
            newlen = minlen;
-#ifndef Perl_safesysmalloc_size
-        if (SvLEN(sv))
+#ifndef PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC
+        if (SvLEN(sv)) {
             newlen = PERL_STRLEN_ROUNDUP(newlen);
+        }
 #endif
        if (SvLEN(sv) && s) {
            s = (char*)saferealloc(s, newlen);
@@ -1593,7 +1598,7 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen)
            }
        }
        SvPV_set(sv, s);
-#ifdef Perl_safesysmalloc_size
+#ifdef PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC
        /* Do this here, do it once, do it right, and then we will never get
           called back into sv_grow() unless there really is some growing
           needed.  */