Avoid dex2dex initialization if not compiling.
Reduces the compilation time for the boot image extension
in memory by ~0.1s.
Also record timing for ImageWriter::PreloadDexCaches() and
and fix naming for CompilerDriver::SetVerifiedDexFile()
timing to not be confused with VerifyDexFile().
Test: aosp_taimen-userdebug boots;
adb root && \
adb shell stop && \
adb shell setprop dalvik.vm.boot-image \
'boot.art:/nonx/boot-framework.art!/system/etc/boot-image.prof' && \
adb shell 'setprop dalvik.vm.extra-opts \
"-Ximage-compiler-option --dump-timings"' && \
adb shell start # Starts correctly
# Check dex2oat timing in logcat
Bug: 119800099
Change-Id: I72d1916164906cab593c1437eeb4b3aa094b8493
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index 525cfab..6792a59 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -852,7 +852,11 @@
VLOG(compiler) << "Before precompile " << GetMemoryUsageString(false);
compiled_classes_.AddDexFiles(GetCompilerOptions().GetDexFilesForOatFile());
- dex_to_dex_compiler_.SetDexFiles(GetCompilerOptions().GetDexFilesForOatFile());
+
+ if (GetCompilerOptions().IsAnyCompilationEnabled()) {
+ TimingLogger::ScopedTiming t2("Dex2Dex SetDexFiles", timings);
+ dex_to_dex_compiler_.SetDexFiles(GetCompilerOptions().GetDexFilesForOatFile());
+ }
// Precompile:
// 1) Load image classes.
@@ -2093,7 +2097,7 @@
ThreadPool* thread_pool,
size_t thread_count,
TimingLogger* timings) {
- TimingLogger::ScopedTiming t("Verify Dex File", timings);
+ TimingLogger::ScopedTiming t("Set Verified Dex File", timings);
if (!compiled_classes_.HaveDexFile(&dex_file)) {
compiled_classes_.AddDexFile(&dex_file);
}
diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc
index a5605f9..af8c50b 100644
--- a/dex2oat/linker/image_writer.cc
+++ b/dex2oat/linker/image_writer.cc
@@ -278,6 +278,7 @@
}
{
+ TimingLogger::ScopedTiming t("PreloadDexCaches", timings);
// Preload deterministic contents to the dex cache arrays we're going to write.
ScopedObjectAccess soa(self);
ObjPtr<mirror::ClassLoader> class_loader = GetAppClassLoader();