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

Side by Side Diff: base/trace_event/heap_profiler_allocation_register.cc

Issue 2890363003: Enable sharding of AllocationRegister on desktop. (Closed)
Patch Set: comment from primiano. Created 3 years, 7 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/trace_event/heap_profiler_allocation_register.h" 5 #include "base/trace_event/heap_profiler_allocation_register.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/trace_event/trace_event_memory_overhead.h"
11
12 namespace base { 10 namespace base {
13 namespace trace_event { 11 namespace trace_event {
14 12
15 AllocationRegister::ConstIterator::ConstIterator( 13 AllocationRegister::ConstIterator::ConstIterator(
16 const AllocationRegister& alloc_register, 14 const AllocationRegister& alloc_register,
17 AllocationIndex index) 15 AllocationIndex index)
18 : register_(alloc_register), index_(index) {} 16 : register_(alloc_register), index_(index) {}
19 17
20 void AllocationRegister::ConstIterator::operator++() { 18 void AllocationRegister::ConstIterator::operator++() {
21 index_ = register_.allocations_.Next(index_ + 1); 19 index_ = register_.allocations_.Next(index_ + 1);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 143 }
146 144
147 AllocationRegister::ConstIterator AllocationRegister::begin() const { 145 AllocationRegister::ConstIterator AllocationRegister::begin() const {
148 return ConstIterator(*this, allocations_.Next(0)); 146 return ConstIterator(*this, allocations_.Next(0));
149 } 147 }
150 148
151 AllocationRegister::ConstIterator AllocationRegister::end() const { 149 AllocationRegister::ConstIterator AllocationRegister::end() const {
152 return ConstIterator(*this, AllocationMap::kInvalidKVIndex); 150 return ConstIterator(*this, AllocationMap::kInvalidKVIndex);
153 } 151 }
154 152
155 void AllocationRegister::EstimateTraceMemoryOverhead( 153 size_t AllocationRegister::EstimateAllocatedMemory() const {
156 TraceEventMemoryOverhead* overhead) const { 154 return sizeof(AllocationRegister);
157 size_t allocated = sizeof(AllocationRegister); 155 }
158 size_t resident = sizeof(AllocationRegister) + 156
159 allocations_.EstimateUsedMemory() + 157 size_t AllocationRegister::EstimateResidentMemory() const {
160 backtraces_.EstimateUsedMemory(); 158 return sizeof(AllocationRegister) + allocations_.EstimateUsedMemory() +
161 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerAllocationRegister, 159 backtraces_.EstimateUsedMemory();
162 allocated, resident);
163 } 160 }
164 161
165 AllocationRegister::BacktraceMap::KVIndex AllocationRegister::InsertBacktrace( 162 AllocationRegister::BacktraceMap::KVIndex AllocationRegister::InsertBacktrace(
166 const Backtrace& backtrace) { 163 const Backtrace& backtrace) {
167 auto index = backtraces_.Insert(backtrace, 0).first; 164 auto index = backtraces_.Insert(backtrace, 0).first;
168 if (index == BacktraceMap::kInvalidKVIndex) 165 if (index == BacktraceMap::kInvalidKVIndex)
169 return kOutOfStorageBacktraceIndex; 166 return kOutOfStorageBacktraceIndex;
170 auto& backtrace_and_count = backtraces_.Get(index); 167 auto& backtrace_and_count = backtraces_.Get(index);
171 backtrace_and_count.second++; 168 backtrace_and_count.second++;
172 return index; 169 return index;
(...skipping 13 matching lines...) Expand all
186 const auto& address_and_info = allocations_.Get(index); 183 const auto& address_and_info = allocations_.Get(index);
187 const auto& backtrace_and_count = 184 const auto& backtrace_and_count =
188 backtraces_.Get(address_and_info.second.backtrace_index); 185 backtraces_.Get(address_and_info.second.backtrace_index);
189 return {address_and_info.first, address_and_info.second.size, 186 return {address_and_info.first, address_and_info.second.size,
190 AllocationContext(backtrace_and_count.first, 187 AllocationContext(backtrace_and_count.first,
191 address_and_info.second.type_name)}; 188 address_and_info.second.type_name)};
192 } 189 }
193 190
194 } // namespace trace_event 191 } // namespace trace_event
195 } // namespace base 192 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698