[patch] malloc per-thread cache ready for review

Markus Trippelsdorf markus@trippelsdorf.de
Wed Feb 1 17:33:00 GMT 2017


On 2017.02.01 at 19:23 +0300, Alexander Monakov wrote:
> On Wed, 1 Feb 2017, Jeff Law wrote:
> 
> > On 02/01/2017 09:14 AM, DJ Delorie wrote:
> > > Markus Trippelsdorf <markus@trippelsdorf.de> writes:
> > > > Thanks. It works fine now.
> > > 
> > > Excellent :-)
> > > 
> > > > But I see no speedups for a simple compile time test:
> > > 
> > > GCC is single threaded and has its own internal memory management system
> > > it layers on top of malloc, and I've not seen it benefit from a
> > > per-thread cache.
> > Actually most of GCC's key internal structures are layered on top of mmap'd
> > pages.  It doesn't go through malloc for any of the key data structures.
> 
> As I recall from looking at profiling data, GCC's C++ frontend is nevertheless a
> heavy user of libc malloc/free.  Apart from that, GCC uses its custom GC-capable
> allocator extensively.

Exactly. For C++ projects you can easily get a 6-8% build time speedup
by using an alternative allocator like
http://locklessinc.com/downloads/lockless_allocator_src.tgz (the best in
my testing) or jemalloc.

-- 
Markus



More information about the Libc-alpha mailing list