Profiling the Android Compatibility Test Suite (CTS) using Perfetto on Cuttlefish causes frequent device disconnects

307 Views Asked by At

As part of a research project, I am trying perform callstack sampling using Perfetto's cpu_profiler while running the Android Compatibility Test Suite (CTS) using a Cuttlefish Virtual Device (CVD) .

My problem is that the CVD frequently disconnects, which makes the tests fail, and prevents me from collecting the callstacks I want.

I'm adding a relevant part of the CTS logs:

05-28 14:20:53 D/NativeDevice: Device 0.0.0.0:6520 state is now NOT_AVAILABLE
05-28 14:21:04 D/NativeDevice: Device 0.0.0.0:6520 state is now ONLINE
05-28 14:21:22 W/NativeDevice: There is no reboot history since 1685276476000
05-28 14:21:22 E/ModuleDefinition: Detected a soft-restart after module x86 CtsNativeNetDnsTestCases
05-28 14:21:22 E/LeakedThreadStatusChecker: We have 3 threads instead of 1. List: [Thread[Invocation-0.0.0.0:6520,5,Invocation-0.0.0.0:6520], Thread[BackgroundDeviceAction-logcat -v threadtime,uid,5,Invocation-
0.0.0.0:6520], Thread[Timer-1,5,Invocation-0.0.0.0:6520]]
05-28 14:21:22 W/ITestSuite: System status checker [com.android.tradefed.suite.checker.LeakedThreadStatusChecker] failed
05-28 14:21:22 W/DeviceSettingChecker: Setting in namespace global fails:
 boot_count changes from 99 to 100
05-28 14:21:22 W/ITestSuite: System status checker [com.android.tradefed.suite.checker.DeviceSettingChecker] failed
05-28 14:21:23 W/ITestSuite: There are failed system status checkers: {com.android.tradefed.suite.checker.LeakedThreadStatusChecker=We have 3 threads instead of 1. List: [Thread[Invocation-0.0.0.0:6520,5,Invocation-0.0.0.0:6520], Thread[BackgroundDeviceAction-logcat -v threadtime,uid,5,Invocation-0.0.0.0:6520], Thread[Timer-1,5,Invocation-0.0.0.0:6520]], com.android.tradefed.suite.checker.DeviceSettingChecker=Setting in namespace global fails:
 boot_count changes from 99 to 100

I know the problem comes from doing the profiling in parallel, because when I disable it, the tests run without failure and without device disconnection.

I should note that the CTS and CVD were built from the Android 13.0.0_r42 branch

I tried reducing the sampling frequency in the perfetto config file to 10 samples per second (which is very low compared to what I want), and I expected it to make the disconnecting less frequent, but this does not seem to be the case.

Is there maybe another way to achieve what I want to achieve?

Thanks in advance for any help!

1

There are 1 best solutions below

0
On

Ok, so if for some weird reason someone else encounters this problem, I ended up (partially) solving it. I'm still not entirely sure if this definitely really helped, so take it with a grain of salt, but I thought that increasing the amount of RAM available to the CVD would help. This can be done with the command line arguments:

launch_cvd --num_instances=1 --daemon --memory_mb=8000 --cpus=8

On the other hand, what definitely helped was to increase the ring_buffer_read_period_ms to 200 in the perfetto config file. I could then increase the sampling frequency (also in the perfetto config file) to 100, and the device disconnected far less often. The tradeoff is that increasing the buffer read period sometimes causes samples to be lost. Overall, it seems that we can work around the problem by playing with config values to decrease the disconnections, but this is not a perfect or clean solution.