Re: TLV to memPools

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Mon, 8 Oct 2001 17:08:46 +0200

 sorry, fast fingers..

------- Forwarded message follows -------
From: Andres Kroonmaa <andre@online.ee>
To: Adrian Chadd <adrian@squid-cache.org>
Subject: Re: TLV to memPools
Date sent: Mon, 8 Oct 2001 17:08:14 +0200

On 8 Oct 2001, at 8:59, Adrian Chadd <adrian@squid-cache.org> wrote:

> On Mon, Oct 08, 2001, Andres Kroonmaa wrote:
> >
> > Does it make sense to convert TLV stuff to memPools?
> > Specifically, TLV->value is currently xmalloced, but
> > as its size is known at both alloc and free time, we
> > can convert this to memAllocBuf/memFreeBuf.
> >
> > Immediate benefits are almost none, only just reduce
> > number of xmallocs past memPools, and account this
> > mem traffic to String Pools.
>
> It makes sense to convert everything that uses xmalloc to use
> mempools. The only things that may get away with it are the
> allocator itself (heh) and the request parsing, and I
> do believe that eventually the request parsing code should
> be rewritten to use an stmem chained buffer.

 ok,

 Any good reason why we insist on size to be exactly size of
 pool's obj_size?

/* free buffer allocated with memAllocBuf() */
void
memFreeBuf(size_t size, void *buf)
{
    int i;
    MemPool *pool = NULL;
    assert(size && buf);
    for (i = 0; i < mem_str_pool_count; i++) {
        if (size <= StrPoolsAttrs[i].obj_size) {
>>> assert(size == StrPoolsAttrs[i].obj_size);
            pool = StrPools[i].pool;
            break;
        }
    }
    memMeterDec(StrCountMeter);
    memMeterDel(StrVolumeMeter, size);
    pool ? memPoolFree(pool, buf) : xfree(buf);
}

------- End of forwarded message -------

------------------------------------
 Andres Kroonmaa <andre@online.ee>
 CTO, Microlink Online
 Tel: 6501 731, Fax: 6501 725
 Pärnu mnt. 158, Tallinn,
 11317 Estonia
Received on Mon Oct 08 2001 - 09:15:53 MDT

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