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

Side by Side Diff: systrace/atrace_helper/jni/atrace_process_dump.h

Issue 2946033002: Android systrace: Optimize memory dumps. (Closed)
Patch Set: tiny fix Created 3 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ATRACE_PROCESS_DUMP_H_
6 #define ATRACE_PROCESS_DUMP_H_
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 #include <memory>
13 #include <set>
14 #include <string>
15
16 #include "logging.h"
17 #include "process_info.h"
18 #include "time_utils.h"
19
20 // Program that collects processes, thread names, per-process memory stats and
21 // other minor metrics from /proc filesystem. It's aimed to extend systrace
22 // with more actionable number to hit performance issues.
23 class AtraceProcessDump {
24 public:
25 enum FullDumpMode {
26 kDisabled,
27 kAllProcesses,
28 kAllJavaApps,
29 kOnlyWhitelisted,
30 };
31
32 AtraceProcessDump();
33 ~AtraceProcessDump();
34
35 void RunAndPrintJson(FILE* stream);
36 void Stop();
37
38 void set_dump_count(int count) { dump_count_ = count; }
39 void set_dump_interval(int interval_ms) {
40 dump_timer_ = std::unique_ptr<time_utils::PeriodicTimer>(
41 new time_utils::PeriodicTimer(interval_ms));
42 }
43 void set_full_dump_mode(FullDumpMode mode) { full_dump_mode_ = mode; }
44 void set_full_dump_whitelist(const std::set<std::string> &whitelist) {
45 CHECK(full_dump_mode_ == FullDumpMode::kOnlyWhitelisted);
46 full_dump_whitelist_ = whitelist;
47 }
48 void enable_graphics_stats() { graphics_stats_ = true; }
49 void enable_print_smaps() { print_smaps_ = true; }
50
51 private:
52 AtraceProcessDump(const AtraceProcessDump&) = delete;
53 void operator=(const AtraceProcessDump&) = delete;
54
55 using ProcessMap = std::map<int, std::unique_ptr<ProcessInfo>>;
56 using ProcessSnapshotMap = std::map<int, std::unique_ptr<ProcessSnapshot>>;
57
58 void TakeGlobalSnapshot();
59 bool UpdatePersistentProcessInfo(int pid);
60 bool ShouldTakeFullDump(const ProcessInfo* process);
61 void SerializeSnapshot();
62 void SerializePersistentProcessInfo();
63 void Cleanup();
64
65 int self_pid_;
66 int dump_count_;
67 bool graphics_stats_ = false;
68 bool print_smaps_ = false;
69 FullDumpMode full_dump_mode_ = FullDumpMode::kDisabled;
70 std::set<std::string> full_dump_whitelist_;
71
72 FILE* out_;
73 ProcessMap processes_;
74 ProcessSnapshotMap snapshot_;
75 uint64_t snapshot_timestamp_;
76 std::set<int> full_dump_whitelisted_pids_;
77 std::unique_ptr<time_utils::PeriodicTimer> dump_timer_;
78 };
79
80 #endif // ATRACE_PROCESS_DUMP_H_
OLDNEW
« 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