Navigation Menu

Skip to content

Commit

Permalink
temporary fix for [perl #121975] COW speedup lost after e8c6a47
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
demerphq committed May 29, 2014
1 parent c174bf3 commit ce861ea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sv.c
Expand Up @@ -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);
Expand All @@ -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. */
Expand Down

0 comments on commit ce861ea

Please sign in to comment.