]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Arkin <arkin.yang@gmail.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Jun 2009 10:04:41 +0000 (22:04 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Jun 2009 10:04:41 +0000 (22:04 +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 d9c28a1010dca5bbba84c0654dd79fa3c836cfee..e3b7ae3e80b6b79c619bdb15717c235aca8f85d3 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