From 1ed9d64bcda61feb35dadd925a41cd8e9d739775 Mon Sep 17 00:00:00 2001 From: Islam Elbanna Date: Mon, 17 Oct 2022 10:02:26 +0000 Subject: [PATCH] Allow profiling for standalone system server jars. Currently we profile only main system server classpath, this is to allow profiling for the standalone system server jars. Bug: 241823638 Test: System server profiling: verified the profile snapshot of the boot image profile, and it showed the new jars profiling data. Change-Id: I5b10373fb22ddfecdb95b6a4611f4af97bb5666d --- core/java/com/android/internal/os/ZygoteInit.java | 13 +++++++++---- .../android/server/pm/dex/ArtManagerService.java | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index ca1ae194cb124..73fb7fe0be496 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -517,7 +517,12 @@ public class ZygoteInit { if (shouldProfileSystemServer() && (Build.IS_USERDEBUG || Build.IS_ENG)) { try { Log.d(TAG, "Preparing system server profile"); - prepareSystemServerProfile(systemServerClasspath); + final String standaloneSystemServerJars = + Os.getenv("STANDALONE_SYSTEMSERVER_JARS"); + final String systemServerPaths = standaloneSystemServerJars != null + ? String.join(":", systemServerClasspath, standaloneSystemServerJars) + : systemServerClasspath; + prepareSystemServerProfile(systemServerPaths); } catch (Exception e) { Log.wtf(TAG, "Failed to set up system server profile", e); } @@ -603,12 +608,12 @@ public class ZygoteInit { * permissions. From the installer perspective the system server is a regular package which can * capture profile information. */ - private static void prepareSystemServerProfile(String systemServerClasspath) + private static void prepareSystemServerProfile(String systemServerPaths) throws RemoteException { - if (systemServerClasspath.isEmpty()) { + if (systemServerPaths.isEmpty()) { return; } - String[] codePaths = systemServerClasspath.split(":"); + String[] codePaths = systemServerPaths.split(":"); final IInstalld installd = IInstalld.Stub .asInterface(ServiceManager.getService("installd")); diff --git a/services/core/java/com/android/server/pm/dex/ArtManagerService.java b/services/core/java/com/android/server/pm/dex/ArtManagerService.java index 0e46b0f42a91e..9ebef3b41ad4c 100644 --- a/services/core/java/com/android/server/pm/dex/ArtManagerService.java +++ b/services/core/java/com/android/server/pm/dex/ArtManagerService.java @@ -339,6 +339,11 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub { String classpath = String.join(":", Os.getenv("BOOTCLASSPATH"), Os.getenv("SYSTEMSERVERCLASSPATH")); + final String standaloneSystemServerJars = Os.getenv("STANDALONE_SYSTEMSERVER_JARS"); + if (standaloneSystemServerJars != null) { + classpath = String.join(":", classpath, standaloneSystemServerJars); + } + // Create the snapshot. createProfileSnapshot(BOOT_IMAGE_ANDROID_PACKAGE, BOOT_IMAGE_PROFILE_NAME, classpath, /*appId*/ -1, callback);