Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: storage/browser/blob/blob_storage_context.cc

Issue 812843005: [Storage] Added histograms for blob storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "storage/browser/blob/blob_storage_context.h" 5 #include "storage/browser/blob/blob_storage_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/metrics/histogram.h"
11 #include "storage/browser/blob/blob_data_handle.h" 12 #include "storage/browser/blob/blob_data_handle.h"
12 #include "storage/common/blob/blob_data.h" 13 #include "storage/common/blob/blob_data.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace storage { 16 namespace storage {
16 17
17 namespace { 18 namespace {
18 19
19 // We can't use GURL directly for these hash fragment manipulations 20 // We can't use GURL directly for these hash fragment manipulations
20 // since it doesn't have specific knowlege of the BlobURL format. GURL 21 // since it doesn't have specific knowlege of the BlobURL format. GURL
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // list of Data, File, and FileSystem items. Aggregated TYPE_BLOB items 137 // list of Data, File, and FileSystem items. Aggregated TYPE_BLOB items
137 // are expanded into the primitive constituent types. 138 // are expanded into the primitive constituent types.
138 // 1) The Data item is denoted by the raw data and length. 139 // 1) The Data item is denoted by the raw data and length.
139 // 2) The File item is denoted by the file path, the range and the expected 140 // 2) The File item is denoted by the file path, the range and the expected
140 // modification time. 141 // modification time.
141 // 3) The FileSystem File item is denoted by the FileSystem URL, the range 142 // 3) The FileSystem File item is denoted by the FileSystem URL, the range
142 // and the expected modification time. 143 // and the expected modification time.
143 // 4) The Blob items are expanded. 144 // 4) The Blob items are expanded.
144 // TODO(michaeln): Would be nice to avoid copying Data items when expanding. 145 // TODO(michaeln): Would be nice to avoid copying Data items when expanding.
145 146
146 DCHECK(item.length() > 0); 147 uint64 length = item.length();
148 DCHECK(length > 0);
Alexei Svitkine (slow) 2015/01/06 16:47:42 Nit: DCHECK_GT
dmurph 2015/01/06 20:15:44 Done.
149 UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeBeforeAppend",
150 memory_usage_ / 1024);
147 switch (item.type()) { 151 switch (item.type()) {
148 case BlobData::Item::TYPE_BYTES: 152 case BlobData::Item::TYPE_BYTES:
153 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.Bytes", length);
149 DCHECK(!item.offset()); 154 DCHECK(!item.offset());
150 exceeded_memory = !AppendBytesItem(target_blob_data, 155 exceeded_memory = !AppendBytesItem(target_blob_data,
151 item.bytes(), 156 item.bytes(),
152 static_cast<int64>(item.length())); 157 static_cast<int64>(length));
153 break; 158 break;
154 case BlobData::Item::TYPE_FILE: 159 case BlobData::Item::TYPE_FILE:
160 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.File", length);
155 AppendFileItem(target_blob_data, 161 AppendFileItem(target_blob_data,
156 item.path(), 162 item.path(),
157 item.offset(), 163 item.offset(),
158 item.length(), 164 length,
159 item.expected_modification_time()); 165 item.expected_modification_time());
160 break; 166 break;
161 case BlobData::Item::TYPE_FILE_FILESYSTEM: 167 case BlobData::Item::TYPE_FILE_FILESYSTEM:
168 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.FileSystem", length);
162 AppendFileSystemFileItem(target_blob_data, 169 AppendFileSystemFileItem(target_blob_data,
163 item.filesystem_url(), 170 item.filesystem_url(),
164 item.offset(), 171 item.offset(),
165 item.length(), 172 length,
166 item.expected_modification_time()); 173 item.expected_modification_time());
167 break; 174 break;
168 case BlobData::Item::TYPE_BLOB: { 175 case BlobData::Item::TYPE_BLOB: {
176 UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.Blob", length);
169 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid()); 177 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid());
170 if (src) 178 if (src)
171 exceeded_memory = !ExpandStorageItems(target_blob_data, 179 exceeded_memory = !ExpandStorageItems(target_blob_data,
172 src->data(), 180 src->data(),
173 item.offset(), 181 item.offset(),
174 item.length()); 182 item.length());
175 break; 183 break;
176 } 184 }
177 default: 185 default:
178 NOTREACHED(); 186 NOTREACHED();
179 break; 187 break;
180 } 188 }
189 UMA_HISTOGRAM_COUNTS("Storage.Blob.StorageSizeAfterAppend",
190 memory_usage_ / 1024);
Alexei Svitkine (slow) 2015/01/06 16:47:41 Just wondering why you actually need both the Befo
dmurph 2015/01/06 20:15:44 I want to find the distribution of the final stora
Alexei Svitkine (slow) 2015/01/06 20:22:48 Ah, I see. You'll have to deal with some skew (i.e
181 191
182 // If we're using too much memory, drop this blob's data. 192 // If we're using too much memory, drop this blob's data.
183 // TODO(michaeln): Blob memory storage does not yet spill over to disk, 193 // TODO(michaeln): Blob memory storage does not yet spill over to disk,
184 // as a stop gap, we'll prevent memory usage over a max amount. 194 // as a stop gap, we'll prevent memory usage over a max amount.
195 UMA_HISTOGRAM_BOOLEAN("Storage.BlobItem.ExceededMemory", exceeded_memory);
Alexei Svitkine (slow) 2015/01/06 16:47:42 Since exceeded memory can only happen on TYPE_BLOB
dmurph 2015/01/06 20:15:44 It's set in both TYPE_BLOB and TYPE_BYTES However,
185 if (exceeded_memory) { 196 if (exceeded_memory) {
186 memory_usage_ -= target_blob_data->GetMemoryUsage(); 197 memory_usage_ -= target_blob_data->GetMemoryUsage();
187 found->second.flags |= EXCEEDED_MEMORY; 198 found->second.flags |= EXCEEDED_MEMORY;
188 found->second.data = new BlobData(uuid); 199 found->second.data = new BlobData(uuid);
189 return; 200 return;
190 } 201 }
191 } 202 }
192 203
193 void BlobStorageContext::FinishBuildingBlob( 204 void BlobStorageContext::FinishBuildingBlob(
194 const std::string& uuid, const std::string& content_type) { 205 const std::string& uuid, const std::string& content_type) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (found == blob_map_.end()) 327 if (found == blob_map_.end())
317 return false; 328 return false;
318 return found->second.flags & BEING_BUILT; 329 return found->second.flags & BEING_BUILT;
319 } 330 }
320 331
321 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { 332 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) {
322 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 333 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
323 } 334 }
324 335
325 } // namespace storage 336 } // namespace storage
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698