zeroing buffers

From: Gonzalo Arana <gonzalo.arana@dont-contact.us>
Date: Wed, 12 Dec 2007 10:40:05 -0300

Hi,

I've been profiling squid2.6S16, and reached a similar conclusion to Adrian's:
zeroing structures use about 2% of CPU usage, when squid as a hole is
using about 30%.

I did developed an optimization a little different than what Adrian
did: instead of leaving
large buffers untouched, I added an initialization function to every pool:
o the default is simple to zero it (for most structures, the behaviour
is unmodified).
o pools of large buffers: the buffers per-se get '\0' assigned as its
first character (just for sanity).
o structures with large char[] members get their non char[] members
zeroed via a single memset
   call, and other members get their first char assigned to '\0'.

I believe this approach:
o does not suffer from the fear of not knowing what would be the side
effects of leaving some
  structures/buffers uninitialized,
o we get large structures/buffers always initialized (this is
particularily CPU saving in heavily used
   structures with large structures, like request_t, as well as for
medium/large string memory pools).
o there are CPU savings (according to my profilings, need
verification, we save about 3% of CPU
   usage while squid is using about 30%).

There is a preliminar patch implementing this in
http://www.squid-cache.org/bugs/show_bug.cgi?id=2137
(which applies to squid-2.6.STABLE16).

How does this sound to you?

Regards,

-- 
Gonzalo A. Arana
Received on Wed Dec 12 2007 - 06:40:11 MST

This archive was generated by hypermail pre-2.1.9 : Mon Dec 31 2007 - 12:00:03 MST