[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Abolish STRANGE_MALLOC?
At the moment we have code conditionally compiled on STRANGE_MALLOC that is
simple and assume that malloc has non-pathological behaviour, and realloc()
is the way to go. Or we have the default which is complex, and prefers
malloc() followed by free(). For example in av.c
#if defined(STRANGE_MALLOC) || defined(MYMALLOC)
Renew(AvALLOC(av),newmax+1, SV*);
#else
bytes = (newmax + 1) * sizeof(SV*);
#define MALLOC_OVERHEAD 16
itmp = MALLOC_OVERHEAD;
while ((MEM_SIZE)(itmp - MALLOC_OVERHEAD) < bytes)
itmp += itmp;
itmp -= MALLOC_OVERHEAD;
itmp /= sizeof(SV*);
assert(itmp > newmax);
newmax = itmp - 1;
assert(newmax >= AvMAX(av));
Newx(ary, newmax+1, SV*);
Copy(AvALLOC(av), ary, AvMAX(av)+1, SV*);
if (AvMAX(av) > 64)
offer_nice_chunk(AvALLOC(av), (AvMAX(av)+1) * sizeof(SV*));
else
Safefree(AvALLOC(av));
AvALLOC(av) = ary;
#endif
ie pretty much everywhere we compiling that code in the #else.
Should we just get rid of it all, and assume that malloc()/realloc()/free()
work these days? I tried with perlbench on x86 FreeBSD and Linux.
A, D, E are normal perl. B, C, F were also compiled with -DSTRANGE_MALLOC
A B C D E F
---- ---- ---- ---- ---- ----
AVERAGE (FreeBSD) 100 100 100 100 100 100
AVERAGE (Linux) 100 99 100 101 101 99
So it seems to make little difference here.
Is there a good reason to keep it, and the code complexity?
Nicholas Clark
- Follow-Ups from:
-
Andy Dougherty <doughera@lafayette.edu>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]