summaryrefslogtreecommitdiff
path: root/perfetto_hprof
diff options
context:
space:
mode:
author Ioannis Ilkos <ilkos@google.com> 2023-02-13 13:20:29 +0000
committer Ioannis Ilkos <ilkos@google.com> 2023-02-14 13:32:12 +0000
commited98175c8b944229d3ecc1bbdb8ffdfc2d79c3a5 (patch)
tree9653b4c3483f3bca3ec0d305314c636d12ce0e4a /perfetto_hprof
parent9b5c8c1cb8982465515f81ddcc3f1fe4ef918865 (diff)
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
Diffstat (limited to 'perfetto_hprof')
-rw-r--r--perfetto_hprof/perfetto_hprof.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc
index feee29f22b..45ce651553 100644
--- a/perfetto_hprof/perfetto_hprof.cc
+++ b/perfetto_hprof/perfetto_hprof.cc
@@ -201,14 +201,15 @@ class JavaHprofDataSource : public perfetto::DataSource<JavaHprofDataSource> {
}
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 @@ void ForkAndRun(art::Thread* self,
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 @@ void DumpPerfettoOutOfMemory() REQUIRES_SHARED(art::Locks::mutator_lock_) {
// 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;
});
}