On low-end devices, ART doesn't compile many methods (or none at all).
From oatdump on Gobo, Android Go:
# oatdump --oat-file=/data/app/com.google.android.apps.chrome-.../oat/arm/base.vdex --header-only
[...]
dex2oat-cmdline = --zip-fd=8 --zip-location=base.apk --input-vdex-fd=-1 --output-vdex-fd=10 --oat-fd=9 --oat-location=/data/app/com.google.android.apps.chrome-787akXzqgh6j_C4FjLWDjA==/oat/arm/base.odex --instruction-set=arm --instruction-set-variant=cortex-a53 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m --compiler-filter=quicken --swap-fd=11 --classpath-dir=/data/app/com.google.android.apps.chrome-787akXzqgh6j_C4FjLWDjA== --class-loader-context=PCL[]
The "quicken" compilation profile is used, which is (see https://source.android.com/devices/tech/dalvik/configure):
"quicken: run DEX code verification and optimize some DEX instructions to get better interpreter performance."
Indeed, the odex is small, whereas the vdex (DEX + verification metadata) is larger:
# ls -lh
-rw-r--r-- 1 system all_a84 296K 2018-06-13 14:46 base.odex
-rw-r--r-- 1 system all_a84 7.1M 2018-06-13 14:46 base.vdex
However, since the VDEX contains bytecode and not code, it's not mapped with executable permissions (from /proc/pid/smaps):
9726f000-97993000 r--s 00000000 fd:00 29083 /data/app/com.google.android.apps.chrome-787akXzqgh6j_C4FjLWDjA==/oat/arm/base.vdex
Size: 7312 kB
Rss: 3804 kB
Pss: 2734 kB
Shared_Clean: 2140 kB
Shared_Dirty: 0 kB
Private_Clean: 1664 kB
Private_Dirty: 0 kB
Referenced: 3048 kB
Anonymous: 0 kB
AnonHugePages: 0 kB
Swap: 0 kB
PSwap: 0 kB
SwapPss: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd mr me ms
This makes the VDEX file prone to eviction, and may create jank when Java code has to execute.
Using the script attached, we see after Chrome being in the background for a few minutes:
$ tools/android/native_lib_memory/odex_pss.py --chrome-package com.google.android.apps.chrome
Total PSS from code pages = 3664kB
And opening Chrome and focusing the omnibox:
$ tools/android/native_lib_memory/odex_pss.py --chrome-package com.google.android.apps.chrome
Total PSS from code pages = 5084kB
$ tools/android/native_lib_memory/odex_pss.py --chrome-package com.google.android.apps.chrome
Total PSS from code pages = 5600kB
This could be a cause of jank. Several potential solutions could be tested, provided that this is an issue:
- mprotect(PROT_EXEC) on the vdex area (making it harder to evict)
- madvise(WILL_NEED) when Chrome is resumed
|
Deleted:
odex_pss.py
1.7 KB
|
Comment 1 by benhenry@google.com
, Jan 11