summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 22:25:00 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 22:25:00 +0000
commit9296ed2494aa26c8816b8628bfab8f95760497c9 (patch)
tree08ae3195593d244c36cb5fbbe455fbfe1ac107b5 /net/disk_cache
parent5440b2c15100bd5e44ada6c3f987a7182466080e (diff)
downloadchromium_src-9296ed2494aa26c8816b8628bfab8f95760497c9.zip
chromium_src-9296ed2494aa26c8816b8628bfab8f95760497c9.tar.gz
chromium_src-9296ed2494aa26c8816b8628bfab8f95760497c9.tar.bz2
Disk cache: Don't evict anything for the first five
minutes. Basically, we don't want to do anything that may slow down startup. BUG=none TEST=none Review URL: http://codereview.chromium.org/7765006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/backend_impl.cc11
-rw-r--r--net/disk_cache/backend_impl.h2
2 files changed, 9 insertions, 4 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 520be91..ed69dcd 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -47,6 +47,9 @@ const int k64kEntriesStore = 240 * 1000 * 1000;
const int kBaseTableLen = 64 * 1024;
const int kDefaultCacheSize = 80 * 1024 * 1024;
+// Avoid trimming the cache for the first 5 minutes (10 timer ticks).
+const int kTrimDelay = 10;
+
int DesiredIndexTableLen(int32 storage_size) {
if (storage_size <= k64kEntriesStore)
return kBaseTableLen;
@@ -366,7 +369,7 @@ BackendImpl::BackendImpl(const FilePath& path,
block_files_(path),
mask_(0),
max_size_(0),
- io_delay_(0),
+ up_ticks_(0),
cache_type_(net::DISK_CACHE),
uma_report_(0),
user_flags_(0),
@@ -392,7 +395,7 @@ BackendImpl::BackendImpl(const FilePath& path,
block_files_(path),
mask_(mask),
max_size_(0),
- io_delay_(0),
+ up_ticks_(0),
cache_type_(net::DISK_CACHE),
uma_report_(0),
user_flags_(kMask),
@@ -975,7 +978,8 @@ void BackendImpl::OnEntryDestroyBegin(Addr address) {
void BackendImpl::OnEntryDestroyEnd() {
DecreaseNumRefs();
- if (data_->header.num_bytes > max_size_ && !read_only_)
+ if (data_->header.num_bytes > max_size_ && !read_only_ &&
+ (up_ticks_ > kTrimDelay || user_flags_ & disk_cache::kNoRandom))
eviction_.TrimCache(false);
}
@@ -1190,6 +1194,7 @@ void BackendImpl::OnStatsTimer() {
CACHE_UMA(COUNTS, "ByteIORate", 0, byte_count_ / 1024);
entry_count_ = 0;
byte_count_ = 0;
+ up_ticks_++;
if (!data_)
first_timer_ = false;
diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h
index 5344c8d..fc85d7e 100644
--- a/net/disk_cache/backend_impl.h
+++ b/net/disk_cache/backend_impl.h
@@ -357,7 +357,7 @@ class NET_EXPORT_PRIVATE BackendImpl : public Backend {
int entry_count_; // Number of entries accessed lately.
int byte_count_; // Number of bytes read/written lately.
int buffer_bytes_; // Total size of the temporary entries' buffers.
- int io_delay_; // Average time (ms) required to complete some IO operations.
+ int up_ticks_; // The number of timer ticks received (OnStatsTimer).
net::CacheType cache_type_;
int uma_report_; // Controls transmision of UMA data.
uint32 user_flags_; // Flags set by the user.