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

Commit d5f053ed authored by Jeffrey Huang's avatar Jeffrey Huang
Browse files

Migrate pullCpuTimePerUid

Test: atest UidAtomTests#testCpuPerUid
Test: adb shell cmd stats pull-source 10009
Change-Id: I791c5d2320fdc843caeac8e32ed5011a0efda893
parent 43d5e2d1
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -761,19 +761,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        }
    }

    private void pullKernelUidCpuTime(
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
        mCpuUidUserSysTimeReader.readAbsolute((uid, timesUs) -> {
            long userTimeUs = timesUs[0], systemTimeUs = timesUs[1];
            StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
            e.writeInt(uid);
            e.writeLong(userTimeUs);
            e.writeLong(systemTimeUs);
            pulledData.add(e);
        });
    }

    private void pullKernelUidCpuFreqTime(
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
@@ -2110,11 +2097,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                break;
            }

            case StatsLog.CPU_TIME_PER_UID: {
                pullKernelUidCpuTime(tagId, elapsedNanos, wallClockNanos, ret);
                break;
            }

            case StatsLog.CPU_TIME_PER_UID_FREQ: {
                pullKernelUidCpuFreqTime(tagId, elapsedNanos, wallClockNanos, ret);
                break;
+0 −5
Original line number Diff line number Diff line
@@ -72,11 +72,6 @@ std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
        {{.atomTag = android::util::ON_DEVICE_POWER_MEASUREMENT},
         {.puller = new PowerStatsPuller()}},

        // cpu_time_per_uid
        {{.atomTag = android::util::CPU_TIME_PER_UID},
         {.additiveFields = {2, 3},
          .puller = new StatsCompanionServicePuller(android::util::CPU_TIME_PER_UID)}},

        // cpu_time_per_uid_freq
        // the throttling is 3sec, handled in
        // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
+25 −3
Original line number Diff line number Diff line
@@ -631,6 +631,9 @@ public class StatsPullAtomService extends SystemService {
    }

    private KernelCpuSpeedReader[] mKernelCpuSpeedReaders;
    // Disables throttler on CPU time readers.
    private KernelCpuUidUserSysTimeReader mCpuUidUserSysTimeReader =
            new KernelCpuUidUserSysTimeReader(false);

    private void registerCpuTimePerFreq() {
        int tagId = StatsLog.CPU_TIME_PER_FREQ;
@@ -664,11 +667,30 @@ public class StatsPullAtomService extends SystemService {
    }

    private void registerCpuTimePerUid() {
        // No op.
        int tagId = StatsLog.CPU_TIME_PER_UID;
        PullAtomMetadata metadata = PullAtomMetadata.newBuilder()
                .setAdditiveFields(new int[] {2, 3})
                .build();
        mStatsManager.registerPullAtomCallback(
                tagId,
                metadata,
                (atomTag, data) -> pullCpuTimePerUid(atomTag, data),
                Executors.newSingleThreadExecutor()
        );
    }

    private void pullCpuTimePerUid() {
        // No op.
    private int pullCpuTimePerUid(int atomTag, List<StatsEvent> pulledData) {
        mCpuUidUserSysTimeReader.readAbsolute((uid, timesUs) -> {
            long userTimeUs = timesUs[0], systemTimeUs = timesUs[1];
            StatsEvent e = StatsEvent.newBuilder()
                    .setAtomId(atomTag)
                    .writeInt(uid)
                    .writeLong(userTimeUs)
                    .writeLong(systemTimeUs)
                    .build();
            pulledData.add(e);
        });
        return StatsManager.PULL_SUCCESS;
    }

    private void registerCpuTimePerUidFreq() {