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

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

Issue 2403223002: Leak reports collect information about the last uptrend (Closed)
Patch Set: Created 4 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 // 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_CALL_STACK_TABLE_H_ 5 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_
6 #define COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_ 6 #define COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 30 matching lines...) Expand all
41 void Remove(const CallStack* call_stack); 41 void Remove(const CallStack* call_stack);
42 42
43 // Check for leak patterns in the allocation data. 43 // Check for leak patterns in the allocation data.
44 void TestForLeaks(); 44 void TestForLeaks();
45 45
46 // Get the top N entries in the CallStackTable, ranked by net number of 46 // Get the top N entries in the CallStackTable, ranked by net number of
47 // allocations. N is given by |top_entries->max_size()|, so |*top_entries| 47 // allocations. N is given by |top_entries->max_size()|, so |*top_entries|
48 // must already be initialized with that number. 48 // must already be initialized with that number.
49 void GetTopCallStacks(RankedSet* top_entries) const; 49 void GetTopCallStacks(RankedSet* top_entries) const;
50 50
51 // Updates fields in CallStackCountInfo for every stored call stack.
Simon Que 2016/10/11 01:11:05 Explain the behavior in more detail. Mention e.g.
mwlodar 2016/10/11 07:13:23 Done.
52 void UpdateLastDropInfo(size_t timestamp);
53
54 // Retrieves the number of timestamps and the count growth since the last
Simon Que 2016/10/11 01:11:05 "number of timestamps" isn't quite right... did yo
mwlodar 2016/10/11 07:13:24 Done.
55 // observed drop in the number for allocations for the given call stack.
56 void GetLastUptrendInfo(const CallStack* call_stack, size_t timestamp,
57 size_t *timestamp_delta, uint32_t *count_delta) const;
Simon Que 2016/10/11 01:11:05 Nit: alignment
mwlodar 2016/10/11 07:13:23 Done.
58
51 const LeakAnalyzer& leak_analyzer() const { return leak_analyzer_; } 59 const LeakAnalyzer& leak_analyzer() const { return leak_analyzer_; }
52 60
53 size_t size() const { return entry_map_.size(); } 61 size_t size() const { return entry_map_.size(); }
54 bool empty() const { return entry_map_.empty(); } 62 bool empty() const { return entry_map_.empty(); }
55 63
56 uint32_t num_allocs() const { return num_allocs_; } 64 uint32_t num_allocs() const { return num_allocs_; }
57 uint32_t num_frees() const { return num_frees_; } 65 uint32_t num_frees() const { return num_frees_; }
58 66
59 private: 67 private:
68 struct CallStackCountInfo {
69 uint32_t count, previous_count, last_drop_count;
70 size_t last_drop_timestamp;
71 };
72
60 // Total number of allocs and frees in this table. 73 // Total number of allocs and frees in this table.
61 uint32_t num_allocs_; 74 uint32_t num_allocs_;
62 uint32_t num_frees_; 75 uint32_t num_frees_;
63 76
64 // Hash table containing entries. Uses CustomAllocator to avoid recursive 77 // Hash table containing entries. Uses CustomAllocator to avoid recursive
65 // malloc hook invocation when analyzing allocs and frees. 78 // malloc hook invocation when analyzing allocs and frees.
66 using TableEntryAllocator = 79 using TableEntryAllocator =
67 STLAllocator<std::pair<const CallStack* const, uint32_t>, 80 STLAllocator<std::pair<const CallStack* const, uint32_t>,
68 CustomAllocator>; 81 CustomAllocator>;
69 82
70 // Stores a mapping of each call stack to the number of recorded allocations 83 // Stores a mapping of each call stack to the number of recorded allocations
71 // made from that call site. 84 // made from that call site.
72 base::hash_map<const CallStack*, 85 base::hash_map<const CallStack*,
73 uint32_t, 86 CallStackCountInfo,
74 StoredHash, 87 StoredHash,
75 std::equal_to<const CallStack*>, 88 std::equal_to<const CallStack*>,
76 TableEntryAllocator> entry_map_; 89 TableEntryAllocator> entry_map_;
77 90
78 // For detecting leak patterns in incoming allocations. 91 // For detecting leak patterns in incoming allocations.
79 LeakAnalyzer leak_analyzer_; 92 LeakAnalyzer leak_analyzer_;
80 93
81 DISALLOW_COPY_AND_ASSIGN(CallStackTable); 94 DISALLOW_COPY_AND_ASSIGN(CallStackTable);
82 }; 95 };
83 96
84 } // namespace leak_detector 97 } // namespace leak_detector
85 } // namespace metrics 98 } // namespace metrics
86 99
87 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_ 100 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698