Re: Chunked mempools, a second verdict

From: Alex Rousskov <rousskov@dont-contact.us>
Date: Fri, 4 May 2001 08:13:25 -0600 (MDT)

On Fri, 4 May 2001, Andres Kroonmaa wrote:

> > It is a standard OO iterator, converted to C. I agree that it looks
> > more complex in C. The real advantage of those things is that you can
> > pass an iterator to a third function (algorithm), and that function
> > would iterate "anything" doing "something" on it. You will not see
> > many of such things in Squid yet, but it is a standard STL technique.
> > As you know, I stopped short of proposing this; I was afraid to be
> > pummeled for forcing OO/C++ ideas onto Squid code.
>
> How do you use such thing?

I think Henrik answered that already. You might want to look at C++
STL for more examples.

I do agree that using iterators might be confusing at first and is not
required every time one wants to iterate. However, it is like
comparing a loop implemented using if/goto and a loop implemented
using for(;;;). Both do the job, the second approach looks messy at
first, but, eventually most programs end up using it (and compilers
optimize for it) because it is better *in general*.

Unfortunately, C is not powerful enough to support neat, reusable
iterators. That is why I do not know whether it is a good idea to use
them in Squid whenever we can.

> > Still not sure why do you need this call. Why can't the library do it
> > on its own, when needed (either via memPoolUpdateTime that Henrik
> > banned or from inside of other public functions).
>
> like what functions? Alloc/Free out of question, they are tuned for
> performance, and any overhead is unwanted there.

If Alloc/Free is out of the question, then you have to convince Henrik
that memPoolUpdateTime is a good idea. Personally, I really doubt that
eliminating a couple of cheap statements from Alloc/Free (to check
whether stat cycle has ended) will have any impact on Squid speed. I
still prefer memPoolUpdateTime() though.

Thanks,

Alex.
Received on Fri May 04 2001 - 08:13:36 MDT

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