系統啟動時,監控計時器原生服務會記錄早期初始階段的 I/O 效能資料。原生服務會將收集到的效能資料傾印至錯誤報告。供應商可以透過 dumpsys 查詢原生服務,傾印收集到的資料,或啟動自訂收集工作階段進行偵錯。
資料收集頻率
成效資料的收集頻率會因建構類型而異。
- 在 userdebug 或 eng 建構版本中,系統啟動時,Watchdog 會每秒收集一次效能資料,啟動完成後則每分鐘收集一次。
- 在使用者建構版本中,Watchdog 會在系統啟動期間每 20 秒收集一次效能資料,並在啟動完成後每兩 (2) 分鐘收集一次。
資料收集事件
系統會在各種系統事件 (例如系統啟動、系統喚醒和使用者切換) 期間,以及過去 N 分鐘的視窗期間,執行以樣本為準的剖析作業。
- 產生錯誤報告前 N 分鐘的事件:在 30 分鐘的滾動時間範圍內產生。
- 開機時間事件:開機後產生。
- 使用者切換事件:使用者切換作業啟動後產生。
- 自訂收集事件:可指定輪詢週期、最長持續時間,以及依套件篩選。
匯出成效資料
擷取錯誤報告時,Watchdog 原生服務會將收集到的效能資料傾印至錯誤報告。供應商可透過下列 dumpsys 指令查詢原生服務,傾印收集到的效能資料。如要進一步瞭解這份報表,請參閱「瞭解成效資料報表」一節。
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default > /tmp/carwatchdog_dump.txt
收集效能資料以進行偵錯
供應商可使用 Watchdog 原生服務自訂收集效能資料,以利進行偵錯。舉例來說,如要瞭解應用程式或服務的 I/O 使用情形,供應商可以執行自訂效能資料收集作業,分析特定套件清單或整個系統的 I/O 使用情形。
開始自訂收藏工作階段
下方顯示啟動自訂效能資料收集工作階段的指令:
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --start_perf [--interval <seconds>] [--max_duration <seconds>] [--filter_packages <package_name>,<package_name>,...]
--start_perf
開始自訂效能資料收集工作階段。--interval <seconds>
指定剖析間隔。 預設間隔為 30 秒。--max_duration <seconds>
指定自訂效能資料收集工作階段的最長持續時間。如果未手動停止工作階段,系統會在經過這段時間後停止工作階段,並捨棄收集到的資料。預設最長時數為 30 分鐘。--filter_packages <package_name>,<package_name>...
指定要分析的套件名稱清單 (以逗號分隔)。如果提供這些資訊,系統只會收集這些套件的效能資料。否則,系統會收集所有套件的效能資料。
舉例來說,下列指令會啟動自訂效能資料收集作業,設定的剖析間隔為 10 秒,最長收集時間為 1 小時,並將剖析作業限制在 com.google.android.car.kitchensink
和 com.google.android.apps.maps
套件。
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --start_perf --interval 10 --max_duration 3600 --filter_packages com.google.android.car.kitchensink,com.google.android.apps.maps
停止並傾印自訂集合工作階段
記錄感興趣的應用程式或服務的 I/O 使用量後,供應商應停止自訂效能資料收集工作階段,以傾印收集到的資料。這個指令會停止收集自訂效能資料,並將收集到的資料傾印至 /tmp/carwatchdog_dump.txt
:
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --stop-perf > /tmp/carwatchdog_custom_dump.txt
Dumpsys 說明
如要取得 dumpsys 說明:
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --help
以 Proto 格式傾印
您也可以選擇以 proto 格式傾印 dumpsys 資料:
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --proto
瞭解成效資料報表
詳情請參閱下列範例成效資料報表:
adb shell dumpsys android.automotive.watchdog.ICarWatchdog/default --------------------------------- WatchdogPerfService report: --------------------------------- Boot-time collection information: ================================= Event polling interval: 1 second Wake-up collection information: =============================== Event polling interval: 1 second User-switch collection information: =================================== Event polling interval: 1 second Periodic collection information: ================================ Event polling interval: 60 seconds --------------------------------------------------------------------------- Boot-time performance report: ================================= No collection recorded --------------------------------------------------------------------------- Wake-up performance report: =========================== No collection recorded --------------------------------------------------------------------------- User-switch events performance report: ====================================== No collection recorded --------------------------------------------------------------------------- Last N minutes performance report: ====================================== Collection duration: 10800 seconds Number of collections: 181 Collection 0: <Mon Oct 2 18:36:06 2023 GMT> ============================================= Total CPU time (ms): 473210 Total CPU cycles: 39553152000 Total idle CPU time (ms)/percent: 435860 / 92.11% CPU I/O wait time (ms)/percent: 0 / 0.00% Number of context switches: 13723415093 Number of I/O blocked processes/percent: 0 / 0.00% Top N CPU Times: ---------------- Android User ID, Package Name, CPU Time (ms), Percentage of total CPU time, CPU Cycles Command, CPU Time (ms), Percentage of UID's CPU Time, CPU Cycles 10, com.google.android.carassistant, 13357, 2.82%, 16409088000 assistant:interactor, 13360, 100.02%, 16409088000 0, system, 9097, 1.92%, 9640512000 sensors@1.0-ser, 3790, 41.66%, 3773184000 system_server, 2760, 30.34%, 3135936000 com.android.car, 1150, 12.64%, 1099584000 binder:621_4, 1000, 10.99%, 1281024000 surfaceflinger, 230, 2.53%, 245376000 0, audioserver, 4383, 0.93%, 4597248000 Main, 2690, 61.37%, 2980416000 binder:916_2, 950, 21.67%, 925056000 audioserver, 720, 16.43%, 691776000 0, root, 4357, 0.92%, 3727872000 irq/311-iam2068, 2630, 60.36%, 2471616000 irq/26-90b6400., 370, 8.49%, 561024000 kworker/u16:4-bwmon_wq, 290, 6.66%, 48960000 kworker/u16:1-memlat_wq, 270, 6.20%, 0 ipcdaemon, 220, 5.05%, 218304000 10, com.google.android.apps.geo.automotive.adas, 1509, 0.32%, 1756416000 adas:publishing, 1490, 98.74%, 1735680000 as:clientparams, 10, 0.66%, 20736000 0, com.android.vending, 796, 0.17%, 765504000 android.vending, 790, 99.25%, 765504000 0, shared:com.google.uid.shared, 581, 0.12%, 481152000 google.android.gms, 340, 58.52%, 237312000 .gms.persistent, 190, 32.70%, 184512000 process.gservices, 50, 8.61%, 59328000 0, gps, 507, 0.11%, 659136000 binder:920_2, 500, 98.62%, 659136000 10, com.android.vending, 489, 0.10%, 372288000 android.vending, 480, 98.16%, 372288000 0, shared:android.uid.systemui, 438, 0.09%, 449856000 android.systemui, 440, 100.46%, 449856000 Top N Storage I/O Reads: ------------- Android User ID, Package Name, Foreground Bytes, Foreground Bytes %, Foreground Fsync, Foreground Fsync %, Background Bytes, Background Bytes %, Background Fsync, Background Fsync % 0, root, 56123392, 81.95%, 1, 100.00%, 0, 0.00%, 0, 0.00% 0, system, 12333056, 18.01%, 0, 0.00%, 0, 0.00%, 0, 0.00% Top N Storage I/O Writes: ------------------------- Android User ID, Package Name, Foreground Bytes, Foreground Bytes %, Foreground Fsync, Foreground Fsync %, Background Bytes, Background Bytes %, Background Fsync, Background Fsync % 0, com.android.vending, 0, 0.00%, 0, 0.00%, 520192, 46.35%, 20, 47.62% 10, com.android.vending, 0, 0.00%, 0, 0.00%, 520192, 46.35%, 20, 47.62% 10, shared:com.google.uid.shared, 0, 0.00%, 0, 0.00%, 45056, 4.01%, 0, 0.00% 0, shared:com.google.uid.shared, 0, 0.00%, 0, 0.00%, 36864, 3.28%, 2, 4.76% 0, logd, 24576, 40.00%, 0, 0.00%, 0, 0.00%, 0, 0.00% 0, root, 20480, 33.33%, 0, 0.00%, 0, 0.00%, 0, 0.00% 0, system, 16384, 26.67%, 0, 0.00%, 0, 0.00%, 0, 0.00% Top N I/O waiting UIDs: ----------------------- Android User ID, Package Name, Number of owned tasks waiting for I/O, Percentage of owned tasks waiting for I/O Command, Number of I/O waiting tasks, Percentage of UID's tasks waiting for I/O 0, root, 2, 0.39% dp_hdcp2p2, 1, 50.00% hdcp_2x, 1, 50.00% Top N major page faults: ------------------------ Android User ID, Package Name, Number of major page faults, Percentage of total major page faults Command, Number of major page faults, Percentage of UID's major page faults 0, com.android.vending, 104, 48.83% android.vending, 104, 100.00% 10, com.android.vending, 104, 48.83% android.vending, 104, 100.00% 0, shared:com.google.uid.shared, 4, 1.88% .gms.persistent, 4, 100.00% 10, shared:com.google.uid.shared, 1, 0.47% .gms.persistent, 1, 100.00% Number of major page faults since last collection: 213 Percentage of change in major page faults since last collection: 0.00%
擷取錯誤報告、執行不含任何引數的 Watchdog dumpsys 指令,或停止自訂收集工作階段時,Watchdog 原生服務會傾印類似上述報表的效能資料報表。
這份報告包含系統啟動期間收集的資料,以及報告產生前 N 分鐘的資料。
產品 | 說明 |
---|---|
開機時收集的資訊 | 提供有關啟動時間效能資料收集工作階段的資訊。 |
起床時間資訊 | 提供系統從暫停狀態喚醒時的喚醒效能資料收集工作階段相關資訊。 |
使用者切換收集資訊 | 在使用者切換時,提供使用者切換效能資料收集工作階段的相關資訊。 |
定期收集資訊 | 提供有關定期效能收集工作階段的資訊,該工作階段會在開機完成後啟動。 |
開機時間成效報表 | 內含系統啟動期間收集的效能資料。這項資料會保留在記憶體中,直到系統關機為止,因此所有報表都會傾印這項資料。 |
喚醒成效報表 | 包含喚醒期間收集的效能資料。這項資料會持續保留在記憶體中,直到系統關機為止,因此所有報表都會傾印這項資料。 |
使用者切換成效報表 | 包含使用者切換期間收集的效能資料。這類資料會保留在記憶體中,直到系統關機為止,因此所有報表都會傾印這類資料。 |
過去 N 分鐘的 I/O 效能報表 | 包含報表產生前 N 分鐘內,定期收集工作階段所收集的成效資料。 |
收集時間長度 | 收集效能資料的總時間長度。 |
收藏內容數量 | 單一報表中回報的集合總數。 |
報表中回報的每個集合可能包含下列所有或部分章節。除了即時統計資料 (例如,自系統啟動以來未匯總的資料),每個集合中回報的統計資料都是自上次集合以來的差異。
產品 | 說明 |
---|---|
CPU I/O 等待時間/百分比 | 自上次收集資料以來,用於內容切換或因 I/O 作業而等待的絕對 CPU 時間,以及占 CPU 總時間的百分比。 |
CPU 作業時間總計 | CPU 作業總時間,以毫秒為單位。 |
CPU 閒置時間總計 | 閒置狀態的 CPU 作業時間總計。 |
CPU I/O 等待時間 | CPU 等待 I/O 作業的總時間。 |
環境切換次數 | CPU 從一個程序或執行緒切換至另一個程序或執行緒的次數。 |
I/O 阻斷程序數量/百分比 | 遭封鎖等待 I/O 的程序總數,以及自上次收集資料以來,遭封鎖等待 I/O 的程序百分比。 |
前 N 個 CPU 時間 |
自上次收集資料以來,消耗最多 CPU 時間的前 N 個套件:
|
前 N 個儲存空間 I/O 讀取作業 |
自上次收集資料以來,從磁碟讀取最多資料的前 N 個套件。 每行包含使用者 ID、套件名稱、在前台模式與背景模式中讀取的位元組總數、系統中所有前台模式與背景模式讀取作業的位元組百分比、在前台模式與背景模式中發出的 |
前 N 個儲存空間 I/O 寫入作業 | 自上次收集資料以來,寫入磁碟資料量最多的前 N 個套件。每行包含的欄位與前 N 個熱門讀物類似。 |
前 N 個 I/O 等待 UID | I/O 等待工作最多的前 N 個套件。
|
前 N 個主要頁面錯誤 | 自上次收集以來,發生最多主要頁面錯誤的前 N 個套件。 |