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

Side by Side Diff: components/metrics/leak_detector/leak_detector_impl.h

Issue 1892283004: Add cooldown to LeakDetectorImpl leak report generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased; remove JuliaSet history comparison Created 4 years, 8 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 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ 5 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_
6 #define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ 6 #define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // records kept is capped. If adding a new record exceeds that limit, the 165 // records kept is capped. If adding a new record exceeds that limit, the
166 // oldest record is discarded. See the function definition for more details. 166 // oldest record is discarded. See the function definition for more details.
167 void RecordCurrentAllocationDataInHistory(); 167 void RecordCurrentAllocationDataInHistory();
168 168
169 // Store the data collected by RecordCurrentAllocationDataInHistory() in 169 // Store the data collected by RecordCurrentAllocationDataInHistory() in
170 // |*report|. Not all net alloc counts per call site will be stored, only the 170 // |*report|. Not all net alloc counts per call site will be stored, only the
171 // count for size=|size| and made from |call_site|. 171 // count for size=|size| and made from |call_site|.
172 void StoreHistoricalDataInReport(size_t size, const CallStack* call_site, 172 void StoreHistoricalDataInReport(size_t size, const CallStack* call_site,
173 LeakReport* report); 173 LeakReport* report);
174 174
175 // Decrements the cooldown counter (value) for each entry in
176 // |cooldowns_per_leak_|. If the cooldown counter reaches 0, the entry is
177 // removed. Thus, all extantentries in |cooldowns_per_leak_| maintain a
178 // positive count.
179 void UpdateLeakCooldowns();
180
181 // Returns true if a particular leak signature (alloc size + call site) does
182 // not have an active cooldown counter (i.e. does not have an entry in
183 // |cooldowns_per_leak_|.
184 bool ReadyToGenerateReport(size_t size, const CallStack* call_stack) const;
185
186 // Resets the counter for a leak signature (alloc size + call site) in
187 // |cooldowns_per_leak_| to the max cooldown value. Creates a new entry in the
188 // container if none exists for this leak signature.
189 void ResetLeakCooldown(size_t size, const CallStack* call_stack);
190
175 // Owns all unique call stack objects, which are allocated on the heap. Any 191 // Owns all unique call stack objects, which are allocated on the heap. Any
176 // other class or function that references a call stack must get it from here, 192 // other class or function that references a call stack must get it from here,
177 // but may not take ownership of the call stack object. 193 // but may not take ownership of the call stack object.
178 CallStackManager call_stack_manager_; 194 CallStackManager call_stack_manager_;
179 195
180 // Allocation stats. 196 // Allocation stats.
181 uint64_t num_allocs_; 197 uint64_t num_allocs_;
182 uint64_t num_frees_; 198 uint64_t num_frees_;
183 uint64_t alloc_size_; 199 uint64_t alloc_size_;
184 uint64_t free_size_; 200 uint64_t free_size_;
(...skipping 14 matching lines...) Expand all
199 // Allocation stats for each size. 215 // Allocation stats for each size.
200 InternalVector<AllocSizeEntry> size_entries_; 216 InternalVector<AllocSizeEntry> size_entries_;
201 217
202 // Tracks the net number of allocations per size over time. Each list item is 218 // Tracks the net number of allocations per size over time. Each list item is
203 // a vector containing the allocation counts for each size. The vector element 219 // a vector containing the allocation counts for each size. The vector element
204 // with index i corresponds to sizes |i * 4| to |i * 4 + 3|. The oldest size 220 // with index i corresponds to sizes |i * 4| to |i * 4 + 3|. The oldest size
205 // breakdowns is at the head of the list, and new size breakdowns should be 221 // breakdowns is at the head of the list, and new size breakdowns should be
206 // added to the tail of the list. 222 // added to the tail of the list.
207 InternalList<InternalVector<uint32_t>> size_breakdown_history_; 223 InternalList<InternalVector<uint32_t>> size_breakdown_history_;
208 224
225 // Key: leak signature (alloc size + call site)
226 // Value: number of leak analyses before another leak report can be generated
227 // for that leak.
228 std::map<std::pair<size_t, const CallStack*>, size_t> cooldowns_per_leak_;
229
209 // Address mapping info of the current binary. 230 // Address mapping info of the current binary.
210 uintptr_t mapping_addr_; 231 uintptr_t mapping_addr_;
211 size_t mapping_size_; 232 size_t mapping_size_;
212 233
213 // Number of consecutive times an allocation size must trigger suspicion to be 234 // Number of consecutive times an allocation size must trigger suspicion to be
214 // considered a leak suspect. 235 // considered a leak suspect.
215 int size_suspicion_threshold_; 236 int size_suspicion_threshold_;
216 237
217 // Number of consecutive times a call stack must trigger suspicion to be 238 // Number of consecutive times a call stack must trigger suspicion to be
218 // considered a leak suspect. 239 // considered a leak suspect.
219 int call_stack_suspicion_threshold_; 240 int call_stack_suspicion_threshold_;
220 241
221 DISALLOW_COPY_AND_ASSIGN(LeakDetectorImpl); 242 DISALLOW_COPY_AND_ASSIGN(LeakDetectorImpl);
222 }; 243 };
223 244
224 } // namespace leak_detector 245 } // namespace leak_detector
225 } // namespace metrics 246 } // namespace metrics
226 247
227 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ 248 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698