Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a43904b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Log debuggerd -j output when sampling memory use."

parents b29199a6 07456698
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -13,8 +13,7 @@ Running the test

You can manually run the test as follows:

  make tradefed-all system-memory-test SystemMemoryTestDevice
  tradefed.sh run commandAndExit template/local_min --template:map test=system-memory-test
  atest -v system-memory-test

This installs and runs the test on device. You can see the metrics in the
tradefed output.
+18 −7
Original line number Diff line number Diff line
@@ -65,6 +65,18 @@ class Metrics {
        this.logs = logs;
    }

    /**
     * Writes the given <code>text</code> to a log with the given label.
     */
    private void logText(String label, String text) throws IOException {
      File file = File.createTempFile(label, "txt");
      PrintStream ps = new PrintStream(file);
      ps.print(text);
      try (FileInputStreamSource dataStream = new FileInputStreamSource(file)) {
        logs.addTestLog(label, LogDataType.TEXT, dataStream);
      }
    }

    /**
     * Returns the pid for the process with the given name.
     */
@@ -111,13 +123,7 @@ class Metrics {

        // Read showmap for system server and add it as a test log
        String showmap = device.executeShellCommand("showmap " + pid);
        String showmapLabel = label + ".system_server.showmap";
        File file = File.createTempFile(showmapLabel, "txt");
        PrintStream ps = new PrintStream(file);
        ps.print(showmap);
        try (FileInputStreamSource dataStream = new FileInputStreamSource(file)) {
            logs.addTestLog(showmapLabel, LogDataType.TEXT, dataStream);
        }
        logText(label + ".system_server.showmap", showmap);

        // Extract VSS, PSS and RSS from the showmap and output them as metrics.
        // The last lines of the showmap output looks something like:
@@ -140,6 +146,11 @@ class Metrics {
            throw new MetricsException("unexpected showmap format", e);
        }

        // Run debuggerd -j to get GC stats for system server and add it as a
        // test log
        String debuggerd = device.executeShellCommand("debuggerd -j " + pid);
        logText(label + ".system_server.debuggerd", debuggerd);

        // TODO: Experiment with other additional metrics.

        // TODO: Consider launching an instrumentation to collect metrics from