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

Commit 95071588 authored by Ben Murdoch's avatar Ben Murdoch Committed by Android (Google) Code Review
Browse files

Merge "App Compaction: Add westworld atom & statsd logging."

parents 7af6d125 bab399f6
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ message Atom {
        DocsUIUserActionReported docs_ui_user_action_reported = 112;
        WifiEnabledStateChanged wifi_enabled_state_changed = 113;
        WifiRunningStateChanged wifi_running_state_changed = 114;
        AppCompacted app_compacted = 115;
    }

    // Pulled events will start at field 10000.
@@ -3649,3 +3650,65 @@ message DocsUIUserActionReported {
message DocsUIInvalidScopedAccessRequestReported {
    optional android.stats.docsui.InvalidScopedAccess type = 1;
}

/**
 * Logs when an app's memory is compacted.
 *
 * Logged from:
 *   frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
 */
message AppCompacted {
  // The pid of the process being compacted.
  optional int32 pid = 1;

  // The name of the process being compacted.
  optional string process_name = 2;

  // The type of compaction.
  enum Action {
    UNKNOWN = 0;
    SOME = 1;
    FULL = 2;
  }
  optional Action action = 3 [default = UNKNOWN];

  // Total RSS in kilobytes consumed by the process prior to compaction.
  optional int64 before_rss_total_kilobytes = 4;

  // File RSS in kilobytes consumed by the process prior to compaction.
  optional int64 before_rss_file_kilobytes = 5;

  // Anonymous RSS in kilobytes consumed by the process prior to compaction.
  optional int64 before_rss_anon_kilobytes = 6;

  // Swap in kilobytes consumed by the process prior to compaction.
  optional int64 before_swap_kilobytes = 7;

  // Total RSS in kilobytes consumed by the process after compaction.
  optional int64 after_rss_total_kilobytes = 8;

  // File RSS in kilobytes consumed by the process after compaction.
  optional int64 after_rss_file_kilobytes = 9;

  // Anonymous RSS in kilobytes consumed by the process after compaction.
  optional int64 after_rss_anon_kilobytes = 10;

  // Swap in kilobytes consumed by the process after compaction.
  optional int64 after_swap_kilobytes = 11;

  // The time taken to perform compaction in milliseconds.
  optional int64 time_to_compact_millis = 12;

  // The last compaction action performed for this app.
  optional Action last_action = 13;

  // The last time that compaction was attempted on this process in seconds
  // since boot.
  optional int64 last_compact_timestamp = 14;

  // The oom_adj at the time of compaction.
  optional int32 oom_adj = 15;

  // The process state at the time of compaction.
  optional android.app.ProcessStateEnum process_state = 16 [default = PROCESS_STATE_UNKNOWN];
}
+14 −3
Original line number Diff line number Diff line
@@ -2329,9 +2329,16 @@ public class ActivityManagerService extends IActivityManager.Stub
                    fos.close();
                    long[] rssAfter = Process.getRss(pid);
                    long end = SystemClock.uptimeMillis();
                    long time = end - start;
                    EventLog.writeEvent(EventLogTags.AM_COMPACT, pid, name, action,
                            rssBefore[0], rssBefore[1], rssBefore[2], rssBefore[3],
                            rssAfter[0], rssAfter[1], rssAfter[2], rssAfter[3], end-start);
                            rssAfter[0], rssAfter[1], rssAfter[2], rssAfter[3], time,
                            lastCompactAction, lastCompactTime, msg.arg1, msg.arg2);
                    StatsLog.write(StatsLog.APP_COMPACTED, pid, name, pendingAction,
                            rssBefore[0], rssBefore[1], rssBefore[2], rssBefore[3],
                            rssAfter[0], rssAfter[1], rssAfter[2], rssAfter[3], time,
                            lastCompactAction, lastCompactTime, msg.arg1,
                            ActivityManager.processStateAmToProto(msg.arg2));
                    synchronized(ActivityManagerService.this) {
                        proc.lastCompactTime = end;
                        proc.lastCompactAction = pendingAction;
@@ -17028,12 +17035,16 @@ public class ActivityManagerService extends IActivityManager.Stub
                     app.curAdj == ProcessList.HOME_APP_ADJ)) {
                    app.reqCompactAction = COMPACT_PROCESS_SOME;
                    mPendingCompactionProcesses.add(app);
                    mCompactionHandler.sendEmptyMessage(COMPACT_PROCESS_MSG);
                    mCompactionHandler.sendMessage(
                            mCompactionHandler.obtainMessage(
                                COMPACT_PROCESS_MSG, app.curAdj, app.setProcState));
                } else if (app.setAdj < ProcessList.CACHED_APP_MIN_ADJ &&
                           app.curAdj >= ProcessList.CACHED_APP_MIN_ADJ) {
                    app.reqCompactAction = COMPACT_PROCESS_FULL;
                    mPendingCompactionProcesses.add(app);
                    mCompactionHandler.sendEmptyMessage(COMPACT_PROCESS_MSG);
                    mCompactionHandler.sendMessage(
                            mCompactionHandler.obtainMessage(
                                COMPACT_PROCESS_MSG, app.curAdj, app.setProcState));
                }
            }
            ProcessList.setOomAdj(app.pid, app.uid, app.curAdj);
+1 −1
Original line number Diff line number Diff line
@@ -138,4 +138,4 @@ option java_package com.android.server.am
30061 am_remove_task (Task ID|1|5), (Stack ID|1|5)

# The task is being compacted
30063 am_compact (Pid|1|5),(Process Name|3),(Action|3),(BeforeRssTotal|2|2),(BeforeRssFile|2|2),(BeforeRssAnon|2|2),(BeforeRssSwap|2|2),(AfterRssTotal|2|2),(AfterRssFile|2|2),(AfterRssAnon|2|2),(AfterRssSwap|2|2),(Time|2|3)
 No newline at end of file
30063 am_compact (Pid|1|5),(Process Name|3),(Action|3),(BeforeRssTotal|2|2),(BeforeRssFile|2|2),(BeforeRssAnon|2|2),(BeforeRssSwap|2|2),(AfterRssTotal|2|2),(AfterRssFile|2|2),(AfterRssAnon|2|2),(AfterRssSwap|2|2),(Time|2|3),(LastAction|1|2),(LastActionTimestamp|2|3),(setAdj|1|2),(procState|1|2)