diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 00:53:02 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-19 00:53:02 +0000 |
commit | d997862f6c876e5fe85304a6f0ab82dbd1acf576 (patch) | |
tree | 20e8b3649a5d0b6d502f586992262b0d50fccbb0 /net/disk_cache/eviction.cc | |
parent | 1f43948cc3e6d925b268d77fdac3c873dd7bb23f (diff) | |
download | chromium_src-d997862f6c876e5fe85304a6f0ab82dbd1acf576.zip chromium_src-d997862f6c876e5fe85304a6f0ab82dbd1acf576.tar.gz chromium_src-d997862f6c876e5fe85304a6f0ab82dbd1acf576.tar.bz2 |
Disk cache: Delete the disk cache if it is substantially bigger
than the desired max size, and adjust eviction to avoid
having long periods without it.
There's a few users with caches that are too big, and it
looks like the problem is that eviction could be stopped
forever, while still adding new items to the cache.
Now we only allow one minute (at a time) with eviction suspended.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/647054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/eviction.cc')
-rw-r--r-- | net/disk_cache/eviction.cc | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index bdcef6b..fd5bd2e 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -44,6 +44,7 @@ namespace { const int kCleanUpMargin = 1024 * 1024; const int kHighUse = 10; // Reuse count to be on the HIGH_USE list. const int kTargetTime = 24 * 7; // Time to be evicted (hours since last use). +const int kMaxDelayedTrims = 60; int LowWaterAdjust(int high_water) { if (high_water < kCleanUpMargin) @@ -67,18 +68,19 @@ void Eviction::Init(BackendImpl* backend) { first_trim_ = true; trimming_ = false; delay_trim_ = false; + trim_delays_ = 0; } void Eviction::TrimCache(bool empty) { - if (new_eviction_) - return TrimCacheV2(empty); - if (backend_->disabled_ || trimming_) return; - if (!empty && backend_->IsLoaded()) + if (!empty && !ShouldTrim()) return PostDelayedTrim(); + if (new_eviction_) + return TrimCacheV2(empty); + Trace("*** Trim Cache ***"); trimming_ = true; Time start = Time::Now(); @@ -111,7 +113,12 @@ void Eviction::TrimCache(bool empty) { } } - CACHE_UMA(AGE_MS, "TotalTrimTime", backend_->GetSizeGroup(), start); + if (empty) { + CACHE_UMA(AGE_MS, "TotalClearTimeV1", 0, start); + } else { + CACHE_UMA(AGE_MS, "TotalTrimTimeV1", backend_->GetSizeGroup(), start); + } + trimming_ = false; Trace("*** Trim Cache end ***"); return; @@ -153,15 +160,28 @@ void Eviction::PostDelayedTrim() { if (delay_trim_) return; delay_trim_ = true; + trim_delays_++; MessageLoop::current()->PostDelayedTask(FROM_HERE, factory_.NewRunnableMethod(&Eviction::DelayedTrim), 1000); } void Eviction::DelayedTrim() { delay_trim_ = false; + if (trim_delays_ < kMaxDelayedTrims && backend_->IsLoaded()) + return PostDelayedTrim(); + TrimCache(false); } +bool Eviction::ShouldTrim() { + if (trim_delays_ < kMaxDelayedTrims && backend_->IsLoaded()) + return false; + + UMA_HISTOGRAM_COUNTS("DiskCache.TrimDelays", trim_delays_); + trim_delays_ = 0; + return true; +} + void Eviction::ReportTrimTimes(EntryImpl* entry) { if (first_trim_) { first_trim_ = false; @@ -223,12 +243,6 @@ bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) { // ----------------------------------------------------------------------- void Eviction::TrimCacheV2(bool empty) { - if (backend_->disabled_ || trimming_) - return; - - if (!empty && backend_->IsLoaded()) - return PostDelayedTrim(); - Trace("*** Trim Cache ***"); trimming_ = true; Time start = Time::Now(); @@ -300,7 +314,12 @@ void Eviction::TrimCacheV2(bool empty) { factory_.NewRunnableMethod(&Eviction::TrimDeleted, empty)); } - CACHE_UMA(AGE_MS, "TotalTrimTime", backend_->GetSizeGroup(), start); + if (empty) { + CACHE_UMA(AGE_MS, "TotalClearTimeV2", 0, start); + } else { + CACHE_UMA(AGE_MS, "TotalTrimTimeV2", backend_->GetSizeGroup(), start); + } + Trace("*** Trim Cache end ***"); trimming_ = false; return; |