Skip to content
Commit 2237efed authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Optimize getting time_in_state for threads of system server

Prior to this change, we would iterate over _all_ UIDs in
the system, select the one for SystemServer and then iterate over
_all_ threads in _all_ processes running under that UID.
This iteration involves reading many directories in /proc and
many files in those directories.

In the new implementation, we only read time_in_state for the
threads in the system server process itself, identifying them by
the PID.  This optimization reduces the cost 5:1 to 8:1 in terms
of CPU time, number of files read and amount of RAM used.

Bug: 167994570
Bug: 163063901

Test: atest FrameworksCoreTests:com.android.internal.os.SystemServerCpuThreadReaderTest
Test: atest FrameworksCoreTests:com.android.internal.os.BatteryStatsTests
Test: atest FrameworksCoreTests:com.android.internal.os.KernelSingleProcessCpuThreadReaderTest
Change-Id: Iaa2eabc9f39999b2867bbffbac93b282cde74165
parent f9438b04
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment