From: Dmitry Kurochkin Date: Wed, 27 Apr 2011 13:26:03 +0000 (+0400) Subject: Make Store::currentSize() return size in bytes. X-Git-Tag: take07~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=57f583f131ec99afa44e7a72df51538d03f970a7;p=thirdparty%2Fsquid.git Make Store::currentSize() return size in bytes. --- diff --git a/src/MemStore.cc b/src/MemStore.cc index d0cb698671..fe744d95c2 100644 --- a/src/MemStore.cc +++ b/src/MemStore.cc @@ -94,7 +94,7 @@ MemStore::maxSize() const uint64_t MemStore::currentSize() const { - return theCurrentSize >> 10; + return theCurrentSize; } uint64_t diff --git a/src/Store.h b/src/Store.h index 4b731be01c..5a0075e250 100644 --- a/src/Store.h +++ b/src/Store.h @@ -300,8 +300,8 @@ public: /** The minimum size the store will shrink to via normal housekeeping */ virtual uint64_t minSize() const = 0; - /** current store size in kiloBytes */ - virtual uint64_t currentSize() const = 0; // TODO: return size in bytes + /** current store size */ + virtual uint64_t currentSize() const = 0; /** the total number of objects stored */ virtual uint64_t currentCount() const = 0; diff --git a/src/SwapDir.h b/src/SwapDir.h index 53dde7126c..f1bffe320f 100644 --- a/src/SwapDir.h +++ b/src/SwapDir.h @@ -144,7 +144,7 @@ public: virtual uint64_t minSize() const; - virtual uint64_t currentSize() const { return cur_size; } + virtual uint64_t currentSize() const { return cur_size << 10; } virtual uint64_t currentCount() const { return n_disk_objects; } diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 0c77120306..710c810f25 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -8,6 +8,7 @@ #include "Parsing.h" #include #include "MemObject.h" +#include "SquidMath.h" #include "base/RunnersRegistry.h" #include "DiskIO/DiskIOModule.h" #include "DiskIO/DiskIOStrategy.h" @@ -99,7 +100,7 @@ void Rock::SwapDir::disconnect(StoreEntry &e) uint64_t Rock::SwapDir::currentSize() const { - return (HeaderSize + max_objsize * currentCount()) >> 10; + return HeaderSize + max_objsize * currentCount(); } uint64_t @@ -571,7 +572,7 @@ Rock::SwapDir::maintain() return; debugs(47,3, HERE << "cache_dir[" << index << "] state: " << map->full() << - ' ' << (currentSize() << 10) << " < " << diskOffsetLimit()); + ' ' << currentSize() << " < " << diskOffsetLimit()); // Hopefully, we find a removable entry much sooner (TODO: use time?) const int maxProbed = 10000; @@ -644,10 +645,12 @@ Rock::SwapDir::ignoreReferences(StoreEntry &e) void Rock::SwapDir::statfs(StoreEntry &e) const { + const double currentSizeInKB = currentSize() / 1024.0; storeAppendPrintf(&e, "\n"); storeAppendPrintf(&e, "Maximum Size: %"PRIu64" KB\n", max_size); - storeAppendPrintf(&e, "Current Size: %"PRIu64" KB %.2f%%\n", - currentSize(), 100.0 * currentSize() / max_size); + storeAppendPrintf(&e, "Current Size: %.2f KB %.2f%%\n", + currentSizeInKB, + Math::doublePercent(currentSizeInKB, max_size)); if (map) { const int limit = map->entryLimit(); diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index 9948c45b70..45a639bf26 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -67,7 +67,7 @@ snmp_sysFn(variable_list * Var, snint * ErrP) case SYSSTOR: Answer = snmp_var_new_integer(Var->name, Var->name_length, - Store::Root().currentSize(), + Store::Root().currentSize() >> 10, ASN_INTEGER); break; @@ -531,7 +531,7 @@ snmp_prfProtoFn(variable_list * Var, snint * ErrP) case PERF_PROTOSTAT_AGGR_CURSWAP: Answer = snmp_var_new_integer(Var->name, Var->name_length, - (snint) Store::Root().currentSize(), + (snint) Store::Root().currentSize() >> 10, SMI_GAUGE32); break; diff --git a/src/stat.cc b/src/stat.cc index 6b0a88c3a7..8a76dde26e 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -546,7 +546,7 @@ GetInfo(Mgr::InfoActionData& stats) stats.request_hit_disk_ratio5 = statRequestHitDiskRatio(5); stats.request_hit_disk_ratio60 = statRequestHitDiskRatio(60); - stats.store_swap_size = Store::Root().currentSize(); + stats.store_swap_size = Store::Root().currentSize() / 1024.0; stats.store_swap_max_size = Store::Root().maxSize(); stats.store_mem_size = mem_node::StoreMemSize(); @@ -555,7 +555,7 @@ GetInfo(Mgr::InfoActionData& stats) stats.n_disk_objects = Store::Root().currentCount(); stats.objects_size = stats.n_disk_objects > 0 ? - (double)Store::Root().currentSize() / stats.n_disk_objects : 0.0; + stats.store_swap_size / stats.n_disk_objects : 0.0; stats.unlink_requests = statCounter.unlink.requests; diff --git a/src/store_digest.cc b/src/store_digest.cc index 14649ab5f1..2960193aa0 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -507,7 +507,7 @@ storeDigestCalcCap(void) * number of _entries_ we want to pre-allocate for. */ const int hi_cap = Store::Root().maxSize() / Config.Store.avgObjectSize; - const int lo_cap = 1 + Store::Root().currentSize() / Config.Store.avgObjectSize; + const int lo_cap = 1 + (Store::Root().currentSize() >> 10) / Config.Store.avgObjectSize; const int e_count = StoreEntry::inUseCount(); int cap = e_count ? e_count :hi_cap; debugs(71, 2, "storeDigestCalcCap: have: " << e_count << ", want " << cap << diff --git a/src/store_dir.cc b/src/store_dir.cc index 11ff8c6b47..5386d02f13 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -345,16 +345,17 @@ SwapDir::updateSize(int64_t size, int sign) void StoreController::stat(StoreEntry &output) const { + const double currentSizeInKB = currentSize() / 1024.0; storeAppendPrintf(&output, "Store Directory Statistics:\n"); storeAppendPrintf(&output, "Store Entries : %lu\n", (unsigned long int)StoreEntry::inUseCount()); storeAppendPrintf(&output, "Maximum Swap Size : %"PRIu64" KB\n", maxSize()); - storeAppendPrintf(&output, "Current Store Swap Size: %"PRIu64" KB\n", - currentSize()); - storeAppendPrintf(&output, "Current Capacity : %"PRId64"%% used, %"PRId64"%% free\n", - Math::int64Percent(currentSize(), maxSize()), - Math::int64Percent((maxSize() - currentSize()), maxSize())); + storeAppendPrintf(&output, "Current Store Swap Size: %.2f KB\n", + currentSizeInKB); + storeAppendPrintf(&output, "Current Capacity : %.2f%% used, %.2f%% free\n", + Math::doublePercent(currentSizeInKB, maxSize()), + Math::doublePercent((maxSize() - currentSizeInKB), maxSize())); if (memStore) memStore->stat(output); diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 1c3edea5f6..038c537168 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -111,7 +111,7 @@ storeCleanup(void *datanotused) if (currentSearch->isDone()) { debugs(20, 1, " Completed Validation Procedure"); debugs(20, 1, " Validated " << validated << " Entries"); - debugs(20, 1, " store_swap_size = " << Store::Root().currentSize()); + debugs(20, 1, " store_swap_size = " << Store::Root().currentSize() / 1024.0 << " KB"); StoreController::store_dirs_rebuilding--; assert(0 == StoreController::store_dirs_rebuilding);