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

Commit a4734632 authored by Marcin Oczeretko's avatar Marcin Oczeretko Committed by Android (Google) Code Review
Browse files

Merge changes I327b971f,Ie35e1fe7 into sc-dev

* changes:
  Update AOT trigger names to match the new convention
  Limit PerfettoTrigger to max 1 trigger per minute
parents 44a417e0 794e034d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -499,7 +499,7 @@ public class InteractionJankMonitor {
        }

        public String getPerfettoTrigger() {
            return String.format("interaction-jank-monitor-%d", mCujType);
            return String.format("com.android.telemetry.interaction-jank-monitor-%d", mCujType);
        }

        public String getName() {
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class LatencyTracker {
    }

    private static String getTraceTriggerNameForAction(@Action int action) {
        return "latency-tracker-" + getNameOfAction(STATSD_ACTION[action]);
        return "com.android.telemetry.latency-tracker-" + getNameOfAction(STATSD_ACTION[action]);
    }

    public static boolean isEnabled(Context ctx) {
+14 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.util;

import android.os.SystemClock;
import android.util.Log;

import java.io.IOException;
@@ -27,16 +28,28 @@ import java.io.IOException;
public class PerfettoTrigger {
    private static final String TAG = "PerfettoTrigger";
    private static final String TRIGGER_COMMAND = "/system/bin/trigger_perfetto";
    private static final long THROTTLE_MILLIS = 60000;
    private static volatile long sLastTriggerTime = -THROTTLE_MILLIS;

    /**
     * @param triggerName The name of the trigger. Must match the value defined in the AOT
     *                    Perfetto config.
     */
    public static void trigger(String triggerName) {
        // Trace triggering has a non-negligible cost (fork+exec).
        // To mitigate potential excessive triggering by the API client we ignore calls that happen
        // too quickl after the most recent trigger.
        long sinceLastTrigger = SystemClock.elapsedRealtime() - sLastTriggerTime;
        if (sinceLastTrigger < THROTTLE_MILLIS) {
            Log.v(TAG, "Not triggering " + triggerName + " - not enough time since last trigger");
            return;
        }

        try {
            ProcessBuilder pb = new ProcessBuilder(TRIGGER_COMMAND, triggerName);
            Log.v(TAG, "Triggering " + String.join(" ", pb.command()));
            Process process = pb.start();
            pb.start();
            sLastTriggerTime = SystemClock.elapsedRealtime();
        } catch (IOException e) {
            Log.w(TAG, "Failed to trigger " + triggerName, e);
        }