From 947922b0eca3aa9dbd4cc5687ad5fe6c504b2213 Mon Sep 17 00:00:00 2001 From: Kevin Jeon Date: Wed, 21 Sep 2022 00:29:18 +0000 Subject: Replace libmeminfo tools with bugreport_procdump This change replaces calls to showmap, procrank, and librank in dumpstate with a single call to bugreport_procdump, which collects the same information with less overhead. Over 3 trials on aosp_redfin-userdebug, the time spent collecting memory info during a bug report was reduced by ~88% (11.954s -> 1.393s). With a high outlier removed from the 'before' trials and a low outlier removed from the 'after' trials, the reduction in overall bug report time was measured at ~13.5% (50.639s -> 43.784s). Test: Checked that bug reports still contain the same information, and that showmap/procrank/librank sections are still parsed by ABT in the same way. Bug: 229147699 Change-Id: I724922d2c583f2d1b3a443f86d445e994260c1cd --- cmds/dumpstate/Android.bp | 1 + cmds/dumpstate/dumpstate.cpp | 17 ++--------------- cmds/dumpstate/dumpstate.h | 3 --- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/cmds/dumpstate/Android.bp b/cmds/dumpstate/Android.bp index a60972b722..a62bd01a5b 100644 --- a/cmds/dumpstate/Android.bp +++ b/cmds/dumpstate/Android.bp @@ -126,6 +126,7 @@ cc_binary { ], required: [ "atrace", + "bugreport_procdump", "dmabuf_dump", "ip", "iptables", diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 6e9747f4dd..c1ae5b451f 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -1600,7 +1600,8 @@ static Dumpstate::RunStatus dumpstate() { RunCommand("CPU INFO", {"top", "-b", "-n", "1", "-H", "-s", "6", "-o", "pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name"}); - RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(RunCommand, "PROCRANK", {"procrank"}, AS_ROOT_20); + RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(RunCommand, "BUGREPORT_PROCDUMP", {"bugreport_procdump"}, + CommandOptions::AS_ROOT); RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(DumpVisibleWindowViews); @@ -1617,9 +1618,6 @@ static Dumpstate::RunStatus dumpstate() { RunCommand("PROCESSES AND THREADS", {"ps", "-A", "-T", "-Z", "-O", "pri,nice,rtprio,sched,pcy,time"}); - RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(RunCommand, "LIBRANK", {"librank"}, - CommandOptions::AS_ROOT); - if (ds.dump_pool_) { WAIT_TASK_WITH_CONSENT_CHECK(std::move(dump_hals)); } else { @@ -1649,8 +1647,6 @@ static Dumpstate::RunStatus dumpstate() { RunCommand("LIST OF OPEN FILES", {"lsof"}, CommandOptions::AS_ROOT); - RUN_SLOW_FUNCTION_WITH_CONSENT_CHECK(for_each_pid, do_showmap, "SMAPS OF ALL PROCESSES"); - for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS"); for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)"); @@ -3891,15 +3887,6 @@ void do_dmesg() { return; } -void do_showmap(int pid, const char *name) { - char title[255]; - char arg[255]; - - snprintf(title, sizeof(title), "SHOW MAP %d (%s)", pid, name); - snprintf(arg, sizeof(arg), "%d", pid); - RunCommand(title, {"showmap", "-q", arg}, CommandOptions::AS_ROOT); -} - int Dumpstate::DumpFile(const std::string& title, const std::string& path) { DurationReporter duration_reporter(title); diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index ee6b1aee18..66f84cb1c1 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -619,9 +619,6 @@ void show_wchan(int pid, int tid, const char *name); /* Displays a processes times */ void show_showtime(int pid, const char *name); -/* Runs "showmap" for a process */ -void do_showmap(int pid, const char *name); - /* Gets the dmesg output for the kernel */ void do_dmesg(); -- cgit v1.2.3-59-g8ed1b