]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
From: Henrik Nordstrom <hno@hem.passagen.se>
authorwessels <>
Sat, 23 May 1998 03:11:47 +0000 (03:11 +0000)
committerwessels <>
Sat, 23 May 1998 03:11:47 +0000 (03:11 +0000)
==============================================================================
Here is a in large parts reworked patch for async I/O. This replaces all
of my previous async-io patch (which was messy and broken).

    * The read offset was not preserved, corrupting deferred hits on
      pipelined connections.
    * Main <-> I/O thread communication is done using a single request
      pointer, optionally protected by a mutex.
    * CPU spin situation solved in two possible ways: Either by
      properly protecting the condition variable using a mutex, or by
      increasing the timeout-time on each timeout instead of relying on
      squid_curtime.
    * Use a 50 msec select timeout for ASYNC_IO to keep things flowing
      nicely.
    * Check for completed threads when the request queue grows.
      Completed requests are put on a FIFO queue until processed from the
      main loop.  This is done to more quickly reuse of finished
      threads.
    * Fixed a silly bug in my last version of this patch. No idea how
      the last patch could pass my tests...
    * Avoid pointer aliasing. Some compilers/optimisations have trouble
      with this (the old code was probably safe, but..).
    * Some minor code cleanups.
    * This patch is not messed up ;-)
    * Removed compiler warnings
    * No more SIGCONT signal hack or cross-level hints. This was a bad
      move both on performance and code design.
    * Mutex signalling is optional (-DAIO_PROPER_MUTEX). Using a
      volatile pointer should be safe on most/all platforms.

This patch is quite heavily tested, and seems to perform well.

I still haven't found the cause to another async-io problem. When
async-io is enabled Squid only caches about 1/2 of the requests in my
tests. Without async-io everything gets cached as expected. I have
verified that this problem in present in a unpatched b20-1 and is not
caused by this patch or any of the other 1.2b20-1 changes I have made.

src/disk.cc
src/protos.h

index 309db9a1fba3fcdbf529ed4bbbe56cbcc201ba06..9195530f941f8b7864db6a50d977d5271a99429d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.cc,v 1.114 1998/05/20 22:39:44 wessels Exp $
+ * $Id: disk.cc,v 1.115 1998/05/22 21:11:47 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -241,6 +241,7 @@ diskHandleWrite(int fd, void *notused)
     debug(6, 3) ("diskHandleWrite: FD %d\n", fd);
     /* We need to combine subsequent write requests after the first */
     /* But only if we don't need to seek() in betwen them, ugh! */
+    /* XXX This currently ignores any seeks (file_offset) */
     if (fdd->write_q->next != NULL && fdd->write_q->next->next != NULL) {
        len = 0;
        for (q = fdd->write_q->next; q != NULL; q = q->next)
@@ -273,6 +274,7 @@ diskHandleWrite(int fd, void *notused)
     assert(fdd->write_q->len > fdd->write_q->buf_offset);
 #if USE_ASYNC_IO
     aioWrite(fd,
+       -1, /* seek offset, -1 == append */
        fdd->write_q->buf + fdd->write_q->buf_offset,
        fdd->write_q->len - fdd->write_q->buf_offset,
        diskHandleWriteComplete,
@@ -480,6 +482,7 @@ diskHandleRead(int fd, void *data)
     ctrlp->data = ctrl_dat;
 #if USE_ASYNC_IO
     aioRead(fd,
+       ctrl_dat->offset,
        ctrl_dat->buf,
        ctrl_dat->req_len,
        diskHandleReadComplete,
index 7d3b9a0a035751a1b78376f4c163d9350b3d2cfe..c253f39067032b0999b740587d00c1f567edfcdd 100644 (file)
@@ -48,8 +48,8 @@ extern aio_result_t *aio_poll_done(void);
 extern void aioCancel(int, void *);
 extern void aioOpen(const char *, int, mode_t, AIOCB *, void *, void *);
 extern void aioClose(int);
-extern void aioWrite(int, char *, int, AIOCB *, void *);
-extern void aioRead(int, char *, int, AIOCB *, void *);
+extern void aioWrite(int, int offset, char *, int size, AIOCB *, void *);
+extern void aioRead(int, int offset, char *, int size, AIOCB *, void *);
 extern void aioStat(char *, struct stat *, AIOCB *, void *, void *);
 extern void aioUnlink(const char *, AIOCB *, void *);
 extern void aioCheckCallbacks(void);