# texproto can be directly copied from https://ui.perfetto.dev/#!/record?p=instructions
# under the "recording command' settings.
buffers {
  size_kb: 512
  fill_policy: RING_BUFFER
}
buffers {
  size_kb: 4096
  fill_policy: RING_BUFFER
}
buffers {
  size_kb: 65536
  fill_policy: RING_BUFFER
}
buffers {
  size_kb: 512
  fill_policy: RING_BUFFER
}
buffers {
  size_kb: 40960
  fill_policy: RING_BUFFER
}
# Buffer dedicated for linux.ftrace. It's OK that the trace data is
# overwritten. If there are ftrace events that are of interest, use
# another dedicated buffer or increase this the size of this buffer.
buffers {
  size_kb: 40960
  fill_policy: RING_BUFFER
}
# Buffer dedicated for input events.
buffers {
  size_kb: 40960
  fill_policy: RING_BUFFER
}
data_sources {
  config {
    name: "android.packages_list"
    target_buffer: 0
  }
}
data_sources: {
  config {
    name: "linux.process_stats"
    target_buffer: 1
    process_stats_config {
      scan_all_processes_on_start: true
      proc_stats_poll_ms: 1000
    }
  }
}
data_sources {
  config {
    name: "linux.system_info"
    target_buffer: 0
  }
}
data_sources: {
  config {
    name: "linux.sys_stats"
    target_buffer: 2
    sys_stats_config {
      meminfo_period_ms: 1000
      cpufreq_period_ms: 1000
      cpuidle_period_ms: 1000
      thermal_period_ms: 1000
      diskstat_period_ms: 2000
      psi_period_ms: 2000
      stat_period_ms: 1000
      stat_counters: STAT_CPU_TIMES
      stat_counters: STAT_FORK_COUNT
      vmstat_period_ms: 1000
      vmstat_counters: VMSTAT_PGFAULT
      vmstat_counters: VMSTAT_PGPGIN
      vmstat_counters: VMSTAT_PGPGOUT
      vmstat_counters: VMSTAT_PSWPIN
      vmstat_counters: VMSTAT_PSWPOUT
    }
  }
}
data_sources: {
  config {
    name: "linux.sysfs_power"
    target_buffer: 2
  }
}
data_sources: {
  config {
    name: "android.power"
    target_buffer: 2
    android_power_config {
      battery_counters: BATTERY_COUNTER_CAPACITY_PERCENT
      battery_counters: BATTERY_COUNTER_CHARGE
      battery_counters: BATTERY_COUNTER_CURRENT
      battery_counters: BATTERY_COUNTER_CURRENT_AVG
      battery_counters: BATTERY_COUNTER_VOLTAGE
      collect_power_rails: true
    }
  }
}
# TODO(b/389552028): Remove the hardcoded event configs once dynamic resolution is implemented.
data_sources: {
  config {
    name: "linux.perf"
    target_buffer: 2
    perf_event_config {
      target_cpu: 0
      timebase {
        poll_period_ms: 1000
        name: "msr/tsc/"
        raw_event: {
          type: 14
          config: 0
        }
      }
      followers {
        name: "cstate_pkg/c2-residency/"
        raw_event: {
          type: 27
          config: 0
        }
      }
      followers {
        name: "cstate_pkg/c3-residency/"
        raw_event: {
          type: 27
          config: 1
        }
      }
      followers {
        name: "cstate_pkg/c6-residency/"
        raw_event: {
          type: 27
          config: 2
        }
      }
      followers {
        name: "cstate_pkg/c8-residency/"
        raw_event: {
          type: 27
          config: 4
        }
      }
      followers {
        name: "cstate_pkg/c10-residency/"
        raw_event: {
          type: 27
          config: 6
        }
      }
    }
  }
}
data_sources: {
  config {
    name: "android.statsd"
    target_buffer: 3
    statsd_tracing_config {
      push_atom_id: ATOM_APP_COMPACTED_V2
      push_atom_id: ATOM_LMK_KILL_OCCURRED
      push_atom_id: ATOM_LOW_MEM_REPORTED
      push_atom_id: ATOM_PACKAGE_INSTALLER_V2_REPORTED
      push_atom_id: ATOM_PROCESS_LIFE_CYCLE_STATE_CHANGED
      push_atom_id: ATOM_SLOW_INPUT_EVENT_REPORTED
      push_atom_id: ATOM_SLOW_IO
      raw_push_atom_id: 210803
      pull_config {
        pull_atom_id: ATOM_PROCESS_CPU_TIME
        pull_frequency_ms: 500
      }
    }
  }
}
data_sources: {
  config {
    name: "android.surfaceflinger.frametimeline"
    target_buffer: 4
  }
}
data_sources: {
  config {
    name: "org.chromium.trace_metadata2"
    target_buffer: 4
  }
}
data_sources: {
  config {
    name: "linux.ftrace"
    target_buffer: 5
    ftrace_config {
      ftrace_events: "mm_event/mm_event_record"
      ftrace_events: "kmem/rss_stat"
      throttle_rss_stat: true
      ftrace_events: "ion/ion_stat"
      ftrace_events: "dmabuf_heap/dma_heap_stat"
      ftrace_events: "kmem/ion_heap_grow"
      ftrace_events: "kmem/ion_heap_shrink"
      ftrace_events: "sched/sched_process_exit"
      ftrace_events: "sched/sched_process_free"
      ftrace_events: "sched/sched_switch"
      ftrace_events: "task/task_newtask"
      ftrace_events: "task/task_rename"
      ftrace_events: "lowmemorykiller/lowmemory_kill"
      ftrace_events: "gpu_mem/gpu_mem_total"
      ftrace_events: "oom/oom_score_adj_update"
      ftrace_events: "ftrace/print"
      atrace_apps: "lmkd"
      atrace_apps: "com.android.vending"
      atrace_categories: "am"
      atrace_categories: "wm"
    }
  }
}
data_sources: {
  config {
    name: "track_event"
    target_buffer: 4
    chrome_config {
      trace_config: "{\"record_mode\":\"record-until-full\",\"included_categories\":[\"blink.user_timing\"],\"excluded_categories\":[\"*\"],\"memory_dump_config\":{}}"
      privacy_filtering_enabled: false
      client_priority: USER_INITIATED
    }
    track_event_config {
      disabled_categories: "*"
      enabled_categories: "blink.user_timing"
      enabled_categories: "input"
      enabled_categories: "loading"
      enabled_categories: "__metadata"
      timestamp_unit_multiplier: 1000
      filter_debug_annotations: false
      enable_thread_time_sampling: true
      filter_dynamic_event_names: false
    }
  }
}
data_sources: {
  config {
    name: "org.chromium.histogram_sample"
    target_buffer: 4
    chromium_histogram_samples {
      histograms {
        histogram_name: "Browser.MainThreadsCongestion"
      }
      histograms {
        histogram_name: "Browser.MainThreadsCongestion.RunningOnly"
      }
      histograms {
        histogram_name: "Browser.Tabs.TabSwitchResult3.NoSavedFrames_Loaded"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalIncompleteSwitchDuration3"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalIncompleteSwitchDuration3.NoSavedFrames_Loaded"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalIncompleteSwitchDuration3.NoSavedFrames_NotLoaded"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalSwitchDuration3"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalSwitchDuration3.NoSavedFrames_Loaded"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalSwitchDuration3.NoSavedFrames_NotLoaded"
      }
      histograms {
        histogram_name: "Browser.Tabs.TotalSwitchDuration3.WithSavedFrames"
      }
      histograms {
        histogram_name: "Compositing.Display.PendingSwaps"
      }
      histograms {
        histogram_name: "Compositing.Display.OverlayProcessorUsingStrategy.NumOverlaysPromoted"
      }
      histograms {
        histogram_name: "EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.KeyPressed.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.MouseDragged.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.MouseMoved.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.MousePressed.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.MouseReleased.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.MouseWheel.TotalLatency"
      }
      histograms {
        histogram_name: "EventLatency.TotalLatency"
      }
      histograms {
        histogram_name: "Event.ScrollJank.DelayedFramesPercentage.FixedWindow"
      }
      histograms {
        histogram_name: "Graphics.Smoothness.Jank3.AllSequences"
      }
      histograms {
        histogram_name: "Graphics.Smoothness.PercentDroppedFrames3.AllInteractions"
      }
      histograms {
        histogram_name: "Graphics.Smoothness.PercentDroppedFrames3.AllSequences"
      }
      histograms {
        histogram_name: "Memory.Browser.PrivateMemoryFootprint"
      }
      histograms {
        histogram_name: "Memory.PartitionAlloc.MemoryReclaim"
      }
      histograms {
        histogram_name: "PageLoad.Experimental.NavigationTiming.NavigationStartToFirstResponseStart"
      }
      histograms {
        histogram_name: "PageLoad.InteractiveTiming.InputDelay3"
      }
      histograms {
        histogram_name: "PageLoad.InteractiveTiming.TimeToNextPaint"
      }
      histograms {
        histogram_name: "PageLoad.PaintTiming.NavigationToFirstContentfulPaint"
      }
      histograms {
        histogram_name: "PageLoad.PaintTiming.NavigationToLargestContentfulPaint2"
      }
      histograms {
        histogram_name: "Startup.FirstWebContents.NonEmptyPaint3"
      }
      histograms {
        histogram_name: "Startup.Android.Cold.TimeToFirstVisibleContent4"
      }
      histograms {
        histogram_name: "Viz.FrameSink.GpuBusyDuration"
      }
      histograms {
        histogram_name: "Viz.DisplayCompositor.OverlayStrategy"
      }
      histograms {
        histogram_name: "WebVitals.FirstContentfulPaint3"
      }
      histograms {
        histogram_name: "WebVitals.InteractionToNextPaint2"
      }
      histograms {
        histogram_name: "Browser.Tabs.TabSwitchResult3"
      }
      histograms {
        histogram_name: "Browser.Tabs.TabSwitchResult3.NoSavedFrames_NotLoaded"
      }
      histograms {
        histogram_name: "Browser.Tabs.TabSwitchResult3.WithSavedFrames"
      }
      histograms {
        histogram_name: "WebRTC.Video.DroppedFrames.Capturer"
      }
      histograms {
        histogram_name: "WebRTC.Video.DroppedFrames.Encoder"
      }
      histograms {
        histogram_name: "WebRTC.Video.DroppedFrames.Receiver"
      }
    }
  }
}
data_sources: {
  config {
    name: "android.input.inputevent"
    target_buffer: 6
    android_input_event_config {
      mode: TRACE_MODE_TRACE_ALL
    }
  }
}

# Buffer for extra high-overhead but lossy Chrome trace categories.
buffers {
  # Buffer id: 7
  size_kb: 20480
  fill_policy: RING_BUFFER
}
data_sources: {
  config {
    name: "track_event"
    target_buffer: 7
    track_event_config {
      disabled_categories: "*"
      enabled_categories: "toplevel"
      enabled_categories: "__metadata"
      timestamp_unit_multiplier: 1000
    }
  }
}

write_into_file: true
file_write_period_ms: 5000
max_file_size_bytes: 1073741824
flush_period_ms: 30000
