Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: net/disk_cache/backend_impl.cc

Issue 155314: Disk cache: Don't evict entries if we are busy doing other stuff.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/backend_impl.h ('k') | net/disk_cache/eviction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/backend_impl.cc
===================================================================
--- net/disk_cache/backend_impl.cc (revision 20196)
+++ net/disk_cache/backend_impl.cc (working copy)
@@ -766,13 +766,18 @@
stats_.ModifyStorageStats(0, size);
}
-std::string BackendImpl::HistogramName(const char* name, int experiment) {
+bool BackendImpl::IsLoaded() const {
+ CACHE_UMA(COUNTS, "PendingIO", GetSizeGroup(), num_pending_io_);
+ return num_pending_io_ > 10;
+}
+
+std::string BackendImpl::HistogramName(const char* name, int experiment) const {
if (!experiment)
return StringPrintf("DiskCache.%d.%s", cache_type_, name);
return StringPrintf("DiskCache.%d.%s_%d", cache_type_, name, experiment);
}
-int BackendImpl::GetSizeGroup() {
+int BackendImpl::GetSizeGroup() const {
if (disabled_)
return 0;
@@ -859,14 +864,22 @@
void BackendImpl::OnStatsTimer() {
stats_.OnEvent(Stats::TIMER);
+ int64 time = stats_.GetCounter(Stats::TIMER);
int64 current = stats_.GetCounter(Stats::OPEN_ENTRIES);
- int64 time = stats_.GetCounter(Stats::TIMER);
- current = current * (time - 1) + num_refs_;
- current /= time;
- stats_.SetCounter(Stats::OPEN_ENTRIES, current);
- stats_.SetCounter(Stats::MAX_ENTRIES, max_refs_);
+ // OPEN_ENTRIES is a sampled average of the number of open entries, avoiding
+ // the bias towards 0.
+ if (num_refs_ && (current != num_refs_)) {
+ int64 diff = (num_refs_ - current) / 50;
+ if (!diff)
+ diff = num_refs_ > current ? 1 : -1;
+ current = current + diff;
+ stats_.SetCounter(Stats::OPEN_ENTRIES, current);
+ stats_.SetCounter(Stats::MAX_ENTRIES, max_refs_);
+ }
+ CACHE_UMA(COUNTS, "NumberOfReferences", 0, num_refs_);
Nicolas Sylvain 2009/07/09 22:32:21 still lgtm
+
if (!data_)
first_timer_ = false;
if (first_timer_) {
« no previous file with comments | « net/disk_cache/backend_impl.h ('k') | net/disk_cache/eviction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698