New libc malloc committed

Matthew Dillon dillon at apollo.backplane.com
Thu Apr 23 20:26:34 PDT 2009


    libc now has a new malloc.  It appears to work well with buildworlds
    and pkgsrc, including firefox3.

    The new malloc is a bit more thread friendly then the old one.
    I didn't go overboard coding parallelism w/ pthreads but it is
    significantly better then the old malloc.  It also produces much
    less fragmentation for large persistent applications.  Perl, X, firefox,
    kde, etc.  Perl in particular, using the devel/libgweather build
    from pkgsrc as a test.  The old malloc had conniption fits on that
    build, the new one is smooth as butter.

    The raw malloc/free performance of the new allocator is about double
    that of the old one though related buildworld performance doesn't
    appear to change much, probably due to very slightly higher startup
    overhead as the slabs are mapped.

    --

    The new malloc is a port of our kernel SMP-friendly slab allocator,
    tuned down a bit to reduce page fault activity and VM footprint
    (things the kernel version doesn't have to worry about but the
    userland version does).

    The slab-based malloc supports about 80 different chunk sizes in 
    multiples starting at 8 bytes, making it extremely efficient for
    allocating large numbers of odd-sized structures all the way down
    to 8 bytes.  The lack of compaction for small numbers of
    disparately-sized allocations slightly increases the initial footprint
    but this same effect also tends to reduce fragmentation in long-running
    applications, which is more important these days.

					    -Matt





More information about the Kernel mailing list