From 3b14a88ba78b6a4c24928ac62f09f2aebcd70522 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sat, 6 Jun 2009 22:04:41 +1200 Subject: [PATCH] Author: Arkin 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store_dir.cc b/src/store_dir.cc index d9c28a1010..e3b7ae3e80 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -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 -- 2.47.2