diff options
| author | 2019-11-26 11:04:17 -0800 | |
|---|---|---|
| committer | 2019-11-26 15:03:19 -0800 | |
| commit | d886cfe2bc932cc8bad9c08b3477bbc3ec31176a (patch) | |
| tree | 927ff99cb37f63d04191358607ca1d6989ee4fab | |
| parent | 936fd348f72d1e1ab92de257c088d56b85a4106d (diff) | |
Use resetJitCounters for boot image profiling
For boot image profiling, use resetJitCounters instead of disabling
preloading. This improves startup for the configuration by up to
20%.
Bug: 139883463
Bug: 142564450
Test: atest BootImageProfileTest
Change-Id: I11274ae623d3f0032e68f6f205447ad4d200620b
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index ad4c6dd7a92b..93e61020ff19 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -248,18 +248,6 @@ public class ZygoteInit { InputStream is; try { - // If we are profiling the boot image, avoid preloading classes. - // Can't use device_config since we are the zygote. - String prop = SystemProperties.get( - "persist.device_config.runtime_native_boot.profilebootclasspath", ""); - // Might be empty if the property is unset since the default is "". - if (prop.length() == 0) { - prop = SystemProperties.get("dalvik.vm.profilebootclasspath", ""); - } - if ("true".equals(prop)) { - return; - } - is = new FileInputStream(PRELOADED_CLASSES); } catch (FileNotFoundException e) { Log.e(TAG, "Couldn't find " + PRELOADED_CLASSES + "."); @@ -339,6 +327,22 @@ public class ZygoteInit { runtime.preloadDexCaches(); Trace.traceEnd(Trace.TRACE_TAG_DALVIK); + // If we are profiling the boot image, reset the Jit counters after preloading the + // classes. We want to preload for performance, and we can use method counters to + // infer what clases are used after calling resetJitCounters, for profile purposes. + // Can't use device_config since we are the zygote. + String prop = SystemProperties.get( + "persist.device_config.runtime_native_boot.profilebootclasspath", ""); + // Might be empty if the property is unset since the default is "". + if (prop.length() == 0) { + prop = SystemProperties.get("dalvik.vm.profilebootclasspath", ""); + } + if ("true".equals(prop)) { + Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "ResetJitCounters"); + runtime.resetJitCounters(); + Trace.traceEnd(Trace.TRACE_TAG_DALVIK); + } + // Bring back root. We'll need it later if we're in the zygote. if (droppedPriviliges) { try { |