summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 21:25:19 +0000
committerttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 21:25:19 +0000
commite6f13a18faec88935e939f191ba5b6508be52786 (patch)
treee074495906c3b682994f7b135a509cb977bedd11 /net
parent7d3b2545b5b449f1454e40a0865c8126bf4f119b (diff)
downloadchromium_src-e6f13a18faec88935e939f191ba5b6508be52786.zip
chromium_src-e6f13a18faec88935e939f191ba5b6508be52786.tar.gz
chromium_src-e6f13a18faec88935e939f191ba5b6508be52786.tar.bz2
Simple Cache: Add two optional stream 2 histograms
Add two histograms to see how often we remove old empty stream 2 files and how often we omit new empty stream 2 files. BUG=280592 Review URL: https://codereview.chromium.org/24400004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/disk_cache/simple/simple_entry_impl.cc4
-rw-r--r--net/disk_cache/simple/simple_index_file.h8
-rw-r--r--net/disk_cache/simple/simple_index_unittest.cc2
-rw-r--r--net/disk_cache/simple/simple_net_log_parameters.h6
-rw-r--r--net/disk_cache/simple/simple_synchronous_entry.cc15
-rw-r--r--net/disk_cache/simple/simple_synchronous_entry.h16
6 files changed, 35 insertions, 16 deletions
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc
index 3d2bc22..be7788b 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -1296,8 +1296,8 @@ int SimpleEntryImpl::SetStream0Data(net::IOBuffer* buf,
int buf_len,
bool truncate) {
// Currently, stream 0 is only used for HTTP headers, and always writes them
- // with a single, truncating write. Detect these writes and record the size
- // changes of the headers. Also, support writes to stream 0 that have
+ // with a single, truncating write. Detect these writes and record the size
+ // changes of the headers. Also, support writes to stream 0 that have
// different access patterns, as required by the API contract.
// All other clients of the Simple Cache are encouraged to use stream 1.
have_written_[0] = true;
diff --git a/net/disk_cache/simple/simple_index_file.h b/net/disk_cache/simple/simple_index_file.h
index ce19e2b..7562941 100644
--- a/net/disk_cache/simple/simple_index_file.h
+++ b/net/disk_cache/simple/simple_index_file.h
@@ -40,15 +40,15 @@ struct NET_EXPORT_PRIVATE SimpleIndexLoadResult {
};
// Simple Index File format is a pickle serialized data of IndexMetadata and
-// EntryMetadata objects. The file format is as follows: one instance of
+// EntryMetadata objects. The file format is as follows: one instance of
// serialized |IndexMetadata| followed serialized |EntryMetadata| entries
-// repeated |number_of_entries| amount of times. To know more about the format,
+// repeated |number_of_entries| amount of times. To know more about the format,
// see SimpleIndexFile::Serialize() and SeeSimpleIndexFile::LoadFromDisk()
// methods.
//
-// The non-static methods must run on the IO thread. All the real
+// The non-static methods must run on the IO thread. All the real
// work is done in the static methods, which are run on the cache thread
-// or in worker threads. Synchronization between methods is the
+// or in worker threads. Synchronization between methods is the
// responsibility of the caller.
class NET_EXPORT_PRIVATE SimpleIndexFile {
public:
diff --git a/net/disk_cache/simple/simple_index_unittest.cc b/net/disk_cache/simple/simple_index_unittest.cc
index 47ae24f..cee7bf3 100644
--- a/net/disk_cache/simple/simple_index_unittest.cc
+++ b/net/disk_cache/simple/simple_index_unittest.cc
@@ -538,7 +538,7 @@ TEST_F(SimpleIndexTest, BasicEviction) {
// Trigger an eviction, and make sure the right things are tossed.
// TODO(rdsmith): This is dependent on the innards of the implementation
- // as to at exactly what point we trigger eviction. Not sure how to fix
+ // as to at exactly what point we trigger eviction. Not sure how to fix
// that.
index()->UpdateEntrySize(hashes_.at<3>(), 475);
EXPECT_EQ(1, doom_entries_calls());
diff --git a/net/disk_cache/simple/simple_net_log_parameters.h b/net/disk_cache/simple/simple_net_log_parameters.h
index b6f386f..41ea9a2 100644
--- a/net/disk_cache/simple/simple_net_log_parameters.h
+++ b/net/disk_cache/simple/simple_net_log_parameters.h
@@ -14,14 +14,14 @@ namespace disk_cache {
class SimpleEntryImpl;
// Creates a NetLog callback that returns parameters for the construction of a
-// SimpleEntryImpl. Contains the entry's hash. |entry| can't be NULL and must
+// SimpleEntryImpl. Contains the entry's hash. |entry| can't be NULL and must
// outlive the returned callback.
net::NetLog::ParametersCallback CreateNetLogSimpleEntryConstructionCallback(
const SimpleEntryImpl* entry);
// Creates a NetLog callback that returns parameters for the result of calling
-// |CreateEntry| or |OpenEntry| on a SimpleEntryImpl. Contains the |net_error|
-// and, if successful, the entry's key. |entry| can't be NULL and must outlive
+// |CreateEntry| or |OpenEntry| on a SimpleEntryImpl. Contains the |net_error|
+// and, if successful, the entry's key. |entry| can't be NULL and must outlive
// the returned callback.
net::NetLog::ParametersCallback CreateNetLogSimpleEntryCreationCallback(
const SimpleEntryImpl* entry,
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index 13fd531..659d1c1 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -482,6 +482,12 @@ void SimpleSynchronousEntry::Close(
cluster_loss * 100 / (cluster_loss + file_size));
}
+ if (files_created_) {
+ const int stream2_file_index = GetFileIndexFromStreamIndex(2);
+ SIMPLE_CACHE_UMA(BOOLEAN, "EntryCreatedAndStream2Omitted", cache_type_,
+ empty_file_omitted_[stream2_file_index]);
+ }
+
RecordCloseResult(cache_type_, CLOSE_RESULT_SUCCESS);
have_open_files_ = false;
delete this;
@@ -622,6 +628,8 @@ bool SimpleSynchronousEntry::OpenFiles(
"SyncOpenEntryAge", cache_type_,
entry_age.InHours(), 1, 1000, 50);
+ files_created_ = false;
+
return true;
}
@@ -661,6 +669,8 @@ bool SimpleSynchronousEntry::CreateFiles(
for (int i = 0; i < kSimpleEntryStreamCount; ++i)
out_entry_stat->set_data_size(i, 0);
+ files_created_ = true;
+
return true;
}
@@ -754,6 +764,7 @@ int SimpleSynchronousEntry::InitializeForOpen(
}
}
+ bool removed_stream2 = false;
const int stream2_file_index = GetFileIndexFromStreamIndex(2);
DCHECK(CanOmitEmptyFile(stream2_file_index));
if (!empty_file_omitted_[stream2_file_index] &&
@@ -762,8 +773,12 @@ int SimpleSynchronousEntry::InitializeForOpen(
CloseFile(stream2_file_index);
DeleteFileForEntryHash(path_, entry_hash_, stream2_file_index);
empty_file_omitted_[stream2_file_index] = true;
+ removed_stream2 = true;
}
+ SIMPLE_CACHE_UMA(BOOLEAN, "EntryOpenedAndStream2Removed", cache_type_,
+ removed_stream2);
+
RecordSyncOpenResult(cache_type_, OPEN_ENTRY_SUCCESS, had_index);
initialized_ = true;
return net::OK;
diff --git a/net/disk_cache/simple/simple_synchronous_entry.h b/net/disk_cache/simple/simple_synchronous_entry.h
index 470e8e2..74823a2 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.h
+++ b/net/disk_cache/simple/simple_synchronous_entry.h
@@ -175,12 +175,12 @@ class SimpleSynchronousEntry {
// called.
~SimpleSynchronousEntry();
- // Tries to open one of the cache entry files. Succeeds if the open succeeds
+ // Tries to open one of the cache entry files. Succeeds if the open succeeds
// or if the file was not found and is allowed to be omitted if the
// corresponding stream is empty.
bool MaybeOpenFile(int file_index,
base::PlatformFileError* out_error);
- // Creates one of the cache entry files if necessary. If the file is allowed
+ // Creates one of the cache entry files if necessary. If the file is allowed
// to be omitted if the corresponding stream is empty, and if |file_required|
// is FILE_NOT_REQUIRED, then the file is not created; otherwise, it is.
bool MaybeCreateFile(int file_index,
@@ -193,7 +193,7 @@ class SimpleSynchronousEntry {
void CloseFile(int index);
void CloseFiles();
- // Returns a net error, i.e. net::OK on success. |had_index| is passed
+ // Returns a net error, i.e. net::OK on success. |had_index| is passed
// from the main entry for metrics purposes, and is true if the index was
// initialized when the open operation began.
int InitializeForOpen(bool had_index,
@@ -201,13 +201,13 @@ class SimpleSynchronousEntry {
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
uint32* out_stream_0_crc32);
- // Writes the header and key to a newly-created stream file. |index| is the
- // index of the stream. Returns true on success; returns false and sets
+ // Writes the header and key to a newly-created stream file. |index| is the
+ // index of the stream. Returns true on success; returns false and sets
// |*out_result| on failure.
bool InitializeCreatedFile(int index, CreateEntryResult* out_result);
// Returns a net error, including net::OK on success and net::FILE_EXISTS
- // when the entry already exists. |had_index| is passed from the main entry
+ // when the entry already exists. |had_index| is passed from the main entry
// for metrics purposes, and is true if the index was initialized when the
// create operation began.
int InitializeForCreate(bool had_index, SimpleEntryStat* out_entry_stat);
@@ -250,6 +250,10 @@ class SimpleSynchronousEntry {
// True if the corresponding stream is empty and therefore no on-disk file
// was created to store it.
bool empty_file_omitted_[kSimpleEntryFileCount];
+
+ // True if the entry was created, or false if it was opened. Used to log
+ // SimpleCache.*.EntryCreatedWithStream2Omitted only for created entries.
+ bool files_created_;
};
} // namespace disk_cache