diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-12 01:17:51 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-12 01:17:51 +0000 |
commit | ad4984168f95ab7b519577fc2434cd9f270168e6 (patch) | |
tree | 73a371036751e8deace5c0367c80ecd9b7a8b2eb /net/disk_cache | |
parent | 64ce9d05bec75b48bba0814868c9bf472ba3eebb (diff) | |
download | chromium_src-ad4984168f95ab7b519577fc2434cd9f270168e6.zip chromium_src-ad4984168f95ab7b519577fc2434cd9f270168e6.tar.gz chromium_src-ad4984168f95ab7b519577fc2434cd9f270168e6.tar.bz2 |
Disk cache: Track evictions of ga.js.
The purpose is to understand the cache behavior with very popular resources.
BUG=147383
TEST=none
Review URL: https://chromiumcodereview.appspot.com/11000062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 5 | ||||
-rw-r--r-- | net/disk_cache/eviction.cc | 8 | ||||
-rw-r--r-- | net/disk_cache/stats.cc | 8 | ||||
-rw-r--r-- | net/disk_cache/stats.h | 1 |
4 files changed, 19 insertions, 3 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 2de5952..e7fd5d6 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -1538,6 +1538,7 @@ void BackendImpl::RestartCache(bool failure) { int64 errors = stats_.GetCounter(Stats::FATAL_ERROR); int64 full_dooms = stats_.GetCounter(Stats::DOOM_CACHE); int64 partial_dooms = stats_.GetCounter(Stats::DOOM_RECENT); + int64 ga_evictions = stats_.GetCounter(Stats::GAJS_EVICTED); int64 last_report = stats_.GetCounter(Stats::LAST_REPORT); PrepareForRestart(); @@ -1557,6 +1558,7 @@ void BackendImpl::RestartCache(bool failure) { stats_.SetCounter(Stats::FATAL_ERROR, errors); stats_.SetCounter(Stats::DOOM_CACHE, full_dooms); stats_.SetCounter(Stats::DOOM_RECENT, partial_dooms); + stats_.SetCounter(Stats::GAJS_EVICTED, ga_evictions); stats_.SetCounter(Stats::LAST_REPORT, last_report); } } @@ -2013,9 +2015,12 @@ void BackendImpl::ReportStats() { static_cast<int>(stats_.GetCounter(Stats::DOOM_CACHE))); CACHE_UMA(COUNTS_10000, "TotalDoomRecentEntries", 0, static_cast<int>(stats_.GetCounter(Stats::DOOM_RECENT))); + CACHE_UMA(COUNTS_10000, "TotalEvictionsGaJs", 0, + static_cast<int>(stats_.GetCounter(Stats::GAJS_EVICTED))); stats_.SetCounter(Stats::FATAL_ERROR, 0); stats_.SetCounter(Stats::DOOM_CACHE, 0); stats_.SetCounter(Stats::DOOM_RECENT, 0); + stats_.SetCounter(Stats::GAJS_EVICTED, 0); int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; if (!data_->header.create_time || !data_->header.lru.filled) { diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index 7a33479..1a4a0f1 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -281,8 +281,6 @@ bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty, ReportTrimTimes(entry); if (empty || !new_eviction_) { entry->DoomImpl(); - if (!empty) - backend_->OnEvent(Stats::TRIM_ENTRY); } else { entry->DeleteEntryData(false); EntryStore* info = entry->entry()->Data(); @@ -292,7 +290,13 @@ bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty, info->state = ENTRY_EVICTED; entry->entry()->Store(); rankings_->Insert(entry->rankings(), true, Rankings::DELETED); + } + if (!empty) { backend_->OnEvent(Stats::TRIM_ENTRY); + + static const char gajs[] = "http://www.google-analytics.com/ga.js"; + if (!entry->GetKey().compare(gajs)) + backend_->OnEvent(Stats::GAJS_EVICTED); } entry->Release(); diff --git a/net/disk_cache/stats.cc b/net/disk_cache/stats.cc index 62d228c..c77f7f9 100644 --- a/net/disk_cache/stats.cc +++ b/net/disk_cache/stats.cc @@ -61,7 +61,8 @@ static const char* kCounterNames[] = { "Fatal error", "Last report", "Last report timer", - "Doom recent entries" + "Doom recent entries", + "ga.js evicted" }; COMPILE_ASSERT(arraysize(kCounterNames) == disk_cache::Stats::MAX_COUNTER, update_the_names); @@ -88,6 +89,11 @@ bool LoadStats(BackendImpl* backend, Addr address, OnDiskStats* stats) { // counter; we keep old data if we can. if (static_cast<unsigned int>(stats->size) > sizeof(*stats)) { memset(stats, 0, sizeof(*stats)); + stats->signature = kDiskSignature; + } else if (static_cast<unsigned int>(stats->size) != sizeof(*stats)) { + size_t delta = sizeof(*stats) - static_cast<unsigned int>(stats->size); + memset(reinterpret_cast<char*>(stats) + stats->size, 0, delta); + stats->size = sizeof(*stats); } return true; diff --git a/net/disk_cache/stats.h b/net/disk_cache/stats.h index 94b9d68..845aa18 100644 --- a/net/disk_cache/stats.h +++ b/net/disk_cache/stats.h @@ -48,6 +48,7 @@ class Stats { LAST_REPORT, // Time of the last time we sent a report. LAST_REPORT_TIMER, // Timer count of the last time we sent a report. DOOM_RECENT, // The cache was partially cleared. + GAJS_EVICTED, // ga.js was evicted from the cache. MAX_COUNTER }; |