Re: Async-IO

From: Stewart Forster <slf@dont-contact.us>
Date: Tue, 05 May 1998 09:40:05 +1000

--MimeMultipartBoundary
Content-Type: text/plain; charset=us-ascii

> > > * ~2 seconds to handle cache hits
>
> This was caused by the 1 second timeout on select(), and only seen on
> low loads. [fixed in two cooperating ways/hacks]

        Actually the fix that I sent in for this some months ago only found
its way into the poll() version. The easiest way to provide improved
performance was simply to lower the timeout on the poll/select calls. I
changed it from 1 second to 50 millisecs. This effectuated a faster poll
rate for outstanding aio operations under very low loads. Under high loads,
the timeout of 1 second never got reached because something happened before
then.

        What was the fix you applied?

> Another bug I quickly discovered while testing async-io was that the
> main<->thread communication was badly designed (almost to the point of
> abusing thread primitives) and could easily end up in a situation where
> most or all of the I/O threads got into a 100% CPU spin for a couple of
> seconds. This situation did occur if the main select() loop got
> suspended for more than 3 seconds (i.e. if the system was paging).
> [fixed]

        Oh dear. I see where its wrong now. Did you fix it by calling
time() each time through the loop? Or did you go for a less CPU intensive
fix of the following which will keep system calls down to a minimum under
higher loads.

        if (threadp->req == NULL) {
            abstime.tv_sec = squid_curtime + 3;
            abstime.tv_nsec = 0;
            threadp->status = _THREAD_WAITING;
            for(;;) {
                pthread_cond_timedwait(&(threadp->cond),
                    &(threadp->mutex), &abstime);
                if(threadp->req != NULL)
                    break;
                abstime.tv_sec = time(NULL) + 3;
            }
        }

        Cheers,

                Stew.

-- 
Stewart Forster (Snr. Development Engineer)
connect.com.au pty ltd, Level 9, 114 Albert Rd, Sth Melbourne, VIC 3205, Aust.
Email: slf@connect.com.au   Phone: +61 3 9251-3684   Fax: +61 3 9251-3666
--MimeMultipartBoundary--
Received on Tue Jul 29 2003 - 13:15:49 MDT

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