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

Unified Diff: components/metrics/leak_detector/leak_detector_impl.h

Issue 1870233003: Record call site history in LeakDetectorImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify comments in RankedSet 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/metrics/leak_detector/leak_detector_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/leak_detector/leak_detector_impl.h
diff --git a/components/metrics/leak_detector/leak_detector_impl.h b/components/metrics/leak_detector/leak_detector_impl.h
index 7c3ec24a54b7519eb8266b7efc0b06e027d3f38a..144582d704ace30acc30483fc687e3a83dade6fa 100644
--- a/components/metrics/leak_detector/leak_detector_impl.h
+++ b/components/metrics/leak_detector/leak_detector_impl.h
@@ -38,6 +38,22 @@ class LeakDetectorImpl {
// Leak report generated by LeakDetectorImpl.
class LeakReport {
public:
+ // Stores a record of the allocation bookkeeping taken at a single moment in
+ // time.
+ struct AllocationBreakdown {
+ AllocationBreakdown();
+ ~AllocationBreakdown();
+
+ // The contents of |LeakDetectorImpl::size_breakdown_history_| when this
+ // report was generated. See comment description of that variable.
+ InternalVector<uint32_t> counts_by_size;
+
+ // The net number of allocations with alloc size of
+ // |Leakreport::alloc_size_bytes_| allocated from |call_stack_|, at the
+ // time this record was generated.
+ uint32_t count_for_call_stack;
+ };
+
LeakReport();
~LeakReport();
@@ -45,9 +61,8 @@ class LeakDetectorImpl {
const InternalVector<uintptr_t>& call_stack() const { return call_stack_; }
- const InternalVector<InternalVector<uint32_t>>& size_breakdown_history()
- const {
- return size_breakdown_history_;
+ const InternalVector<AllocationBreakdown>& alloc_breakdown_history() const {
+ return alloc_breakdown_history_;
}
// Used to compare the contents of two leak reports.
@@ -65,9 +80,9 @@ class LeakDetectorImpl {
// will contain offsets in the executable binary.
InternalVector<uintptr_t> call_stack_;
- // A snapshot of LeakDetectorImpl::size_breakdown_history_ when this report
- // was generated. See comment description of that variable.
- InternalVector<InternalVector<uint32_t>> size_breakdown_history_;
+ // Records of allocation bookkeeping over time. The first element is the
+ // oldest entry and the last element is the newest.
+ InternalVector<AllocationBreakdown> alloc_breakdown_history_;
};
LeakDetectorImpl(uintptr_t mapping_addr,
@@ -100,6 +115,16 @@ class LeakDetectorImpl {
// A stack table, if this size is being profiled for stack as well.
CallStackTable* stack_table;
+ // Historical records of allocation breakdown by call site, for a particular
+ // allocation size. Each entry in the list is a RankedSet containing the top
+ // call sites ordered by most number of call sites, collected during a leak
+ // analysis. The oldest record is at the head and the newest record is at
+ // the tail.
+ InternalList<RankedSet> call_site_breakdown_history;
+
+ AllocSizeEntry();
+ ~AllocSizeEntry();
+
// Returns net number of allocs.
uint32_t GetNetAllocs() const { return num_allocs - num_frees; }
};
@@ -129,6 +154,22 @@ class LeakDetectorImpl {
// current binary, just return |ptr| as an integer.
uintptr_t GetOffset(const void* ptr) const;
+ // Record some of the current allocation bookkeeping. The net number of allocs
+ // per size is recorded in |size_breakdown_history_|. The net number of allocs
+ // per call site for each size is recorded in
+ // |AllocSizeEntry::call_site_breakdown_history|.
+ //
+ // Not all the net alloc counts are recorded. And the number of historical
+ // records kept is capped. If adding a new record exceeds that limit, the
+ // oldest record is discarded. See the function definition for more details.
+ void RecordCurrentAllocationDataInHistory();
+
+ // Store the data collected by RecordCurrentAllocationDataInHistory() in
+ // |*report|. Not all net alloc counts per call site will be stored, only the
+ // count for size=|size| and made from |call_site|.
+ void StoreHistoricalDataInReport(size_t size, const CallStack* call_site,
+ LeakReport* report);
+
// Owns all unique call stack objects, which are allocated on the heap. Any
// other class or function that references a call stack must get it from here,
// but may not take ownership of the call stack object.
« no previous file with comments | « no previous file | components/metrics/leak_detector/leak_detector_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698