summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 22:36:19 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 22:36:19 +0000
commit66e35f3811536754d6f74ed7cf3140d8c0bda192 (patch)
tree6f5b7844f7dc0a8f76d5a921e1a0739775ca89c6 /net
parentb781f63538c962d2d839c5d5f6914ff4843fe823 (diff)
downloadchromium_src-66e35f3811536754d6f74ed7cf3140d8c0bda192.zip
chromium_src-66e35f3811536754d6f74ed7cf3140d8c0bda192.tar.gz
chromium_src-66e35f3811536754d6f74ed7cf3140d8c0bda192.tar.bz2
Disk cache: Add a few more histograms.
BUG=none TEST=none Review URL: http://codereview.chromium.org/2863039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/disk_cache/backend_impl.cc35
-rw-r--r--net/disk_cache/backend_impl.h6
-rw-r--r--net/disk_cache/entry_impl.cc3
3 files changed, 42 insertions, 2 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 5e761e1..075360c 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -273,6 +273,7 @@ bool BackendImpl::Init() {
}
num_refs_ = num_pending_io_ = max_refs_ = 0;
+ entry_count_ = byte_count_ = 0;
if (!restarted_) {
trace_object_ = TraceObject::GetTraceObject();
@@ -387,6 +388,7 @@ EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) {
}
eviction_.OnOpenEntry(cache_entry);
+ entry_count_++;
CACHE_UMA(AGE_MS, "OpenTime", GetSizeGroup(), start);
stats_.OnEvent(Stats::OPEN_HIT);
@@ -475,6 +477,7 @@ EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) {
IncreaseNumEntries();
eviction_.OnCreateEntry(cache_entry);
+ entry_count_++;
if (!parent.get())
data_->table[hash & mask_] = entry_address.value();
@@ -902,10 +905,17 @@ void BackendImpl::FirstEviction() {
Time create_time = Time::FromInternalValue(data_->header.create_time);
CACHE_UMA(AGE, "FillupAge", 0, create_time);
- int64 use_hours = stats_.GetCounter(Stats::TIMER) / 120;
- CACHE_UMA(HOURS, "FillupTime", 0, static_cast<int>(use_hours));
+ int64 use_time = stats_.GetCounter(Stats::TIMER);
+ CACHE_UMA(HOURS, "FillupTime", 0, static_cast<int>(use_time / 120));
CACHE_UMA(PERCENTAGE, "FirstHitRatio", 0, stats_.GetHitRatio());
+ if (!use_time)
+ use_time = 1;
+ CACHE_UMA(COUNTS_10000, "FirstEntryAccessRate", 0,
+ static_cast<int>(data_->header.num_entries / use_time));
+ CACHE_UMA(COUNTS, "FirstByteIORate", 0,
+ static_cast<int>((data_->header.num_bytes / 1024) / use_time));
+
int avg_size = data_->header.num_bytes / GetEntryCount();
CACHE_UMA(COUNTS, "FirstEntrySize", 0, avg_size);
@@ -954,6 +964,18 @@ void BackendImpl::OnEvent(Stats::Counters an_event) {
stats_.OnEvent(an_event);
}
+void BackendImpl::OnRead(int32 bytes) {
+ DCHECK_GE(bytes, 0);
+ byte_count_ += bytes;
+ if (byte_count_ < 0)
+ byte_count_ = kint32max;
+}
+
+void BackendImpl::OnWrite(int32 bytes) {
+ // We use the same implementation as OnRead... just log the number of bytes.
+ OnRead(bytes);
+}
+
void BackendImpl::OnStatsTimer() {
stats_.OnEvent(Stats::TIMER);
int64 time = stats_.GetCounter(Stats::TIMER);
@@ -972,6 +994,11 @@ void BackendImpl::OnStatsTimer() {
CACHE_UMA(COUNTS, "NumberOfReferences", 0, num_refs_);
+ CACHE_UMA(COUNTS_10000, "EntryAccessRate", 0, entry_count_);
+ CACHE_UMA(COUNTS, "ByteIORate", 0, byte_count_ / 1024);
+ entry_count_ = 0;
+ byte_count_ = 0;
+
if (!data_)
first_timer_ = false;
if (first_timer_) {
@@ -1439,6 +1466,7 @@ EntryImpl* BackendImpl::ResurrectEntry(EntryImpl* deleted_entry) {
// previously deleted.
eviction_.OnCreateEntry(deleted_entry);
+ entry_count_++;
stats_.OnEvent(Stats::CREATE_HIT);
Trace("Resurrect entry hit ");
@@ -1585,6 +1613,9 @@ void BackendImpl::ReportStats() {
int avg_size = data_->header.num_bytes / GetEntryCount();
CACHE_UMA(COUNTS, "EntrySize", 0, avg_size);
+ CACHE_UMA(PERCENTAGE, "IndexLoad", 0,
+ data_->header.num_entries * 100 / (mask_ + 1));
+
int large_entries_bytes = stats_.GetLargeEntriesSize();
int large_ratio = large_entries_bytes * 100 / data_->header.num_bytes;
CACHE_UMA(PERCENTAGE, "LargeEntriesRatio", 0, large_ratio);
diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h
index 706a0cb..f0a8aab 100644
--- a/net/disk_cache/backend_impl.h
+++ b/net/disk_cache/backend_impl.h
@@ -171,6 +171,10 @@ class BackendImpl : public Backend {
// Called when an interesting event should be logged (counted).
void OnEvent(Stats::Counters an_event);
+ // Keeps track of paylod access (doesn't include metadata).
+ void OnRead(int bytes);
+ void OnWrite(int bytes);
+
// Timer callback to calculate usage statistics.
void OnStatsTimer();
@@ -295,6 +299,8 @@ class BackendImpl : public Backend {
int num_refs_; // Number of referenced cache entries.
int max_refs_; // Max number of referenced cache entries.
int num_pending_io_; // Number of pending IO operations.
+ int entry_count_; // Number of entries accessed lately.
+ int byte_count_; // Number of bytes read/written lately.
net::CacheType cache_type_;
int uma_report_; // Controls transmision of UMA data.
uint32 user_flags_; // Flags set by the user.
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index 1c041d2..db7c284 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -209,6 +209,7 @@ int EntryImpl::ReadData(int index, int offset, net::IOBuffer* buf, int buf_len,
UpdateRank(false);
backend_->OnEvent(Stats::READ_DATA);
+ backend_->OnRead(buf_len);
if (user_buffers_[index].get()) {
// Complete the operation locally.
@@ -302,6 +303,7 @@ int EntryImpl::WriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
UpdateRank(true);
backend_->OnEvent(Stats::WRITE_DATA);
+ backend_->OnWrite(buf_len);
if (user_buffers_[index].get()) {
// Complete the operation locally.
@@ -460,6 +462,7 @@ bool EntryImpl::CreateEntry(Addr node_address, const std::string& key,
entry_store->key[key.size()] = '\0';
}
backend_->ModifyStorageSize(0, static_cast<int32>(key.size()));
+ CACHE_UMA(COUNTS, "KeySize", 0, static_cast<int32>(key.size()));
node->dirty = backend_->GetCurrentEntryId();
Log("Create Entry ");
return true;