quick speedup in stmem.c

From: Adrian Chadd <adrian@dont-contact.us>
Date: Thu, 30 Aug 2001 17:12:34 -0600

Hi all,

Whilst hacking away at stmem.c under the newhttp branch, I've noticed
that the following is done:

        p = memAllocate(MEM_MEM_NODE);
        p->next = NULL;
        p->len = len_to_copy;
        p->data = memAllocate(MEM_STMEM_BUF);
        store_mem_size += SM_PAGE_SIZE;

I've split this into a little routine since I'm using it in multiple
places, but then I wondered - why not just declare the node data as
a static array of SM_PAGE_SIZE rather than a pointer?

That'll save one pointer per stmem mem_node (which results in at least
a _little_ savings), but it'll drop one alloc and one dealloc per
new stmem node. The latter is what I'm chasing - dropping the number
of allocs/frees will save CPU time.

Have I missed anything here? I'm starting to get on the train of
cutting down the number of allocs, after trying to abuse mempools
for chunks of structs (eg the StoreEntry repl_policy stuff), and this
might be a cheap optimisation for 2.4 and HEAD.

Adrian
Received on Thu Aug 30 2001 - 17:12:36 MDT

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