Skip to content

Commit ce861ea

Browse files
committed
temporary fix for [perl #121975] COW speedup lost after e8c6a47
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.
1 parent c174bf3 commit ce861ea

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sv.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,14 +1574,19 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen)
15741574
newlen++;
15751575
#endif
15761576

1577+
#if defined(PERL_USE_MALLOC_SIZE) && defined(Perl_safesysmalloc_size)
1578+
#define PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC
1579+
#endif
1580+
15771581
if (newlen > SvLEN(sv)) { /* need more room? */
15781582
STRLEN minlen = SvCUR(sv);
15791583
minlen += (minlen >> PERL_STRLEN_EXPAND_SHIFT) + 10;
15801584
if (newlen < minlen)
15811585
newlen = minlen;
1582-
#ifndef Perl_safesysmalloc_size
1583-
if (SvLEN(sv))
1586+
#ifndef PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC
1587+
if (SvLEN(sv)) {
15841588
newlen = PERL_STRLEN_ROUNDUP(newlen);
1589+
}
15851590
#endif
15861591
if (SvLEN(sv) && s) {
15871592
s = (char*)saferealloc(s, newlen);
@@ -1593,7 +1598,7 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen)
15931598
}
15941599
}
15951600
SvPV_set(sv, s);
1596-
#ifdef Perl_safesysmalloc_size
1601+
#ifdef PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC
15971602
/* Do this here, do it once, do it right, and then we will never get
15981603
called back into sv_grow() unless there really is some growing
15991604
needed. */

0 commit comments

Comments
 (0)