Malloc Benchmarking

So not only is malloc a pain to work with when you have to chase down memory leaks, it's also pretty expensive even when you're using it correctly. We never really knew just how expensive it was, we just knew that we should avoid it unless it was actually necessary.

After having pored through the code in OpenLDAP slapd and removing/ rewriting every critical use of malloc, and still seeing performance hotspots in the profiles, it became apparent that we needed to see what malloc itself was doing. This investigation brought other malloc implementations to our attention. So for the curious, here's some data from benchmarking glibc's malloc vs Hoard, Umem, and Google's tcmalloc. Some of the results may surprise you. Click the image to download the raw data as an OpenOffice spreadsheet.

Each library was tested both in single and multi-threaded operation on an identical database. Some relevant discussions were posted on the OpenLDAP Developer's mailing list in August and November of 2006. -- hyc 2006-11-22