diff options
author | clamy@chromium.org <clamy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 23:38:54 +0000 |
---|---|---|
committer | clamy@chromium.org <clamy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-17 23:38:54 +0000 |
commit | 22ce7b1e249a3d5401892fd30bae74d0ea06cbfb (patch) | |
tree | 4fe633665d5c83581301180fe0f84404e8e2bd88 /net | |
parent | 4f1cd759f5bc58dc12238df5b7d21610b8882dd0 (diff) | |
download | chromium_src-22ce7b1e249a3d5401892fd30bae74d0ea06cbfb.zip chromium_src-22ce7b1e249a3d5401892fd30bae74d0ea06cbfb.tar.gz chromium_src-22ce7b1e249a3d5401892fd30bae74d0ea06cbfb.tar.bz2 |
SimpleCache: add histogram to measure parallelizable reads
This CL adds an histogram that will record for each queued read operation
whether it could have been issued in parallel of the rpevious operation.
BUG=
Review URL: https://chromiumcodereview.appspot.com/19372003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/simple/simple_entry_impl.cc | 80 | ||||
-rw-r--r-- | net/disk_cache/simple/simple_entry_impl.h | 9 |
2 files changed, 61 insertions, 28 deletions
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc index 32f695b..d2620d2 100644 --- a/net/disk_cache/simple/simple_entry_impl.cc +++ b/net/disk_cache/simple/simple_entry_impl.cc @@ -108,7 +108,8 @@ SimpleEntryImpl::SimpleEntryImpl(SimpleBackendImpl* backend, state_(STATE_UNINITIALIZED), synchronous_entry_(NULL), net_log_(net::BoundNetLog::Make( - net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY)) { + net_log, net::NetLog::SOURCE_DISK_CACHE_ENTRY)), + last_queued_op_is_read_(false) { COMPILE_ASSERT(arraysize(data_size_) == arraysize(crc32s_end_offset_), arrays_should_be_same_size); COMPILE_ASSERT(arraysize(data_size_) == arraysize(crc32s_), @@ -147,8 +148,10 @@ int SimpleEntryImpl::OpenEntry(Entry** out_entry, if (open_entry_index_enum == INDEX_MISS) return net::ERR_FAILED; - pending_operations_.push(base::Bind(&SimpleEntryImpl::OpenEntryInternal, - this, callback, out_entry)); + EnqueueOperation(base::Bind(&SimpleEntryImpl::OpenEntryInternal, + this, + callback, + out_entry)); RunNextOperationIfNeeded(); return net::ERR_IO_PENDING; } @@ -162,16 +165,16 @@ int SimpleEntryImpl::CreateEntry(Entry** out_entry, pending_operations_.size() == 0) { ReturnEntryToCaller(out_entry); // We can do optimistic Create. - pending_operations_.push(base::Bind(&SimpleEntryImpl::CreateEntryInternal, - this, - CompletionCallback(), - static_cast<Entry**>(NULL))); + EnqueueOperation(base::Bind(&SimpleEntryImpl::CreateEntryInternal, + this, + CompletionCallback(), + static_cast<Entry**>(NULL))); ret_value = net::OK; } else { - pending_operations_.push(base::Bind(&SimpleEntryImpl::CreateEntryInternal, - this, - callback, - out_entry)); + EnqueueOperation(base::Bind(&SimpleEntryImpl::CreateEntryInternal, + this, + callback, + out_entry)); ret_value = net::ERR_IO_PENDING; } @@ -212,7 +215,7 @@ void SimpleEntryImpl::Close() { return; } - pending_operations_.push(base::Bind(&SimpleEntryImpl::CloseInternal, this)); + EnqueueOperation(base::Bind(&SimpleEntryImpl::CloseInternal, this)); DCHECK(!HasOneRef()); Release(); // Balanced in ReturnEntryToCaller(). RunNextOperationIfNeeded(); @@ -258,14 +261,13 @@ int SimpleEntryImpl::ReadData(int stream_index, // TODO(felipeg): Optimization: Add support for truly parallel read // operations. - pending_operations_.push( - base::Bind(&SimpleEntryImpl::ReadDataInternal, - this, - stream_index, - offset, - make_scoped_refptr(buf), - buf_len, - callback)); + EnqueueReadOperation(base::Bind(&SimpleEntryImpl::ReadDataInternal, + this, + stream_index, + offset, + make_scoped_refptr(buf), + buf_len, + callback)); RunNextOperationIfNeeded(); return net::ERR_IO_PENDING; } @@ -303,16 +305,24 @@ int SimpleEntryImpl::WriteData(int stream_index, buf_copy = new IOBuffer(buf_len); memcpy(buf_copy->data(), buf->data(), buf_len); } - pending_operations_.push( - base::Bind(&SimpleEntryImpl::WriteDataInternal, this, stream_index, - offset, make_scoped_refptr(buf_copy), buf_len, - CompletionCallback(), truncate)); + EnqueueOperation(base::Bind(&SimpleEntryImpl::WriteDataInternal, + this, + stream_index, + offset, + make_scoped_refptr(buf_copy), + buf_len, + CompletionCallback(), + truncate)); ret_value = buf_len; } else { - pending_operations_.push( - base::Bind(&SimpleEntryImpl::WriteDataInternal, this, stream_index, - offset, make_scoped_refptr(buf), buf_len, callback, - truncate)); + EnqueueOperation(base::Bind(&SimpleEntryImpl::WriteDataInternal, + this, + stream_index, + offset, + make_scoped_refptr(buf), + buf_len, + callback, + truncate)); ret_value = net::ERR_IO_PENDING; } @@ -421,6 +431,20 @@ void SimpleEntryImpl::RunNextOperationIfNeeded() { } } +void SimpleEntryImpl::EnqueueOperation(const base::Closure& operation) { + last_queued_op_is_read_ = false; + pending_operations_.push(operation); +} + +void SimpleEntryImpl::EnqueueReadOperation(const base::Closure& operation) { + bool parallelizable_read = last_queued_op_is_read_ && + (!pending_operations_.empty() || state_ == STATE_IO_PENDING); + UMA_HISTOGRAM_BOOLEAN("SimpleCache.ReadIsParallelizable", + parallelizable_read); + last_queued_op_is_read_ = true; + pending_operations_.push(operation); +} + void SimpleEntryImpl::OpenEntryInternal(const CompletionCallback& callback, Entry** out_entry) { ScopedOperationRunner operation_runner(this); diff --git a/net/disk_cache/simple/simple_entry_impl.h b/net/disk_cache/simple/simple_entry_impl.h index b34e567..f816f63 100644 --- a/net/disk_cache/simple/simple_entry_impl.h +++ b/net/disk_cache/simple/simple_entry_impl.h @@ -144,6 +144,12 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, // the last reference. void RunNextOperationIfNeeded(); + // Adds a non read operation to the queue of operations. + void EnqueueOperation(const base::Closure& operation); + + // Adds a read operation to the queue of operations. + void EnqueueReadOperation(const base::Closure& operation); + void OpenEntryInternal(const CompletionCallback& callback, Entry** out_entry); void CreateEntryInternal(const CompletionCallback& callback, @@ -261,6 +267,9 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, std::queue<base::Closure> pending_operations_; net::BoundNetLog net_log_; + + // Used for SimpleCache.ReadIsParallelizable histogram. + bool last_queued_op_is_read_; }; } // namespace disk_cache |