Short-circuit when the process is not profiled based on the config
If the process undergoing OOME is not part of the DS config, no reason
to wait.
Test: manual, atest
Bug: 263023736
Change-Id: Ia078faf4e5a1e9d60c191a26dd5e3e74faeb366a
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc
index feee29f..45ce651 100644
--- a/perfetto_hprof/perfetto_hprof.cc
+++ b/perfetto_hprof/perfetto_hprof.cc
@@ -201,14 +201,15 @@
}
bool dump_smaps() { return dump_smaps_; }
+
+ // Per-DS enable bit. Invoked by the ::Trace method.
bool enabled() { return enabled_; }
void OnStart(const StartArgs&) override {
- if (!enabled()) {
- return;
- }
art::MutexLock lk(art_thread(), GetStateMutex());
if (g_state == State::kWaitForStart) {
+ // WriteHeapPackets is responsible for checking whether the DS is actually
+ // enabled.
g_state = State::kStart;
GetStateCV().Broadcast(art_thread());
}
@@ -917,7 +918,7 @@
const std::function<void(pid_t child)>& parent_runnable,
const std::function<void(pid_t parent, uint64_t timestamp)>& child_runnable) {
pid_t parent_pid = getpid();
- LOG(INFO) << "preparing to dump heap for " << parent_pid;
+ LOG(INFO) << "forking for " << parent_pid;
// Need to take a heap dump while GC isn't running. See the comment in
// Heap::VisitObjects(). Also we need the critical section to avoid visiting
// the same object twice. See b/34967844.
@@ -1100,11 +1101,11 @@
// A pre-armed tracing session might not exist, so we should wait for a
// limited amount of time before we decide to let the execution continue.
if (!TimedWaitForDataSource(self, 500)) {
- LOG(INFO) << "timeout waiting for data source start (no active session?)";
+ LOG(INFO) << "OOME hprof timeout (state " << g_state << ")";
return;
}
WriteHeapPackets(dumped_pid, timestamp);
- LOG(INFO) << "finished dumping heap for OOME " << dumped_pid;
+ LOG(INFO) << "OOME hprof complete for " << dumped_pid;
});
}