Hardcode more array types in the profile for the ART boot image.
Motivation: after separation of core-icu4j into i18n APEX
(https://r.android.com/1302774), core-icu4j has been moved from the ART
boot image to the framework boot image extension. This has caused
slowdown on ZygoteInit and PostZygoteInitGC (b/156098788), as well as
increase of PSS for zygote (b/156198579).
Two factors contribute to the regression:
1. Some classes are now missing from the boot image (they were
previously included in the ART image because core-icu4j contains
references to them):
java.lang.Class "byte[][][]"
java.lang.Class "int[][]"
java.lang.Class "int[][][]"
java.lang.Class "java.lang.ref.WeakReference[]"
java.lang.Class "java.math.MathContext[]"
java.lang.Class "java.security.Provider[]"
java.lang.Class "java.text.DateFormat[]"
java.lang.Class "java.text.Normalizer$Form[]"
java.lang.Class "java.time.temporal.IsoFields$Field[]"
java.lang.Class "short[][]"
java.lang.Class "sun.security.jca.ProviderConfig[]"
2. Some classes that previosly were verified now require verification
at run-time.
This patch addresses the first problem: it hard-codes array classes
int[][], int[][][], short[][], byte[][][] in the profile for ART image.
These four classes have been chosen because they contribute most to
the output of:
`m dump-oat-boot && \
grep -cE 'Class.*VisiblyInitialized' boot.host-<arch>.oatdump.txt`
[[I+[[[I+[[S+[[[B+[WR+[MC+[P+[DF+[NF+[IFF+[PC 8505 <= all
[[I+[[[I+[[S+[[[B+[WR+[MC+[P+[DF+[NF+[IFF 8504
[[I+[[[I+[[S+[[[B+[WR+[MC+[P+[DF+[NF 8503
[[I+[[[I+[[S+[[[B+[WR+[MC+[P+[DF 8502
[[I+[[[I+[[S+[[[B+[WR+[MC+[P 8501
[[I+[[[I+[[S+[[[B+[WR+[MC 8500
[[I+[[[I+[[S+[[[B+[WR 8498
[[I+[[[I+[[S+[[[B 8496 <= this patch
[[I+[[[I+[[S 8494
[[I+[[[I 8492
[[I 8489
8435 <= none
Test: aosp_cf_x86_phone-userdebug boots
Test: Forrest runs of asit/perf/boottime_test (SuccessiveBootTest) show
reduced slowdown on ZygotInit compared to the metric before:
- wembley (zygote32) is down to 4880ms
(from ~5150ms, compared to ~4800ms before the ICU change)
- walleye (zygote64) is down to 1385ms
(from ~1430ms, compared to ~1350ms before the ICU change)
Stats of this Forrest run may be too good due to the noise:
https://android-build.googleplex.com/builds/forrest/run/L52500000567492990
Bug: 156098788
Bug: 156198579
Change-Id: I62a27124fcd431000cc7752ba72e7faa85499a64
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index b97c1f0..31e78aa 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -1077,10 +1077,19 @@
return;
}
- // Make sure the File[] class is in the primary boot image. b/150319075
+ // A hard-coded list of array classes that should be in the primary boot image profile. The impact
+ // of each class can be approximately measured by comparing oatdump output with and without it:
+ // `m dump-oat-boot && grep -cE 'Class.*VisiblyInitialized' boot.host-<arch>.oatdump.txt`.
+ // - b/150319075: File[]
+ // - b/156098788: int[][], int[][][], short[][], byte[][][]
+ //
// TODO: Implement support for array classes in profiles and remove this workaround. b/148067697
if (GetCompilerOptions().IsBootImage()) {
image_classes->insert("[Ljava/io/File;");
+ image_classes->insert("[[I");
+ image_classes->insert("[[[I");
+ image_classes->insert("[[S");
+ image_classes->insert("[[[B");
}
TimingLogger::ScopedTiming t("LoadImageClasses", timings);