Commit 6e14396e authored by gavinp@chromium.org's avatar gavinp@chromium.org

Add HttpCache histograms focussed on blocking and transaction type.

Most of our existing disk cache histograms focus on the speed of operations on the cache itself. This CL adds a bunch that break down http transactions by type, and track both time spent reading (either from disk cache or network), and time spent waiting for the disk cache to allow us to send the network request.

Note that these patches are based on http://codereview.chromium.org/10797042/ , which must land first.

R=rvargas@chromium.org, tburkhard@chromium.org
BUG=None

Review URL: https://chromiumcodereview.appspot.com/10808047

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150902 0039d316-1c4b-4281-b951-d872f2087c98
parent f7e48f15
......@@ -1323,6 +1323,10 @@ void BackendImpl::FlushIndex() {
// ------------------------------------------------------------------------
net::CacheType BackendImpl::GetCacheType() const {
return cache_type_;
}
int32 BackendImpl::GetEntryCount() const {
if (!index_ || disabled_)
return 0;
......
......@@ -260,6 +260,7 @@ class NET_EXPORT_PRIVATE BackendImpl : public Backend {
void FlushIndex();
// Backend implementation.
virtual net::CacheType GetCacheType() const OVERRIDE;
virtual int32 GetEntryCount() const OVERRIDE;
virtual int OpenEntry(const std::string& key, Entry** entry,
const CompletionCallback& callback) OVERRIDE;
......
......@@ -67,6 +67,9 @@ class NET_EXPORT Backend {
// callback from within this method.
virtual ~Backend() {}
// Returns the type of this cache.
virtual net::CacheType GetCacheType() const = 0;
// Returns the number of entries in the cache.
virtual int32 GetEntryCount() const = 0;
......
......@@ -124,6 +124,10 @@ void MemBackendImpl::RemoveFromRankingList(MemEntryImpl* entry) {
rankings_.Remove(entry);
}
net::CacheType MemBackendImpl::GetCacheType() const {
return net::MEMORY_CACHE;
}
int32 MemBackendImpl::GetEntryCount() const {
return static_cast<int32>(entries_.size());
}
......
......@@ -62,6 +62,7 @@ class NET_EXPORT_PRIVATE MemBackendImpl : public Backend {
void RemoveFromRankingList(MemEntryImpl* entry);
// Backend interface.
virtual net::CacheType GetCacheType() const OVERRIDE;
virtual int32 GetEntryCount() const OVERRIDE;
virtual int OpenEntry(const std::string& key, Entry** entry,
const CompletionCallback& callback) OVERRIDE;
......
This diff is collapsed.
......@@ -175,6 +175,19 @@ class HttpCache::Transaction : public HttpTransaction {
STATE_CACHE_WRITE_DATA_COMPLETE
};
// Used for categorizing transactions for reporting in histograms. Patterns
// cover relatively common use cases being measured and considered for
// optimization. Many use cases that are more complex or uncommon are binned
// as PATTERN_NOT_COVERED, and details are not reported.
enum TransactionPattern {
PATTERN_UNDEFINED,
PATTERN_NOT_COVERED,
PATTERN_ENTRY_NOT_CACHED,
PATTERN_ENTRY_USED,
PATTERN_ENTRY_VALIDATED,
PATTERN_ENTRY_UPDATED,
};
// This is a helper function used to trigger a completion callback. It may
// only be called if callback_ is non-null.
void DoCallback(int rv);
......@@ -342,6 +355,8 @@ class HttpCache::Transaction : public HttpTransaction {
void ReportCacheActionStart();
void ReportCacheActionFinish();
void UpdateTransactionPattern(TransactionPattern new_transaction_pattern);
void RecordHistograms();
State next_state_;
const HttpRequestInfo* request_;
......@@ -353,7 +368,6 @@ class HttpCache::Transaction : public HttpTransaction {
ValidationHeaders external_validation_;
base::WeakPtr<HttpCache> cache_;
HttpCache::ActiveEntry* entry_;
base::TimeTicks entry_lock_waiting_since_;
HttpCache::ActiveEntry* new_entry_;
scoped_ptr<HttpTransaction> network_trans_;
CompletionCallback callback_; // Consumer's callback.
......@@ -380,6 +394,15 @@ class HttpCache::Transaction : public HttpTransaction {
uint64 final_upload_progress_;
base::WeakPtrFactory<Transaction> weak_factory_;
CompletionCallback io_callback_;
// Members used to track data for histograms.
TransactionPattern transaction_pattern_;
int bytes_read_from_cache_;
int bytes_read_from_network_;
base::TimeTicks entry_lock_waiting_since_;
base::TimeTicks first_cache_access_since_;
base::TimeTicks send_request_since_;
HttpTransactionDelegate* transaction_delegate_;
};
......
......@@ -339,6 +339,10 @@ MockDiskCache::~MockDiskCache() {
ReleaseAll();
}
net::CacheType MockDiskCache::GetCacheType() const {
return net::DISK_CACHE;
}
int32 MockDiskCache::GetEntryCount() const {
return static_cast<int32>(entries_.size());
}
......
......@@ -96,6 +96,7 @@ class MockDiskCache : public disk_cache::Backend {
MockDiskCache();
virtual ~MockDiskCache();
virtual net::CacheType GetCacheType() const OVERRIDE;
virtual int32 GetEntryCount() const OVERRIDE;
virtual int OpenEntry(const std::string& key, disk_cache::Entry** entry,
const net::CompletionCallback& callback) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment