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

Side by Side Diff: base/trace_event/memory_dump_scheduler.h

Issue 2737153002: [memory-infra] Implement peak detection logic (Closed)
Patch Set: fixes. Created 3 years, 9 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H
7 7
8 #include <deque>
9
8 #include "base/base_export.h" 10 #include "base/base_export.h"
9 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
12 #include "base/trace_event/memory_dump_request_args.h" 14 #include "base/trace_event/memory_dump_request_args.h"
13 15
14 namespace base { 16 namespace base {
15 class SingleThreadTaskRunner; 17 class SingleThreadTaskRunner;
16 18
17 namespace trace_event { 19 namespace trace_event {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 80
79 scoped_refptr<SingleThreadTaskRunner> polling_task_runner; 81 scoped_refptr<SingleThreadTaskRunner> polling_task_runner;
80 uint32_t polling_interval_ms; 82 uint32_t polling_interval_ms;
81 83
82 // Minimum numer of polls after the last dump at which next dump can be 84 // Minimum numer of polls after the last dump at which next dump can be
83 // triggered. 85 // triggered.
84 int min_polls_between_dumps; 86 int min_polls_between_dumps;
85 int num_polls_from_last_dump; 87 int num_polls_from_last_dump;
86 88
87 uint64_t last_dump_memory_total; 89 uint64_t last_dump_memory_total;
90 int64_t memory_increase_threshold;
91 std::deque<uint64_t> last_n_memory_totals;
Primiano Tucci (use gerrit) 2017/03/09 18:31:27 I'd drop the "_n" in the name
Primiano Tucci (use gerrit) 2017/03/09 18:31:27 also deque is super silly memory-wise, as dskiba f
ssid 2017/03/09 19:32:44 I didn't want to re-implement deque here and code
ssid 2017/03/09 19:32:44 Done.
88 92
89 DISALLOW_COPY_AND_ASSIGN(PollingTriggerState); 93 DISALLOW_COPY_AND_ASSIGN(PollingTriggerState);
90 }; 94 };
91 95
92 // Helper to set polling disabled on the polling thread. 96 // Helper to set polling disabled on the polling thread.
93 void DisablePolling(); 97 void DisablePolling();
94 98
95 // Periodically called by the timer. 99 // Periodically called by the timer.
96 void RequestPeriodicGlobalDump(); 100 void RequestPeriodicGlobalDump();
97 101
98 // Called for polling memory usage and trigger dumps if peak is detected. 102 // Called for polling memory usage and trigger dumps if peak is detected.
99 void PollMemoryOnPollingThread(); 103 void PollMemoryOnPollingThread();
100 104
101 // Returns true if peak memory value is detected. 105 // Returns true if peak memory value is detected.
102 bool ShouldTriggerDump(uint64_t current_memory_total); 106 bool ShouldTriggerDump(uint64_t current_memory_total);
103 107
108 // Helper to detect peaks in memory usage.
109 bool IsCurrentSamplePeak(uint64_t current_memory_total);
110
104 // Must be set before enabling tracing. 111 // Must be set before enabling tracing.
105 static void SetPollingIntervalForTesting(uint32_t interval); 112 static void SetPollingIntervalForTesting(uint32_t interval);
106 113
107 // True if periodic dumping is enabled. 114 // True if periodic dumping is enabled.
108 bool IsPeriodicTimerRunningForTesting(); 115 bool IsPeriodicTimerRunningForTesting();
109 116
110 MemoryDumpManager* mdm_; 117 MemoryDumpManager* mdm_;
111 118
112 PeriodicTriggerState periodic_state_; 119 PeriodicTriggerState periodic_state_;
113 PollingTriggerState polling_state_; 120 PollingTriggerState polling_state_;
114 121
122 // Total physical memory of the device.
123 size_t total_physical_memory_;
Primiano Tucci (use gerrit) 2017/03/09 18:31:27 I find this a bit of a misleading name, because I
ssid 2017/03/09 19:32:44 sorry, mistake. Removed this field.
124
115 DISALLOW_COPY_AND_ASSIGN(MemoryDumpScheduler); 125 DISALLOW_COPY_AND_ASSIGN(MemoryDumpScheduler);
116 }; 126 };
117 127
118 } // namespace trace_event 128 } // namespace trace_event
119 } // namespace base 129 } // namespace base
120 130
121 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H 131 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_SCHEDULER_H
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_scheduler.cc » ('j') | base/trace_event/memory_dump_scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698