mirror of git://gcc.gnu.org/git/gcc.git
re PR other/68239 (libbacktrace allocation is sometimes very slow)
PR other/68239 * mmap.c (backtrace_free_locked): Don't put more than 16 entries on the free list. From-SVN: r257039
This commit is contained in:
parent
533277ba75
commit
3fe3c7d749
|
|
@ -1,3 +1,9 @@
|
||||||
|
2018-01-24 Ian Lance Taylor <iant@golang.org>
|
||||||
|
|
||||||
|
PR other/68239
|
||||||
|
* mmap.c (backtrace_free_locked): Don't put more than 16 entries
|
||||||
|
on the free list.
|
||||||
|
|
||||||
2018-01-19 Tony Reix <tony.reix@atos.net>
|
2018-01-19 Tony Reix <tony.reix@atos.net>
|
||||||
|
|
||||||
* xcoff.c (xcoff_incl_compare): New function.
|
* xcoff.c (xcoff_incl_compare): New function.
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,33 @@ struct backtrace_freelist_struct
|
||||||
static void
|
static void
|
||||||
backtrace_free_locked (struct backtrace_state *state, void *addr, size_t size)
|
backtrace_free_locked (struct backtrace_state *state, void *addr, size_t size)
|
||||||
{
|
{
|
||||||
/* Just leak small blocks. We don't have to be perfect. */
|
/* Just leak small blocks. We don't have to be perfect. Don't put
|
||||||
|
more than 16 entries on the free list, to avoid wasting time
|
||||||
|
searching when allocating a block. If we have more than 16
|
||||||
|
entries, leak the smallest entry. */
|
||||||
|
|
||||||
if (size >= sizeof (struct backtrace_freelist_struct))
|
if (size >= sizeof (struct backtrace_freelist_struct))
|
||||||
{
|
{
|
||||||
|
size_t c;
|
||||||
|
struct backtrace_freelist_struct **ppsmall;
|
||||||
|
struct backtrace_freelist_struct **pp;
|
||||||
struct backtrace_freelist_struct *p;
|
struct backtrace_freelist_struct *p;
|
||||||
|
|
||||||
|
c = 0;
|
||||||
|
ppsmall = NULL;
|
||||||
|
for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next)
|
||||||
|
{
|
||||||
|
if (ppsmall == NULL || (*pp)->size < (*ppsmall)->size)
|
||||||
|
ppsmall = pp;
|
||||||
|
++c;
|
||||||
|
}
|
||||||
|
if (c >= 16)
|
||||||
|
{
|
||||||
|
if (size <= (*ppsmall)->size)
|
||||||
|
return;
|
||||||
|
*ppsmall = (*ppsmall)->next;
|
||||||
|
}
|
||||||
|
|
||||||
p = (struct backtrace_freelist_struct *) addr;
|
p = (struct backtrace_freelist_struct *) addr;
|
||||||
p->next = state->freelist;
|
p->next = state->freelist;
|
||||||
p->size = size;
|
p->size = size;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue