cachemgr mallinfo statistics / dlmalloc

From: Chris Tilbury <cudch@dont-contact.us>
Date: Tue, 16 Jun 1998 18:14:43 +0100

Greetings!

I've been busy developing our cache service here at Warwick recently and
whilst I was trying to work out where memory was going, and how to make best
use of it, I noticed that the statistics given out by the cache manager [via
mallinfo()] aren't actually very helpful if you're using squid with the
dl-malloc library.

This is because the mallinfo struct, whilst being of the same structure,
actually has different meanings for some of its members (even such that some
of them are meaningless, such as the "small blocks" figures).

Because I wanted a better idea of what squid thought it was doing (one that
didn't require me to get decode the standard cachemgr.cgi output before I
could make use of it!) I wrote a little patch to "stat.c" that dumps
information that is applicable to dlmalloc.

The patch enables an extra Makefile define, HAVE_DL_MALLOC, that changes the
output so it looks like this,

[snip]
Memory usage for squid via mallinfo():
        Allocation via sbrk()
                Total allocated: 352 KB
                Total in use: 335 KB 95%
                Total free: 16 KB 5%
                Free, trimmable space: 4 KB 28% of total free
        Allocation via mmap()
                Total allocated: 456 KB 2 regions
        Total allocation: 808 KB
[snip]

giving information on how much memory is allocated via sbrk(), how much has
been allocated via mmap(), and the in-use/free/trimmable amounts for the
sbrk()d memory.

I can't claim to completely understand the c-source or the mallinfo struct,
but this certainly seems to give more consistent information than the
standard output when dlmalloc is used and it _does_ easily allow you to see
the effects of changing the various limits dlmalloc has that decide when it
uses sbrk, when it uses mmap, when it trims, etc.

The patch is attached (it's only little) - to use, apply (it will update
stat.c) and then add -DHAVE_DL_MALLOC to the DEFINES in src/Makefile.

I've tested this with 1.NOVM.21 and 1.1.21 and it seems to work fine. Any
comments and feedback (especially if I've misunderstood any of the dlmalloc
mallinfo struct!) are more than welcome.

Cheers,

Chris

-- 
Chris Tilbury, UNIX Systems Administrator, IT Services, University of Warwick
EMAIL: cudch+s@csv.warwick.ac.uk PHONE: +44 1203 523365(V)/+44 1203 523267(F)
                            URL: http://www.warwick.ac.uk/staff/Chris.Tilbury

Received on Tue Jun 16 1998 - 10:15:30 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:40:43 MST