Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea257b66 authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Android (Google) Code Review
Browse files

Merge "Fix the boot time regression caused by DexUseManagerLocal init."

parents 2ba9cad5 1b7dda73
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1052,6 +1052,17 @@ public final class SystemServer implements Dumpable {
    private void startBootstrapServices(@NonNull TimingsTraceAndSlog t) {
        t.traceBegin("startBootstrapServices");

        t.traceBegin("ArtModuleServiceInitializer");
        // This needs to happen before DexUseManagerLocal init. We do it here to avoid colliding
        // with a GC. ArtModuleServiceInitializer is a class from a separate dex file
        // "service-art.jar", so referencing it involves the class linker. The class linker and the
        // GC are mutually exclusive (b/263486535). Therefore, we do this here to force trigger the
        // class linker earlier. If we did this later, especially after PackageManagerService init,
        // the class linker would be consistently blocked by a GC because PackageManagerService
        // allocates a lot of memory and almost certainly triggers a GC.
        ArtModuleServiceInitializer.setArtModuleServiceManager(new ArtModuleServiceManager());
        t.traceEnd();

        // Start the watchdog as early as possible so we can crash the system server
        // if we deadlock during early boot
        t.traceBegin("StartWatchdog");
@@ -1238,8 +1249,6 @@ public final class SystemServer implements Dumpable {
        t.traceBegin("DexUseManagerLocal");
        // DexUseManagerLocal needs to be loaded after PackageManagerLocal has been registered, but
        // before PackageManagerService starts processing binder calls to notifyDexLoad.
        // DexUseManagerLocal may also call artd, so ensure ArtModuleServiceManager is instantiated.
        ArtModuleServiceInitializer.setArtModuleServiceManager(new ArtModuleServiceManager());
        LocalManagerRegistry.addManager(
                DexUseManagerLocal.class, DexUseManagerLocal.createInstance());
        t.traceEnd();