Bug #111923
Bug #111192: 【Figure】【EVT3】【EE】【启动时间1分6秒】【Performance】
Starting com.android.server.BatteryService 耗费 4400ms
Status: | CLOSED | Start date: | 2022-09-13 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | 移动测试一组_CDTS 刘强 | % Done: | 0% | |
Category: | SYSTEM | |||
Target version: | - | |||
Need_Info: | -- | Found Version: | 所有版本 | |
Resolution: | FIXED | Degrated: | -- | |
Severity: | Major | Verified Version: | DB 20220923 | |
Reproducibility: | Every time | Fixed Version: | ||
Test Type: | IT | Root cause: | The device has no battery. The healthd service will retry 75 times for getting battery capacity node. It will cost 7500ms. |
Description
开机启动阶段Starting com.android.server.BatteryService 耗费 4400ms。
行 6340: 01-01 14:55:04.715 1526 1526 I SystemServerTiming: StartBatteryService
行 6341: 01-01 14:55:04.715 1526 1526 I SystemServiceManager: Starting com.android.server.BatteryService
耗时4400ms
行 8422: 01-01 14:55:09.115 1526 1526 I BatteryService: health: Waited 0ms and received the update.
行 8423: 01-01 14:55:09.115 1526 1526 W SystemServiceManager: Service com.android.server.BatteryService took 4400 ms in onStart
行 8424: 01-01 14:55:09.115 1526 1526 I SystemServerTiming: StartUsageService
History
#1 Updated by CD SYSTEM-龚元祝 almost 3 years ago
- File l0913.txt
added
行 2910: 01-01 14:55:01.293 669 669 I boot_progress_start: 10802
行 2972: 01-01 14:55:01.654 669 669 I boot_progress_preload_start: 11163
行 4600: 01-01 14:55:02.805 669 669 I boot_progress_preload_end: 12314
行 5569: 01-01 14:55:03.256 1526 1526 I boot_progress_system_run: 12766
行 6016: 01-01 14:55:04.158 1526 1526 I boot_progress_pms_start: 13667
行 6192: 01-01 14:55:04.233 1526 1526 I boot_progress_pms_system_scan_start: 13743
行 6214: 01-01 14:55:04.609 1526 1526 I boot_progress_pms_data_scan_start: 14119
行 6223: 01-01 14:55:04.613 1526 1526 I boot_progress_pms_scan_end: 14122
行 6233: 01-01 14:55:04.671 1526 1526 I boot_progress_pms_ready: 14181
行 9464: 09-09 16:55:18.519 1526 1526 I boot_progress_ams_ready: 19216
行 12220: 09-09 16:55:19.288 1526 1598 I boot_progress_enable_screen: 19985
#2 Updated by CD FW-王伟 almost 3 years ago
- Assignee changed from CD FW-王伟 to CD- FW-石豪
#3 Updated by CD- FW-石豪 almost 3 years ago
热启动
01-01 13:22:26.470 1071 1071 I SystemServerTiming: StartBatteryService
01-01 13:22:26.470 1071 1071 I SystemServiceManager: Starting com.android.server.BatteryService
01-01 13:22:26.636 1071 1071 I HealthServiceWrapper: health: HealthServiceWrapper listening to instance default
01-01 13:22:26.644 1071 1071 W SystemServiceManager: Service com.android.server.BatteryService took 173 ms in onStart
断电启动
01-01 00:01:08.302 1074 1074 I SystemServerTiming: StartBatteryService
01-01 00:01:08.302 1074 1074 I SystemServiceManager: Starting com.android.server.BatteryService
01-01 00:01:09.531 1074 1074 I HealthServiceWrapper: health: HealthServiceWrapper listening to instance default
01-01 00:01:09.531 1074 1074 I BatteryService: health: Waited 0ms and received the update.
01-01 00:01:09.532 1074 1074 W SystemServiceManager: Service com.android.server.BatteryService took 1228 ms in onStart
01-01 00:01:09.532 1074 1074 D SystemServerTiming: StartBatteryService took to complete: 1230ms
本地自测,热启动耗时较小,断电启动耗时较长,主要耗时在BatteryService的registerHealthCallback方法。具体耗时还需加入日志调试
#4 Updated by CD- FW-石豪 almost 3 years ago
热启动
01-01 00:35:58.889 1080 1080 I SystemServerTiming: StartBatteryService
01-01 00:35:58.889 1080 1080 I SystemServiceManager: Starting com.android.server.BatteryService
01-01 00:35:58.890 1080 1080 I BatteryService: health: Waited new HealthServiceWrapper: 0ms
01-01 00:35:58.890 1080 1080 I BatteryService: health: Waited new HealthHalCallback: 0ms
01-01 00:35:58.893 1080 1080 I HealthServiceWrapper: health: Waited HealthInitGetService_: 2ms
01-01 00:35:58.968 1080 1080 I HealthServiceWrapper: health: Waited mCallback.onRegistration: 75ms
01-01 00:35:58.972 1080 1080 I HealthServiceWrapper: health: Waited registerForNotifications: 4ms
01-01 00:35:58.972 1080 1080 I HealthServiceWrapper: health: HealthServiceWrapper listening to instance default
01-01 00:35:58.972 1080 1080 I BatteryService: health: Waited mHealthServiceWrapper.init: 81ms
01-01 00:35:58.972 1080 1080 I BatteryService: health: Waited 0ms and received the update.
01-01 00:35:58.974 1080 1080 W SystemServiceManager: Service com.android.server.BatteryService took 84 ms in onStart
01-01 00:35:58.974 1080 1080 D SystemServerTiming: StartBatteryService took to complete: 86ms
冷启动
01-01 00:01:08.855 1047 1047 I SystemServerTiming: StartBatteryService
01-01 00:01:08.855 1047 1047 I SystemServiceManager: Starting com.android.server.BatteryService
01-01 00:01:08.858 1047 1047 I BatteryService: health: Waited new HealthServiceWrapper: 1ms
01-01 00:01:08.858 1047 1047 I BatteryService: health: Waited new HealthHalCallback: 0ms
01-01 00:01:09.985 1047 1047 I HealthServiceWrapper: health: Waited HealthInitGetService_: 1127ms
01-01 00:01:10.022 1047 1047 I HealthServiceWrapper: health: Waited mCallback.onRegistration: 36ms
01-01 00:01:10.028 1047 1047 I HealthServiceWrapper: health: Waited registerForNotifications: 6ms
01-01 00:01:10.028 1047 1047 I HealthServiceWrapper: health: HealthServiceWrapper listening to instance default
01-01 00:01:10.028 1047 1047 I BatteryService: health: Waited mHealthServiceWrapper.init: 1170ms
01-01 00:01:10.028 1047 1047 I BatteryService: health: Waited 0ms and received the update.
01-01 00:01:10.032 1047 1047 W SystemServiceManager: Service com.android.server.BatteryService took 1175 ms in onStart
01-01 00:01:10.032 1047 1047 D SystemServerTiming: StartBatteryService took to complete: 1177ms
多次测试,定位到主要耗时在HealthInitGetService 1127ms for (String name : sAllInstances) {
traceBegin("HealthInitGetService_" + name);
long testWait1 = SystemClock.uptimeMillis();
try {
newService = healthSupplier.get(name);
} catch (NoSuchElementException ex) {
/* ignored, handled below */
} finally {
traceEnd();
}
interface IHealthSupplier {
default IHealth get(String name) throws NoSuchElementException, RemoteException {
return IHealth.getService(name, true /* retry */);
}
}
代码中的服务名调试时打印出来是:default
IHealth.getService 第二参数的意思重试直到获取服务,来自HAL层 android.hardware.health.V2_0.IHealth,因此需要HAL层的同事帮忙分析IHealth为何起来的比较慢
#5 Updated by CD- FW-石豪 almost 3 years ago
- Category changed from CD-FW to SYSTEM
- Assignee changed from CD- FW-石豪 to CD SYSTEM-龚元祝
#6 Updated by CD SYSTEM-龚元祝 almost 3 years ago
已提高通case:06208590
转team
case:06210352
#7 Updated by CD SYSTEM-龚元祝 almost 3 years ago
general/platform/vendor/qcom-opensource/healthd-ext/+/149363/1/healthimpl.cpp
namespace {
void qti_healthd_board_init(struct healthd_config *)
{
int fd;
unsigned char retries = 75;
int ret = 0;
unsigned char buf;
retry:
if (!retries) {
ALOGE;
return;
}
fd = open("/sys/class/power_supply/battery/capacity", 0440);
if (fd >= 0) {
ALOGI("opened battery/capacity after %d retries\n", 75 - retries);
while (retries) {
ret = read(fd, &buf, 1);
if(ret >= 0) {
ALOGI("Read Batt Capacity after %d retries ret : %d\n", 75 - retries, ret);
close(fd);
return;
}
retries--;
usleep(100000);
}
ALOGE("Failed to read Battery Capacity ret=%d\n", ret);
close(fd);
return;
}
retries--;
usleep(100000);
goto retry;
}
} //anonymous namespace
由于qti_healthd_board_init无法获取电池容量节点,导致retry了75次,耗费7.5s。
后面启动的android.hardware.health service因此被delay 4.4s,同时StartBatteryService也就delay了4.4s。
本项目没有电池,所以修改retry次数为10次,以免造成StartBatteryService的延时。
以下为提交的修改连接:
https://dev.thundercomm.com/gerrit/c/general/platform/vendor/qcom-opensource/healthd-ext/+/149363
VB:
http://10.0.76.24:8080/job/VerifyBuild_for_IOT_6490/1312/
验证结果:
01-01 08:02:15.290 671 671 I boot_progress_start: 8019
01-01 08:02:15.761 671 671 I boot_progress_preload_start: 8490
01-01 08:02:16.599 671 671 I boot_progress_preload_end: 9328
01-01 08:02:16.821 1505 1505 I boot_progress_system_run: 9550
01-01 08:02:18.123 1505 1505 I boot_progress_pms_start: 10852
01-01 08:02:18.212 1505 1505 I boot_progress_pms_system_scan_start: 10941
01-01 08:02:18.601 1505 1505 I boot_progress_pms_data_scan_start: 11330
01-01 08:02:18.605 1505 1505 I boot_progress_pms_scan_end: 11334
01-01 08:02:18.663 1505 1505 I boot_progress_pms_ready: 11391
--耗时721ms
09-16 18:18:38.579 1505 1505 I boot_progress_ams_ready: 12112
09-16 18:18:39.251 1505 1632 I boot_progress_enable_screen: 12785
#8 Updated by CD SYSTEM-龚元祝 almost 3 years ago
- Assignee changed from CD SYSTEM-龚元祝 to CDTS_TEST 王成
- Resolution changed from -- to FIXED
- Verified Version set to DB 20220923
- Root cause set to The device has no battery. The healthd service will retry 75 times for getting battery capacity node. It will cost 7500ms.
#9 Updated by CD SYSTEM-龚元祝 almost 3 years ago
- Status changed from New to RESOLVED
#10 Updated by CDTS_TEST 王成 over 2 years ago
- Assignee changed from CDTS_TEST 王成 to SZTS_TEST 邹涛
验证下问题
#11 Updated by CDTS_TEST 王成 over 2 years ago
- Assignee changed from SZTS_TEST 邹涛 to 移动测试一组_CDTS 刘强
#12 Updated by 移动测试一组_CDTS 刘强 over 2 years ago
- Status changed from RESOLVED to VERIFIED
测试版本:FlatBuild_HH_VX1_MCE_FSE.M.R.user.01.00.0069.X101
热启动:
Boot_progress_pms_ready:9875
Boot_progress_ams_ready:10844
969ms
冷启动:
Boot_progress_pms_ready:9751
Boot_progress_ams_ready:10937
1186ms
均小于4400ms,因此验证通过
#13 Updated by 移动测试一组_CDTS 刘强 over 2 years ago
- Status changed from VERIFIED to CLOSED