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

Unified Diff: systrace/atrace_helper/jni/atrace_process_dump.h

Issue 2946033002: Android systrace: Optimize memory dumps. (Closed)
Patch Set: tiny fix Created 3 years, 6 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 | « systrace/atrace_helper/jni/Android.mk ('k') | systrace/atrace_helper/jni/atrace_process_dump.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: systrace/atrace_helper/jni/atrace_process_dump.h
diff --git a/systrace/atrace_helper/jni/atrace_process_dump.h b/systrace/atrace_helper/jni/atrace_process_dump.h
new file mode 100644
index 0000000000000000000000000000000000000000..734587cc9954b07c16972e15233de1bd8ae8b357
--- /dev/null
+++ b/systrace/atrace_helper/jni/atrace_process_dump.h
@@ -0,0 +1,80 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATRACE_PROCESS_DUMP_H_
+#define ATRACE_PROCESS_DUMP_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <memory>
+#include <set>
+#include <string>
+
+#include "logging.h"
+#include "process_info.h"
+#include "time_utils.h"
+
+// Program that collects processes, thread names, per-process memory stats and
+// other minor metrics from /proc filesystem. It's aimed to extend systrace
+// with more actionable number to hit performance issues.
+class AtraceProcessDump {
+ public:
+ enum FullDumpMode {
+ kDisabled,
+ kAllProcesses,
+ kAllJavaApps,
+ kOnlyWhitelisted,
+ };
+
+ AtraceProcessDump();
+ ~AtraceProcessDump();
+
+ void RunAndPrintJson(FILE* stream);
+ void Stop();
+
+ void set_dump_count(int count) { dump_count_ = count; }
+ void set_dump_interval(int interval_ms) {
+ dump_timer_ = std::unique_ptr<time_utils::PeriodicTimer>(
+ new time_utils::PeriodicTimer(interval_ms));
+ }
+ void set_full_dump_mode(FullDumpMode mode) { full_dump_mode_ = mode; }
+ void set_full_dump_whitelist(const std::set<std::string> &whitelist) {
+ CHECK(full_dump_mode_ == FullDumpMode::kOnlyWhitelisted);
+ full_dump_whitelist_ = whitelist;
+ }
+ void enable_graphics_stats() { graphics_stats_ = true; }
+ void enable_print_smaps() { print_smaps_ = true; }
+
+ private:
+ AtraceProcessDump(const AtraceProcessDump&) = delete;
+ void operator=(const AtraceProcessDump&) = delete;
+
+ using ProcessMap = std::map<int, std::unique_ptr<ProcessInfo>>;
+ using ProcessSnapshotMap = std::map<int, std::unique_ptr<ProcessSnapshot>>;
+
+ void TakeGlobalSnapshot();
+ bool UpdatePersistentProcessInfo(int pid);
+ bool ShouldTakeFullDump(const ProcessInfo* process);
+ void SerializeSnapshot();
+ void SerializePersistentProcessInfo();
+ void Cleanup();
+
+ int self_pid_;
+ int dump_count_;
+ bool graphics_stats_ = false;
+ bool print_smaps_ = false;
+ FullDumpMode full_dump_mode_ = FullDumpMode::kDisabled;
+ std::set<std::string> full_dump_whitelist_;
+
+ FILE* out_;
+ ProcessMap processes_;
+ ProcessSnapshotMap snapshot_;
+ uint64_t snapshot_timestamp_;
+ std::set<int> full_dump_whitelisted_pids_;
+ std::unique_ptr<time_utils::PeriodicTimer> dump_timer_;
+};
+
+#endif // ATRACE_PROCESS_DUMP_H_
« no previous file with comments | « systrace/atrace_helper/jni/Android.mk ('k') | systrace/atrace_helper/jni/atrace_process_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698