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

Unified Diff: base/trace_event/memory_dump_scheduler.h

Issue 2737153002: [memory-infra] Implement peak detection logic (Closed)
Patch Set: nit. 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/memory_dump_scheduler.h
diff --git a/base/trace_event/memory_dump_scheduler.h b/base/trace_event/memory_dump_scheduler.h
index 2214e053b46a3c4e16541b8b0bb66ecf4f412719..b063734fce8afdee20aa4aad1668b3c2354e27f7 100644
--- a/base/trace_event/memory_dump_scheduler.h
+++ b/base/trace_event/memory_dump_scheduler.h
@@ -68,6 +68,8 @@ class BASE_EXPORT MemoryDumpScheduler {
};
struct PollingTriggerState {
+ static const uint32_t kNumTotalsTrackedForPeakDetection = 50;
+
explicit PollingTriggerState(
scoped_refptr<SingleThreadTaskRunner> polling_task_runner);
~PollingTriggerState();
@@ -85,6 +87,9 @@ class BASE_EXPORT MemoryDumpScheduler {
int num_polls_from_last_dump;
uint64_t last_dump_memory_total;
+ int64_t memory_increase_threshold;
+ uint64_t last_memory_totals_kb[kNumTotalsTrackedForPeakDetection];
+ uint32_t last_memory_totals_kb_index;
DISALLOW_COPY_AND_ASSIGN(PollingTriggerState);
};
@@ -101,6 +106,9 @@ class BASE_EXPORT MemoryDumpScheduler {
// Returns true if peak memory value is detected.
bool ShouldTriggerDump(uint64_t current_memory_total);
+ // Helper to detect peaks in memory usage.
+ bool IsCurrentSamplePeak(uint64_t current_memory_total);
+
// Must be set before enabling tracing.
static void SetPollingIntervalForTesting(uint32_t interval);

Powered by Google App Engine
This is Rietveld 408576698