Log debuggerd -j output when sampling memory use.

To get more logging around what GC has occurred over the course of the
test.

Test: atest -v system-memory-test
Bug: 111830582
Change-Id: I11827c78d73f3ddbf5e4e988c99abb96aebdc03a
This commit is contained in:
Richard Uhler
2018-09-06 13:31:10 +01:00
parent 1003f75bc4
commit 074566985d
2 changed files with 19 additions and 9 deletions

View File

@@ -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.

View File

@@ -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