On 10/01/14 07:27, Bernd Edlinger wrote:
Hi Jeff,
as you know, this test case takes too long to complete if the test suite is run
with
this command line:
MALLOC_PERTURB_=237 make -k check
The reason was found in libcpp/charset.c, where a reallocation is done one byte
at a time.
It seems to be in the macro expansion of this construct:
#define t16(x) x x x x x x x x x x x x x x x x
#define M (sizeof (t16(t16(t16(t16(t16(" ")))))) - 1)
libcpp is calling realloc 1.000.000 times for this, resizing
the memory by just one byte at a time.
And the worst case of
realloc is O(n), so in the worst case realloc would have
to
copy 1/2 * 1.000.000^2 bytes = 500 GB of memory.
With the change that you suggested, we increase the memory allocation by 25%,
and now
the complete test suite gives exactly the same results with or wihout
MALLOC_PERTURB_ .
Boot-strapped and regression-tested with and without MALLOC_PERTURB_
Ok for the trunk?
Thanks,
Bernd.
patch-libcpp.diff
2014-10-01 Bernd Edlinger<bernd.edlin...@hotmail.de>
Jeff Law<l...@redhat.com>
* charset.c (convert_no_conversion): Reallocate memory with 25%
headroom.
OK.
Jeff