This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/5] Add single-threaded path to malloc/realloc/calloc/memalloc
- From: DJ Delorie <dj at redhat dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: libc-alpha at sourceware dot org, nd at arm dot com
- Date: Thu, 12 Oct 2017 16:06:32 -0400
- Subject: Re: [PATCH 2/5] Add single-threaded path to malloc/realloc/calloc/memalloc
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dj at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 96D03C0467C6
Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:
> This patch adds a single-threaded fast path to malloc, realloc,
> calloc and memalloc. When we're single-threaded, we can bypass
> arena_get (which always locks the arena it returns) and just use
> the main arena. Also avoid retrying a different arena.
Does SINGLE_THREAD_P return true if a multi-threaded app joins all its
threads, so that there's only one thread remaining? If so, there will
still be more arenas in play that might be usable, and the remaining
thread might be better served by whatever arena it had been using, due
to data locality on NUMA machines.
I also wonder if there's an upper limit to the main arena, where we'd
have to use other arenas to fully use available VM.
If either of these are issues, it might be better to conditionalize the
lock calls than to duplicate the code, so we keep the alt-arena code in
play.
(patch LGTM other than the above)
> + assert (!victim || chunk_is_mmapped (mem2chunk (victim)) ||
Slight preference for "victim == NULL" here but I see it's consistent
with other checks elsewhere, so OK. I'll worry about it later :-)