]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Tue, 1 Feb 2000 12:52:15 +0000 (12:52 +0000)
committerwessels <>
Tue, 1 Feb 2000 12:52:15 +0000 (12:52 +0000)
 - This fixes an ugly and probably old bug with hot objects.  Previously,
   storeSwapOut was too aggressive in freeing lower parts of in-memory
   objects.  It would free up to how ever much was sent to the client,
   or how much had been saved to disk, whichever was lower.  When the
   object response is complete, it is saved in memory only if mem->inmem_lo
   was equal to zero.  Thus, many objects which could potentially be
   held in memory wouldn't be, because the lower part had been freed
   in storeSwapOut.

   This change doesn't free the lower part until the hi-lo gap is
   at least DISK_PAGE_SIZE (8192 bytes).  This means that in-memory
   hot objects should mostly be 8kb or less.  This change makes a
   very significant improvement in memory hit ratio.

src/store_swapout.cc

index 5e4324e8906f81a7269f346f79fcb42cb8dd0c20..0115628388162a5dff31158199bd86dd10ce35c8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_swapout.cc,v 1.60 2000/01/11 06:02:54 wessels Exp $
+ * $Id: store_swapout.cc,v 1.61 2000/02/01 05:52:15 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager Swapout Functions
  * AUTHOR: Duane Wessels
@@ -108,7 +108,10 @@ storeSwapOut(StoreEntry * e)
     lowest_offset = storeLowestMemReaderOffset(e);
     debug(20, 7) ("storeSwapOut: lowest_offset = %d\n",
        (int) lowest_offset);
-    new_mem_lo = lowest_offset;
+    if (mem->inmem_hi - lowest_offset > DISK_PAGE_SIZE)
+        new_mem_lo = lowest_offset;
+    else
+        new_mem_lo = mem->inmem_lo;
     assert(new_mem_lo >= mem->inmem_lo);
     if (storeSwapOutAble(e)) {
        /*
@@ -119,11 +122,11 @@ storeSwapOut(StoreEntry * e)
         */
        if ((on_disk = storeSwapOutObjectBytesOnDisk(mem)) < new_mem_lo)
            new_mem_lo = on_disk;
-    } else {
+    } else if (new_mem_lo > 0) {
        /*
-        * Its not swap-able, so we must make it PRIVATE.  Even if
-        * be only one MEM client and all others must read from
-        * disk.
+        * Its not swap-able, and we're about to delete a chunk,
+        * so we must make it PRIVATE.  This is tricky/ugly because
+        * for the most part, we treat swapable == cachable here.
         */
        storeReleaseRequest(e);
     }