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

Commit 53d89b21 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

[res] Dump resources timings in dumpsys

ResourceTimer collects the timings for resource getters, and
we should dump those in the same bugreport section as the
resources history, as it's just a few lines that would add
quite a bit of insight on how device was performing

+ a bit of improvements in the dumping function

Bug: 319137634
Test: manual 'dumpsys resources'
Flag: EXEMPT bugfix
Change-Id: I5fa70d3326038a236c655d762447a9ab13dee8ae
parent 2f271fe4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ import android.content.pm.ServiceInfo;
import android.content.res.AssetManager;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.ResourceTimer;
import android.content.res.Resources;
import android.content.res.ResourcesImpl;
import android.content.res.loader.ResourcesLoader;
@@ -5253,6 +5254,7 @@ public final class ActivityThread extends ClientTransactionHandler

            Resources.dumpHistory(pw, "");
            pw.flush();
            ResourceTimer.dumpTimers(info.fd.getFileDescriptor(), "-refresh");
            if (info.finishCallback != null) {
                info.finishCallback.sendResult(null);
            }
+28 −28
Original line number Diff line number Diff line
@@ -17,13 +17,10 @@
package android.content.res;

import android.annotation.NonNull;
import android.annotation.Nullable;

import android.app.AppProtoEnums;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.SystemClock;
import android.text.TextUtils;
@@ -33,6 +30,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.FrameworkStatsLog;

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
@@ -277,16 +275,18 @@ public final class ResourceTimer {
     * Update the metrics information and dump it.
     * @hide
     */
    public static void dumpTimers(@NonNull ParcelFileDescriptor pfd, @Nullable String[] args) {
        FileOutputStream fout = new FileOutputStream(pfd.getFileDescriptor());
        PrintWriter pw = new FastPrintWriter(fout);
    public static void dumpTimers(@NonNull FileDescriptor fd, String... args) {
        try (PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd))) {
            pw.println("\nDumping ResourceTimers");

            final boolean enabled;
            synchronized (sLock) {
            if (!sEnabled || (sConfig == null)) {
                enabled = sEnabled && sConfig != null;
            }
            if (!enabled) {
                pw.println("  Timers are not enabled in this process");
                pw.flush();
                return;
            }
        }

            // Look for the --refresh switch.  If the switch is present, then sTimers is updated.
            // Otherwise, the current value of sTimers is displayed.
@@ -308,7 +308,7 @@ public final class ResourceTimer {
                    }
                }
            }
        pw.flush();
        }
    }

    // Enable (or disabled) the runtime timers.  Note that timers are disabled by default.  This
+0 −1
Original line number Diff line number Diff line
@@ -88,6 +88,5 @@ public class ResourcesManagerShellCommand extends ShellCommand {
        out.println("    Print this help text.");
        out.println("  dump <PROCESS>");
        out.println("    Dump the Resources objects in use as well as the history of Resources");

    }
}