]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Arkin <arkin.yang@gmail.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 24 May 2009 09:28:55 +0000 (21:28 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 24 May 2009 09:28:55 +0000 (21:28 +1200)
Bug 2387: The calculation of the number of hash buckets need to account for the memory size, not only disk size

cache_mem only setups without a cache_dir miscalculates the hash table size,
resulting in poor performance if cache_mem is very large.

src/store_dir.cc

index b89b3e0dfb29a3454ddaca75f41c7b3a3cb02fca..b9f60a105f6f64fa9dd3ce6d767504cb7d44b8ae 100644 (file)
@@ -788,9 +788,9 @@ StoreHashIndex::init()
     /* Calculate size of hash table (maximum currently 64k buckets).  */
     /* this is very bogus, its specific to the any Store maintaining an
      * in-core index, not global */
-    size_t buckets = Store::Root().maxSize() / Config.Store.avgObjectSize;
+    size_t buckets = (Store::Root().maxSize() + ( Config.memMaxSize >> 10)) / Config.Store.avgObjectSize;
     debugs(20, 1, "Swap maxSize " << Store::Root().maxSize() <<
-           " KB, estimated " << buckets << " objects");
+           " + " << ( Config.memMaxSize >> 10) << " KB, estimated " << buckets << " objects");
     buckets /= Config.Store.objectsPerBucket;
     debugs(20, 1, "Target number of buckets: " << buckets);
     /* ideally the full scan period should be configurable, for the
@@ -803,7 +803,7 @@ StoreHashIndex::init()
     store_table = hash_create(storeKeyHashCmp,
                               store_hash_buckets, storeKeyHashHash);
 
-    for (int i = 0; i < Config.cacheSwap.n_configured; i++)
+    for (int i = 0; i < Config.cacheSwap.n_configured; i++) {
         /* this starts a search of the store dirs, loading their
          * index. under the new Store api this should be
          * driven by the StoreHashIndex, not by each store.
@@ -819,7 +819,7 @@ StoreHashIndex::init()
         * Step 3: have the hash index walk the searches itself.
          */
         store(i)->init();
-
+    }
 }
 
 size_t