/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License")= ;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

import "protos/perfetto/metrics/android/process_metadata.proto";

message AndroidGarbageCollectionStats {
  message ProcessStats {
    // The process the stats are associated with.
    optional AndroidProcessMetadata process = 1;
    // Megabyte-seconds of heap size across the device, used in the calculation
    // of heap_size_mb.
    optional double heap_size_mbs = 2;
    // Total size of heap allocations across the device on average, in MB.
    optional double heap_size_mb = 3;
    // Total number of bytes allocated over the course of the trace.
    optional double heap_allocated_mb = 4;
    // Overall rate of heap allocations in MB per second. This gives a sense of
    // how much allocation activity is going on during the trace.
    optional double heap_allocation_rate = 5;
    // Megabyte-seconds of live heap for processes that had GC events.
    optional double heap_live_mbs = 6;
    // Megabyte-seconds of total heap for processes that had GC events.
    optional double heap_total_mbs = 7;
    // Overall heap utilization. This gives a sense of how aggressive GC is
    // during this trace.
    optional double heap_utilization = 8;
    // CPU time spent running GC. Used in the calculation of gc_running_rate.
    optional int64 gc_running_dur = 9;
    // CPU time spent running GC, as a fraction of the duration of the trace.
    // This gives a sense of the battery cost of GC.
    optional double gc_running_rate = 10;
    // A measure of how efficient GC is with respect to cpu, independent of how
    // aggressively GC is tuned. Larger values indicate more efficient GC, so
    // larger is better.
    optional double gc_running_efficiency = 11;
    // Time GC is running during app startup. Used in the calculation of
    // gc_during_android_startup_rate.
    optional int64 gc_during_android_startup_dur = 12;
    // Time GC is running during app startup, as a fraction of startup time in
    // the trace. This gives a sense of how much potential interference there
    // is between GC and application startup.
    optional double gc_during_android_startup_rate = 13;
    // A measure of how efficient GC is with regards to gc during application
    // startup, independent of how aggressively GC is tuned. Larger values
    // indicate more efficient GC, so larger is better.
    optional double gc_during_android_startup_efficiency = 14;
  }

  // The start of the window of time that the stats cover in the trace.
  optional int64 ts = 1;
  // The duration of the window of time that the stats cover in the trace.
  optional int64 dur = 2;
  // Megabyte-seconds of heap size across the device, used in the calculation
  // of heap_size_mb.
  optional double heap_size_mbs = 3;
  // Total size of heap allocations across the device on average, in MB.
  optional double heap_size_mb = 4;
  // Total number of bytes allocated over the course of the trace.
  optional double heap_allocated_mb = 5;
  // Overall rate of heap allocations in MB per second. This gives a sense of
  // how much allocation activity is going on during the trace.
  optional double heap_allocation_rate = 6;
  // Megabyte-seconds of live heap for processes that had GC events.
  optional double heap_live_mbs = 7;
  // Megabyte-seconds of total heap for processes that had GC events.
  optional double heap_total_mbs = 8;
  // Overall heap utilization. This gives a sense of how aggressive GC is
  // during this trace.
  optional double heap_utilization = 9;
  // CPU time spent running GC. Used in the calculation of gc_running_rate.
  optional int64 gc_running_dur = 10;
  // CPU time spent running GC, as a fraction of the duration of the trace.
  // This gives a sense of the battery cost of GC.
  optional double gc_running_rate = 11;
  // A measure of how efficient GC is with respect to cpu, independent of how
  // aggressively GC is tuned. Larger values indicate more efficient GC, so
  // larger is better.
  optional double gc_running_efficiency = 12;
  // Time GC is running during app startup. Used in the calculation of
  // gc_during_android_startup_rate.
  optional int64 gc_during_android_startup_dur = 13;
  // Total startup time in the trace, used to normalize the
  // gc_during_android_startup_rate.
  optional int64 total_android_startup_dur = 14;
  // Time GC is running during app startup, as a fraction of startup time in
  // the trace. This gives a sense of how much potential interference there
  // is between GC and application startup.
  optional double gc_during_android_startup_rate = 15;
  // A measure of how efficient GC is with regards to gc during application
  // startup, independent of how aggressively GC is tuned. Larger values
  // indicate more efficient GC, so larger is better.
  optional double gc_during_android_startup_efficiency = 16;
  // Per-process stats.
  repeated ProcessStats processes = 17;
}
