diff options
| author | 2020-05-26 12:09:14 +0200 | |
|---|---|---|
| committer | 2020-05-27 17:10:15 +0000 | |
| commit | 9151c6d55bd7ce556e3e3847c70f40397f10ddef (patch) | |
| tree | fda6f6db2b141178b08607a8ab744f15c35124b5 | |
| parent | 0fb9ae803c8f365a366a6a9cc81ff4c9e1153fda (diff) | |
Preload perfetto_hprof library in Zygote.
This is to reduce the startup time for profileable or debuggable apps.
Test: flash, run benchmarks
(cherry picked from commit 0278b4bfb6528c929120f99dbef67d36e55bc6de)
Bug: 147667830
Change-Id: Iee5d60664cad5b6e445c2291d6de07f2bb555017
Merged-In: Iee5d60664cad5b6e445c2291d6de07f2bb555017
| -rw-r--r-- | runtime/runtime.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 8345d77a5b..7646a13bf9 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1788,6 +1788,14 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { callbacks_->NextRuntimePhase(RuntimePhaseCallback::RuntimePhase::kInitialAgents); } + if (IsZygote() && IsPerfettoHprofEnabled()) { + constexpr const char* plugin_name = kIsDebugBuild ? + "libperfetto_hprofd.so" : "libperfetto_hprof.so"; + // Load eagerly in Zygote to improve app startup times. This will make + // subsequent dlopens for the library no-ops. + dlopen(plugin_name, RTLD_NOW | RTLD_LOCAL); + } + VLOG(startup) << "Runtime::Init exiting"; // Set OnlyUseSystemOatFiles only after boot classpath has been set up. |