diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 23:53:36 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 23:53:36 +0000 |
commit | b0358c7208c45f845673fe73c833129cd3314057 (patch) | |
tree | 8d721210e355e84b432d25dc2791ec83bb6c57e2 /net | |
parent | ab813125e93624da1cb95bfab5b55b5ccc0d9808 (diff) | |
download | chromium_src-b0358c7208c45f845673fe73c833129cd3314057.zip chromium_src-b0358c7208c45f845673fe73c833129cd3314057.tar.gz chromium_src-b0358c7208c45f845673fe73c833129cd3314057.tar.bz2 |
Disk cache: Instead of saving the cache stats only when
the destructor is called, store them each five minutes.
From the dev channel, 15% of the runs the disk cache destructor
is not called, so the stats are not that reliable without
this change.
Review URL: http://codereview.chromium.org/42373
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 4 | ||||
-rw-r--r-- | net/disk_cache/stats.cc | 26 | ||||
-rw-r--r-- | net/disk_cache/stats.h | 3 |
3 files changed, 22 insertions, 11 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 885f1db..5801d40 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -729,6 +729,10 @@ void BackendImpl::OnStatsTimer() { UMA_HISTOGRAM_COUNTS(size.c_str(), data_->header.num_bytes / (1024 * 1024)); UMA_HISTOGRAM_COUNTS(max_size.c_str(), max_size_ / (1024 * 1024)); } + + // Save stats to disk at 5 min intervals. + if (time % 10) + stats_.Store(); } void BackendImpl::IncrementIoCount() { diff --git a/net/disk_cache/stats.cc b/net/disk_cache/stats.cc index 6047c5c..46c41a0 100644 --- a/net/disk_cache/stats.cc +++ b/net/disk_cache/stats.cc @@ -135,17 +135,7 @@ bool Stats::Init(BackendImpl* backend, uint32* storage_addr) { } Stats::~Stats() { - if (!backend_) - return; - - OnDiskStats stats; - stats.signature = kDiskSignature; - stats.size = sizeof(stats); - memcpy(stats.data_sizes, data_sizes_, sizeof(data_sizes_)); - memcpy(stats.counters, counters_, sizeof(counters_)); - - Addr address(storage_addr_); - StoreStats(backend_, address, &stats); + Store(); } // The array will be filled this way: @@ -267,4 +257,18 @@ void Stats::GetItems(StatsItems* items) { } } +void Stats::Store() { + if (!backend_) + return; + + OnDiskStats stats; + stats.signature = kDiskSignature; + stats.size = sizeof(stats); + memcpy(stats.data_sizes, data_sizes_, sizeof(data_sizes_)); + memcpy(stats.counters, counters_, sizeof(counters_)); + + Addr address(storage_addr_); + StoreStats(backend_, address, &stats); +} + } // namespace disk_cache diff --git a/net/disk_cache/stats.h b/net/disk_cache/stats.h index 84f013d..6658df6 100644 --- a/net/disk_cache/stats.h +++ b/net/disk_cache/stats.h @@ -60,6 +60,9 @@ class Stats { void GetItems(StatsItems* items); + // Saves the stats to disk. + void Store(); + // Support for StatsHistograms. Together, these methods allow StatsHistograms // to take a snapshot of the data_sizes_ as the histogram data. int GetBucketRange(size_t i) const; |