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

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

Issue 2417403002: Revert of 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
« no previous file with comments | « no previous file | components/metrics/leak_detector/call_stack_table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 information about the last seen drop in the number of allocations
52 // and sets the |previous_count| for every stored call stack, both inside
53 // |entry_map_|. It should be called in the analysis phase, before the
54 // reports are generated, with |timestamp| describing current point in the
55 // timeline.
56 void UpdateLastDropInfo(size_t timestamp);
57
58 // Retrieves the change in timestamp and allocation count since the last
59 // observed drop in the number for allocations for the given call stack
60 // (or since the oldest kept record for the call stacks if there were no
61 // drops)
62 void GetLastUptrendInfo(
63 const CallStack* call_stack, size_t timestamp, size_t *timestamp_delta,
64 uint32_t *count_delta) const;
65
66 const LeakAnalyzer& leak_analyzer() const { return leak_analyzer_; } 51 const LeakAnalyzer& leak_analyzer() const { return leak_analyzer_; }
67 52
68 size_t size() const { return entry_map_.size(); } 53 size_t size() const { return entry_map_.size(); }
69 bool empty() const { return entry_map_.empty(); } 54 bool empty() const { return entry_map_.empty(); }
70 55
71 uint32_t num_allocs() const { return num_allocs_; } 56 uint32_t num_allocs() const { return num_allocs_; }
72 uint32_t num_frees() const { return num_frees_; } 57 uint32_t num_frees() const { return num_frees_; }
73 58
74 private: 59 private:
75 struct CallStackCountInfo {
76 uint32_t count, previous_count, last_drop_count;
77 size_t last_drop_timestamp;
78 CallStackCountInfo() : count(0), previous_count(0), last_drop_count(0),
79 last_drop_timestamp(0) {}
80 };
81
82 // Total number of allocs and frees in this table. 60 // Total number of allocs and frees in this table.
83 uint32_t num_allocs_; 61 uint32_t num_allocs_;
84 uint32_t num_frees_; 62 uint32_t num_frees_;
85 63
86 // Hash table containing entries. Uses CustomAllocator to avoid recursive 64 // Hash table containing entries. Uses CustomAllocator to avoid recursive
87 // malloc hook invocation when analyzing allocs and frees. 65 // malloc hook invocation when analyzing allocs and frees.
88 using TableEntryAllocator = 66 using TableEntryAllocator =
89 STLAllocator<std::pair<const CallStack* const, uint32_t>, 67 STLAllocator<std::pair<const CallStack* const, uint32_t>,
90 CustomAllocator>; 68 CustomAllocator>;
91 69
92 // Stores a mapping of each call stack to the number of recorded allocations 70 // Stores a mapping of each call stack to the number of recorded allocations
93 // made from that call site. 71 // made from that call site.
94 base::hash_map<const CallStack*, 72 base::hash_map<const CallStack*,
95 CallStackCountInfo, 73 uint32_t,
96 StoredHash, 74 StoredHash,
97 std::equal_to<const CallStack*>, 75 std::equal_to<const CallStack*>,
98 TableEntryAllocator> entry_map_; 76 TableEntryAllocator> entry_map_;
99 77
100 // For detecting leak patterns in incoming allocations. 78 // For detecting leak patterns in incoming allocations.
101 LeakAnalyzer leak_analyzer_; 79 LeakAnalyzer leak_analyzer_;
102 80
103 DISALLOW_COPY_AND_ASSIGN(CallStackTable); 81 DISALLOW_COPY_AND_ASSIGN(CallStackTable);
104 }; 82 };
105 83
106 } // namespace leak_detector 84 } // namespace leak_detector
107 } // namespace metrics 85 } // namespace metrics
108 86
109 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_ 87 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_CALL_STACK_TABLE_H_
OLDNEW
« no previous file with comments | « no previous file | components/metrics/leak_detector/call_stack_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698