From d7fc83f78f47de82da3b67449cf7c742b45d3a00 Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Fri, 18 Jan 2013 18:17:43 +0000 Subject: Disk cache: Go back to regular evictions if we are falling behind. If the cache is under load we try to avoid evictions, or at least reduce the frequency of evictions. This CL alters that logic so that when the size of the cache grows too much above the desired limit we go back to non throttled evictions. BUG=none TEST=none Review URL: https://codereview.chromium.org/11961008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177708 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/eviction.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index 1a4a0f1..2086bd3 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -57,6 +57,10 @@ int LowWaterAdjust(int high_water) { return high_water - kCleanUpMargin; } +bool FallingBehind(int current_size, int max_size) { + return current_size > max_size - kCleanUpMargin * 20; +} + } // namespace namespace disk_cache { @@ -219,8 +223,10 @@ void Eviction::DelayedTrim() { } bool Eviction::ShouldTrim() { - if (trim_delays_ < kMaxDelayedTrims && backend_->IsLoaded()) + if (!FallingBehind(header_->num_bytes, max_size_) && + trim_delays_ < kMaxDelayedTrims && backend_->IsLoaded()) { return false; + } UMA_HISTOGRAM_COUNTS("DiskCache.TrimDelays", trim_delays_); trim_delays_ = 0; -- cgit v1.1