[quagga-dev 3158] Re: [PATCH] lib/buffer.c: keep one buffer_data to avoid malloc/free thrashing

Paul Jakma paul at clubi.ie
Mon Apr 11 23:45:06 BST 2005


On Mon, 11 Apr 2005, Andrew J. Schorr wrote:

> Based on some quick testing using quantify on a solaris 8 sparc 
> box, buffer_put (used by vty_write to insert each character into 
> the buffer) is called 181 times and uses a total of 17551 cycles 
> for itself and its descendants (average time of 97 cycles including 
> called functions).  Of those 17551 cycles, 8646 cycles 
> (approximately 50%) are attributable to calls to zmalloc. And there 
> are another 5665 cycles consumed by free. The actual percentage 
> consumed by malloc for putting those single characters in telnet 
> mode is much worse because that data is obscured by the buffer_puts 
> for the command results which do not malloc a buffer for each 
> character written.

Is this with Quagga linked to libumem? (Should be the default for 
CVS). If no, can you try with?

> An average call to zmalloc consumes 136 cycles.
>
> With the optimization in place, the average call to buffer_put
> takes 67 cycles (including time spent in called functions).

Ah.

> I am more than willing to believe that modern mallocs are pretty 
> efficient compared to older implementations.  That being said, it 
> is simply not nearly as fast as retaining a pointer to a spare 
> buffer and avoiding the malloc/free churn altogether.

Ok, if the above was with libumem, or libumem is still an appreciable 
overhead, i'll reconsider :).

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Fortune:
Cure the disease and kill the patient.
 		-- Francis Bacon



More information about the Quagga-dev mailing list