Merge changes I56de3aec,Iba86e8e3

* changes:
  Change CpuTimePerThreadFreq to contain all frequencies in one atom
  Remove filtering out frequencies with zero usage for CpuTimePerThreadFreq
This commit is contained in:
Misha Wagner
2018-11-30 17:52:43 +00:00
committed by Android (Google) Code Review
3 changed files with 37 additions and 19 deletions

View File

@@ -3326,10 +3326,27 @@ message CpuTimePerThreadFreq {
optional string process_name = 4;
// Name of the thread taken from `/proc/$PID/task/$TID/comm`
optional string thread_name = 5;
// What frequency the CPU was running at, in KHz
optional int32 frequency_khz = 6;
// Time spent in frequency in milliseconds, since thread start.
optional int32 time_millis = 7;
// Report eight different frequencies, and how much time is spent in each frequency. Frequencies
// are given in KHz, and time is given in milliseconds since the thread started. All eight
// frequencies are given here as the alternative is sending eight separate atoms. This method
// significantly reduces the amount of data created
optional int32 frequency1_khz = 6;
optional int32 time1_millis = 7;
optional int32 frequency2_khz = 8;
optional int32 time2_millis = 9;
optional int32 frequency3_khz = 10;
optional int32 time3_millis = 11;
optional int32 frequency4_khz = 12;
optional int32 time4_millis = 13;
optional int32 frequency5_khz = 14;
optional int32 time5_millis = 15;
optional int32 frequency6_khz = 16;
optional int32 time6_millis = 17;
optional int32 frequency7_khz = 18;
optional int32 time7_millis = 19;
optional int32 frequency8_khz = 20;
optional int32 time8_millis = 21;
}
/**

View File

@@ -210,7 +210,7 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
5 * NS_PER_SEC /* min cool-down in seconds*/,
new StatsCompanionServicePuller(android::util::PROCESS_CPU_TIME)}},
{android::util::CPU_TIME_PER_THREAD_FREQ,
{{7},
{{7, 9, 11, 13, 15, 17, 19, 21},
1 * NS_PER_SEC,
new StatsCompanionServicePuller(android::util::CPU_TIME_PER_THREAD_FREQ)}},
// DeviceCalculatedPowerUse.

View File

@@ -201,6 +201,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
// "zygote64",
};
private static final int CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES = 8;
static final class CompanionHandler extends Handler {
CompanionHandler(Looper looper) {
@@ -1654,6 +1655,11 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
return;
}
int[] cpuFrequencies = mKernelCpuThreadReader.getCpuFrequenciesKhz();
if (cpuFrequencies.length != CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES) {
Slog.w(TAG, "Expected " + CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES
+ " frequencies, but got " + cpuFrequencies.length);
return;
}
for (int i = 0; i < processCpuUsages.size(); i++) {
KernelCpuThreadReader.ProcessCpuUsage processCpuUsage = processCpuUsages.get(i);
ArrayList<KernelCpuThreadReader.ThreadCpuUsage> threadCpuUsages =
@@ -1667,23 +1673,18 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
continue;
}
for (int k = 0; k < threadCpuUsage.usageTimesMillis.length; k++) {
// Do not report CPU usage at a frequency when it's zero
if (threadCpuUsage.usageTimesMillis[k] == 0) {
continue;
}
StatsLogEventWrapper e =
new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
e.writeInt(processCpuUsage.uid);
e.writeInt(processCpuUsage.processId);
e.writeInt(threadCpuUsage.threadId);
e.writeString(processCpuUsage.processName);
e.writeString(threadCpuUsage.threadName);
StatsLogEventWrapper e =
new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
e.writeInt(processCpuUsage.uid);
e.writeInt(processCpuUsage.processId);
e.writeInt(threadCpuUsage.threadId);
e.writeString(processCpuUsage.processName);
e.writeString(threadCpuUsage.threadName);
for (int k = 0; k < CPU_TIME_PER_THREAD_FREQ_NUM_FREQUENCIES; k++) {
e.writeInt(cpuFrequencies[k]);
e.writeInt(threadCpuUsage.usageTimesMillis[k]);
pulledData.add(e);
}
pulledData.add(e);
}
}
}