Re: Chunked mempools, a first verdict

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Thu, 3 May 2001 19:09:11 +0200

On 3 May 2001, at 10:18, Alex Rousskov <rousskov@measurement-factory.com> wrote:

> > > Did you mean to have both "pool" and "index" parameters there? What is
> > > the semantics of the return value? Sorry if it was documented before.
...
> > Idea is to allow caller to iterate through all pools without knowing number
> > of actual pools. Start from 0 up and continue until func returns false.
>
> So what you really want is
> const int count = memPoolCount();
> while (int i = 0; i < count; ++i) {
> MemPoolStats *stats;
> memPoolGetStats(stats, i);
> ...
> }

 yeah. Adding another API function that merely does "return PoolArray.count"
 As well we could export PoolArray.

> Then, at least, you will not have to write/read so many words
> describing what memPoolGetStats does (and that is always a good
> thing). Moreover, I would even argue that
>
> MemPoolStats *stats;
> MemPool *p = memPoolAt(i);
> memPoolGetStats(stats, p);

 we can skip memPoolCount();

       int i = 0;
         while (*p = memPoolAt(i++)) {
                 MemPoolStats *stats;
                 memPoolGetStats(stats, p);
                 ...
         }

 I've just combined the two:

       int i = 0;
         while (memPoolGetStats(stats, 0, i++)) {
                 ...
         }

> is a better approach because most of your functions operate on MemPool
> pointers, not integer indices. Also, you do not need any words to
> describe this interface -- it is obvious from function profiles.

 I agree. Does everybody else? Boy I'm confused that we are talking about
 what "color" it should be, instead of whether it works..

> > > Also, it may be a good idea to have
> > > memPoolGetStatsAll(MemPoolStatsAll*)
> > > or some such because the internal routines may keep some global
> > > statistics about all pools together (e.g., high water mark). You can
> > > use that to get the count of existing pools for your iteration routine.
> >
> > Yes. Again a matter of additional exported symbols. Currently, to get stats
> > for all pools I'd call memPoolGetStats(MemPoolStats *stats, NULL, -1);
> > Which would internally iterate through all pools and generate summary
> > stats. In place of pool->meter it then returns pointer to TheMeter which
> > keeps global high water marks.
>
> This assumes that MemPoolStats can express the summary statistics,
> which is not necessarily true (in general or in the future).

 alright. So we need 2 API calls for stats. 2 calls to iterate pools.
 Where does the definition of messy cut in?

> If the interface is so complex that it requires N elements, either
> implement all N elements or simplify the interface.

 Simplify how?

------------------------------------
 Andres Kroonmaa <andre@online.ee>
 CTO, Delfi Online
 Tel: 6501 731, Fax: 6501 708
 Pärnu mnt. 158, Tallinn,
 11317 Estonia
Received on Thu May 03 2001 - 11:13:48 MDT

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