This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix performance break-down in gcc.c-torture/unsorted/dump-noaddr.c
- From: Jeff Law <law at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 01 Oct 2014 17:01:51 -0600
- Subject: Re: [PATCH] Fix performance break-down in gcc.c-torture/unsorted/dump-noaddr.c
- Authentication-results: sourceware.org; auth=none
- References: <DUB118-W45FC2C564AE2430EA2C380E4B80 at phx dot gbl>
On 10/01/14 07:27, Bernd Edlinger wrote:
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
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?
2014-10-01 Bernd Edlinger<firstname.lastname@example.org>
* charset.c (convert_no_conversion): Reallocate memory with 25%