Chromium Code Reviews| Index: Source/wtf/Partitions.cpp |
| diff --git a/Source/wtf/Partitions.cpp b/Source/wtf/Partitions.cpp |
| index 800632ea4a009c43f26dd95ac4e1a18aab0a100b..7f3422d98a4070fe4bddb5f69659fd2d1e176e3a 100644 |
| --- a/Source/wtf/Partitions.cpp |
| +++ b/Source/wtf/Partitions.cpp |
| @@ -42,8 +42,9 @@ PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
| PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
| SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; |
| SizeSpecificPartitionAllocator<1024> Partitions::m_renderingAllocator; |
| +HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; |
| -void Partitions::initialize() |
| +void Partitions::initialize(HistogramEnumerationFunction histogramEnumeration) |
| { |
| static int lock = 0; |
| // Guard against two threads hitting here in parallel. |
| @@ -53,6 +54,7 @@ void Partitions::initialize() |
| m_bufferAllocator.init(); |
| m_objectModelAllocator.init(); |
| m_renderingAllocator.init(); |
| + m_histogramEnumeration = histogramEnumeration; |
| s_initialized = true; |
| } |
| spinLockUnlock(&lock); |
| @@ -69,4 +71,21 @@ void Partitions::shutdown() |
| (void) m_fastMallocAllocator.shutdown(); |
| } |
| +void Partitions::recordMemoryUsageIfNeeded() |
|
Chris Evans
2015/04/02 15:53:01
This might be called on any thread -- is that OK?
haraken
2015/04/02 23:31:32
To avoid races on the static variable, I restricte
|
| +{ |
| + static const size_t maxSizeInMB = 4 * 1024; |
| + static bool s_isUsedSlot[maxSizeInMB] = { false }; |
|
Chris Evans
2015/04/02 15:53:01
This is kind of big -- 4KB. If we keep it, I recom
|
| + |
| + if (!m_histogramEnumeration) |
| + return; |
| + size_t sizeInMB = Partitions::totalSizeOfCommittedPages() / 1024 / 1024; |
| + if (sizeInMB >= maxSizeInMB) |
| + sizeInMB = maxSizeInMB - 1; |
| + if (!s_isUsedSlot[sizeInMB]) { |
| + // Send the UseCounter only once for each slot for each renderer process. |
|
Chris Evans
2015/04/02 15:53:01
Another strategy -- which would eliminate the abov
haraken
2015/04/02 23:31:32
Nice idea! Done.
|
| + m_histogramEnumeration("PartitionAlloc.CommittedSize", sizeInMB, maxSizeInMB); |
| + s_isUsedSlot[sizeInMB] = true; |
| + } |
| +} |
| + |
| } // namespace WTF |