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

Side by Side Diff: third_party/WebKit/Source/platform/PurgeableVector.cpp

Issue 1369253002: Add Web Resources usage to chrome://tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: Nits/. Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "platform/PurgeableVector.h" 32 #include "platform/PurgeableVector.h"
33 33
34 #include "public/platform/Platform.h" 34 #include "public/platform/Platform.h"
35 #include "public/platform/WebDiscardableMemory.h" 35 #include "public/platform/WebDiscardableMemory.h"
36 #include "public/platform/WebProcessMemoryDump.h"
36 #include "wtf/Assertions.h" 37 #include "wtf/Assertions.h"
37 #include "wtf/OwnPtr.h" 38 #include "wtf/OwnPtr.h"
38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
39 40
40 #include <cstring> 41 #include <cstring>
41 42
42 namespace blink { 43 namespace blink {
43 44
44 // WebDiscardableMemory allocations are expensive and page-grained. We only use 45 // WebDiscardableMemory allocations are expensive and page-grained. We only use
45 // them when there's a reasonable amount of memory to be saved by the OS 46 // them when there's a reasonable amount of memory to be saved by the OS
(...skipping 26 matching lines...) Expand all
72 // Using reserveInitialCapacity() on the underlying vector ensures that the vector uses the 73 // Using reserveInitialCapacity() on the underlying vector ensures that the vector uses the
73 // exact specified capacity to avoid consuming too much memory for small resources. 74 // exact specified capacity to avoid consuming too much memory for small resources.
74 m_vector.reserveInitialCapacity(capacity); 75 m_vector.reserveInitialCapacity(capacity);
75 } else { 76 } else {
76 m_vector.reserveCapacity(capacity); 77 m_vector.reserveCapacity(capacity);
77 } 78 }
78 79
79 moveDataFromDiscardableToVector(); 80 moveDataFromDiscardableToVector();
80 } 81 }
81 82
83 void PurgeableVector::onMemoryDump(const String& dumpName, WebProcessMemoryDump* memoryDump) const
84 {
85 WebMemoryAllocatorDump* dump = memoryDump->createDiscardableMemoryAllocatorD ump(dumpName, m_discardable.get());
86 if (m_discardable) {
87 dump->AddScalar("discardable_size", "bytes", m_discardableSize);
haraken 2015/09/28 14:54:02 This is confusing. Even if m_discardable is non-nu
ssid 2015/09/28 16:24:38 I am sorry I screwed up the condition here. Now fi
88 } else if (m_vector.size() > 0) {
89 dump->AddScalar("size", "bytes", m_vector.size());
90 memoryDump->AddSuballocation(dump->guid(), String(WTF::Partitions::alloc atorPoolNameForTracing()));
haraken 2015/09/28 14:54:02 What does allocatorPoolNameForTracing return? (I c
ssid 2015/09/28 16:24:38 Sorry, this is added in this CL https://codereview
91 }
92 }
93
82 void PurgeableVector::moveDataFromDiscardableToVector() 94 void PurgeableVector::moveDataFromDiscardableToVector()
83 { 95 {
84 if (m_discardable) { 96 if (m_discardable) {
85 m_vector.append(static_cast<const char*>(m_discardable->data()), m_disca rdableSize); 97 m_vector.append(static_cast<const char*>(m_discardable->data()), m_disca rdableSize);
86 clearDiscardable(); 98 clearDiscardable();
87 } 99 }
88 } 100 }
89 101
90 void PurgeableVector::clearDiscardable() 102 void PurgeableVector::clearDiscardable()
91 { 103 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // fragmentation. 265 // fragmentation.
254 // Since the page size is only used below to minimize fragmentation it's sti ll safe to use it 266 // Since the page size is only used below to minimize fragmentation it's sti ll safe to use it
255 // even if it gets out of sync (e.g. due to the use of huge pages). 267 // even if it gets out of sync (e.g. due to the use of huge pages).
256 const size_t kPageSize = 4096; 268 const size_t kPageSize = 4096;
257 newCapacity = (newCapacity + kPageSize - 1) & ~(kPageSize - 1); 269 newCapacity = (newCapacity + kPageSize - 1) & ~(kPageSize - 1);
258 270
259 return std::max(capacity, newCapacity); // Overflow check. 271 return std::max(capacity, newCapacity); // Overflow check.
260 } 272 }
261 273
262 } // namespace blink 274 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698