Application cold start optimization method and device, electronic equipment and storage medium

By building the class structure and class reference relationship diagram of the application configuration file, filtering and packaging high-frequency classes to the main dex file, the problem of cold startup time for low-version devices in Android system is solved, and faster application startup speed is achieved.

CN119621191AActive Publication Date: 2025-03-14HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411832784.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-03-14
Estimated Expiration
2044-12-12

AI Technical Summary

Technical Problem

Low-version devices in Android system take a long time to start the first cold start of the application, affecting the user experience.

Method used

By building a class structure and class reference relationship diagram based on the application configuration file, filter out high-frequency classes and package them into the main dex file, and non-high-frequency classes into the secondary dex file. When applying cold startup, first load the main dex file until the cold startup is completed and then load the second dex file.

Benefits of technology

It reduces the time for cold start of the application, improves the user experience, and solves the problem of slow cold start for the first time in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621191A_ABST
    Figure CN119621191A_ABST
Patent Text Reader

Abstract

The invention provides an application cold start optimization method and device, electronic equipment and a storage medium. In the application cold start optimization method, a first relational graph and a second relational graph are constructed based on a configuration file of an application. And then screening out high-frequency classes of the applications according to the access frequency of the classes based on the first relational graph and the second relational graph, and packaging the high-frequency classes into a main dex file. And packaging the non-high-frequency class in a secondary dex file. And finally, loading the primary dex file during cold start of the application, and loading the secondary dex file until the cold start of the application is completed. Therefore, by means of the method, the high-frequency class is packaged into the main dex file, it is ensured that service scenes commonly used by a user can be covered in the main dex file during cold starting, only the main dex file is loaded in the application starting stage, the loading time is shortened, and the application cold starting speed is increased. The problem that cold start is slow in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an optimization method, device, electronic device and storage medium for cold starting an application. Background Art

[0002] With the development of science and technology, smart terminal products are becoming more and more popular, among which a large number of smart terminals use the Android system.

[0003] For devices with lower versions of Android, the Java runtime environment used is the Dalvik virtual machine. The biggest problem is that after the application is installed or updated, the first cold start of the application takes a long time, which takes tens of seconds or even minutes. Users need to face a black screen for a while before they can use the APP normally, which seriously affects the user experience. Summary of the invention

[0004] In view of this, the present application provides an optimization method, device, electronic device and storage medium for cold starting an application to solve the problem of slow first cold starting of an application in the prior art.

[0005] To achieve the above objectives, this application provides the following technical solutions:

[0006] The first aspect of the present application discloses a method for optimizing application cold start, comprising:

[0007] Constructing a first relationship graph and a second relationship graph based on the application configuration file; wherein the first relationship graph is used to represent the class structure information corresponding to the components of the application configuration file; and the second relationship graph is used to represent the class reference information corresponding to the components of the application configuration file;

[0008] Based on the first relationship graph and the second relationship graph, filter out high-frequency classes of the application according to the access frequency of the classes, and pack the high-frequency classes into a main dex file;

[0009] Packing non-high-frequency classes into a secondary dex file; wherein the non-high-frequency classes are classes in the application other than the high-frequency classes;

[0010] When the application is cold started, the primary dex file is loaded, and after the application is cold started, the secondary dex file is loaded.

[0011] Optionally, in the above method, the step of constructing the first relationship graph and the second relationship graph based on the configuration file of the application includes:

[0012] Based on the configuration file, obtaining component information of the preset component;

[0013] Based on the component information, the class structure in the preset component is parsed, and class indexes and dependencies are established according to the class structure to generate the first relationship graph;

[0014] Based on the component information, the class references in the preset component are parsed, and class indexes and dependencies are established according to the class references to generate the second relationship graph.

[0015] Optionally, the above method, filtering out high-frequency classes of the application according to class access frequencies based on the first relationship graph and the second relationship graph, and packaging the high-frequency classes into a main dex file, includes:

[0016] Traversing the first relationship graph and the second relationship graph respectively, obtaining the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph;

[0017] Put each class in the first relationship graph into a first queue in descending order of access frequency;

[0018] Put each class in the second relationship graph into the second queue in descending order of access frequency;

[0019] Based on the first queue and the second queue, classes whose access frequencies meet preset conditions are screened out, and the screened classes are packaged into the main dex file.

[0020] Optionally, the above method, filtering out classes that meet preset conditions based on the first queue and the second queue, and packaging the filtered classes into the main dex file, includes:

[0021] Performing a deep traversal on the first queue, if the number of methods of the traversed class is equal to a preset threshold and the traversal of the first queue has not been completed, stopping the traversal and packaging the traversed classes in the first queue into the main dex file; wherein the threshold is the maximum number of methods that the main dex file can accommodate;

[0022] If the number of methods of the classes that have completed the traversal is less than the threshold and the first queue has completed the traversal, perform a deep traversal on the second queue and calculate the difference between the threshold and the number of methods of the classes of the first queue;

[0023] If the number of methods of the class traversed by the second queue is equal to the difference and the traversal of the second queue has not been completed, stop the traversal and pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file;

[0024] If the number of methods of the class traversed by the second queue is less than the difference and the traversal of the second queue is completed, the traversal is stopped, and the traversed classes in the first queue and the traversed classes in the second queue are packaged into the main dex file.

[0025] The second aspect of the present application discloses an optimization device for application cold start, comprising:

[0026] A construction unit, configured to construct a first relationship graph and a second relationship graph based on a configuration file of an application; wherein the first relationship graph is used to represent class structure information corresponding to components of the application configuration file; and the second relationship graph is used to represent class reference information corresponding to components of the application configuration file;

[0027] A screening unit, configured to screen out high-frequency classes of the application according to the access frequency of the classes based on the first relationship graph and the second relationship graph, and pack the high-frequency classes into a main dex file;

[0028] A packaging unit, used to package non-high-frequency classes into a secondary dex file; wherein the non-high-frequency classes are classes in the application other than the high-frequency classes;

[0029] The loading unit is used to load the primary dex file when the application is cold started, and then load the secondary dex file after the application is cold started.

[0030] Optionally, the construction unit of the above-mentioned device includes:

[0031] An acquisition subunit, used for acquiring component information of a preset component based on the configuration file;

[0032] A first generating subunit is used to parse the class structure in the preset component based on the component information, and establish the index and dependency of the class according to the class structure to generate the first relationship graph;

[0033] The second generating subunit is used to parse the class reference in the preset component based on the component information, and establish the class index and dependency according to the class reference to generate the second relationship graph.

[0034] Optionally, in the above device, the screening unit comprises:

[0035] A first traversal subunit is used to traverse the first relationship graph and the second relationship graph respectively to obtain the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph;

[0036] A first queue construction subunit is used to put each class in the first relationship graph into a first queue in descending order of access frequency;

[0037] A second queue construction subunit is used to put each class in the second relationship graph into the second queue in descending order of access frequency;

[0038] The screening subunit is used to screen out classes whose access frequencies meet preset conditions based on the first queue and the second queue, and pack the screened classes into the main dex file.

[0039] Optionally, in the above device, the screening subunit comprises:

[0040] A second traversal subunit is used to perform a deep traversal on the first queue. If the number of methods of the traversed class is equal to a preset threshold and the traversal of the first queue has not been completed, the traversal is stopped, and the traversed classes in the first queue are packaged into the main dex file; wherein the threshold is the maximum number of methods that the main dex file can accommodate;

[0041] A third traversal subunit is used for performing a deep traversal on the second queue and calculating a difference between the threshold and the number of methods of the class of the first queue if the number of methods of the class that has completed the traversal is less than the threshold and the traversal of the first queue has been completed;

[0042] a fourth traversal subunit, configured to stop traversal if the number of methods of the classes traversed by the second queue is equal to the difference and the traversal of the second queue has not been completed, and to pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file;

[0043] The fifth traversal subunit is used to stop traversal if the number of methods of the class traversed by the second queue is less than the difference and the traversal of the second queue has been completed, and to pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file.

[0044] The third aspect of the present application discloses an electronic device, comprising:

[0045] one or more processors;

[0046] a storage device having one or more programs stored thereon;

[0047] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of the first aspects of the present application.

[0048] A fourth aspect of the present application discloses a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method described in any one of the first aspects of the present application is implemented.

[0049] It can be seen from the above technical scheme that in an optimization method for cold start of an application provided by the present application, a first relationship graph and a second relationship graph are first constructed based on the configuration file of the application; wherein the first relationship graph is used to characterize the class structure information corresponding to the components of the application configuration file; and the second relationship graph is used to characterize the class reference information corresponding to the components of the application configuration file. Then, based on the first relationship graph and the second relationship graph, the high-frequency classes of the application are screened out according to the access frequency of the class, and the high-frequency classes are packaged into the main dex file. And the non-high-frequency classes are packaged into the secondary dex file. Finally, when the application is cold started, the main dex file is loaded, and other secondary dex files are loaded in sequence until the cold start of the application is completed. It can be seen that, using the method of the present application, by packaging the high-frequency classes into the main dex file, it is ensured that the business scenarios commonly used by users during cold start can be covered in the main dex file, and only the main dex file is loaded in the application startup phase, which reduces the loading time and speeds up the cold start of the application. The problem of slow first cold start of the application in the prior art is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0051] Figure 1 A flowchart of an optimization method for cold start of an application disclosed in an embodiment of the present application;

[0052] Figure 2 This is a flowchart of an implementation of step S101 disclosed in another embodiment of the present application;

[0053] Figure 3 This is an example diagram of a first relationship diagram disclosed in another embodiment of the present application;

[0054] Figure 4 This is an example diagram of a second relationship diagram disclosed in another embodiment of the present application;

[0055] Figure 5 This is a flowchart of an implementation of step S102 disclosed in another embodiment of the present application;

[0056] Figure 6 This is an example diagram of a first queue disclosed in another embodiment of the present application;

[0057] Figure 7 A schematic diagram of an optimization device for cold start of an application disclosed in another embodiment of the present application;

[0058] Figure 8 A schematic diagram of an electronic device disclosed in another embodiment of the present application. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0060] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0061] Furthermore, in this document, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0062] As can be seen from the background technology, for devices with low versions of the Android system, the Java runtime environment used is the Dalvik virtual machine. Its biggest problem is that after the application is installed or upgraded, the first cold start of the application takes a long time, which takes tens of seconds or even minutes. Users need to face a black screen for a period of time before they can use the APP normally, which seriously affects the user experience.

[0063] In view of this, the present application provides an optimization method, device, electronic device and storage medium for application cold start to solve the problem of slow application cold start in the prior art.

[0064] The present application embodiment discloses an optimization method for cold starting an application, such as Figure 1 As shown, specifically including:

[0065] S101. Construct a first relationship diagram and a second relationship diagram based on an application configuration file; wherein the first relationship diagram is used to represent class structure information corresponding to components of the application configuration file; and the second relationship diagram is used to represent class reference information corresponding to components of the application configuration file.

[0066] It should be noted that the application configuration manifest file of the application is first obtained, which contains the name, version, permissions, components and other information of the application. Then, the first relationship graph and the second relationship graph are constructed based on the component information of the application configuration manifest file; wherein the first relationship graph is used to represent the class structure information corresponding to the components of the application configuration manifest file; and the second relationship graph is used to represent the class reference information corresponding to the components of the application configuration manifest file.

[0067] Optionally, in another embodiment of the present application, an implementation of step S101 is as follows: Figure 2 As shown, it may include:

[0068] S201. Obtain component information of a preset component based on a configuration file.

[0069] Among them, the preset components include Activity component, service component, Provider component and Receiver component.

[0070] It should be noted that based on the manifest configuration file of the application, the component information of the four major components, namely, the Activity component, the service component, the Provider component and the Receiver component, is obtained.

[0071] Among them, the Activity component is the most basic and most commonly used component in Android. It provides a screen that users can interact with to complete a task. Each Activity is implemented as an independent class and inherits from the Activity base class. Activities communicate with each other through Intent.

[0072] The Service component is a solution for running programs in the background in Android. It is usually used to perform tasks that do not require user interaction. Service has two states: Started and Bound. The Started state is started by other components, while the Bound state is bound to other components. The operation of the Service does not depend on the user interface. Even if the program switches to the background, the Service can still keep running.

[0073] The Receive component is used to process system broadcasts, such as detecting changes in the phone's battery level. It can receive broadcast messages from the system or applications and perform corresponding operations.

[0074] The Provider component is used to implement data sharing between different applications. Each application has its own data space, and other applications can access and operate shared data.

[0075] S202: Based on the component information, the class structure in the preset component is parsed, and the class index and dependency are established according to the class structure to generate a first relationship graph.

[0076] It should be noted that the four major component entries related to the application configuration manifest file are traversed, and the class structure in the preset component is parsed according to the parent class, extension, and static relationship, and the class index and dependency are established according to the class structure, and the first relationship diagram is mapped and generated, such as Figure 3 As shown. Each node in the first relationship graph should have at least the following information:

[0077] Dictionary table of signature characters to Class, Field and Method structures;

[0078] The Class structure contains a list of all inherited and implemented parent Class structures;

[0079] The Class structure contains a list of all referenced String constants;

[0080] The Class structure contains a list of all referenced constant Methods.

[0081] S203: Based on the component information, parse the class references in the preset component, and establish class indexes and dependencies according to the class references to generate a second relationship graph.

[0082] It should be noted that based on the four major component entries related to the application configuration manifest file, only the class references in the preset components are parsed, and the class index and dependency are established according to the class references to generate the second relationship diagram, such as Figure 4 As shown. Each node in the second relationship graph has at least the following information:

[0083] Dictionary table of signature characters to Class, Field and Method structures;

[0084] The Class structure contains a list of all referenced Type structures, where Type is PrimitiveType and Class.

[0085] S102: Based on the first relationship graph and the second relationship graph, filter out high-frequency classes of the application according to the access frequency of the classes, and pack the high-frequency classes into a main dex file.

[0086] It should be noted that, based on the constructed first relationship graph and second relationship graph, the high-frequency classes of the application, that is, the classes with higher access frequency, are screened out according to the access frequency of the class. And the screened high-frequency classes are packaged into the main dex file. The dex file is an executable file format unique to the Android system, which is mainly used to carry the core instructions and data of the application. It is not only a core component of the Android application, but also carries the key instructions and data when the program is running. The dex file provides strong support for the efficient operation of Android applications through its unique file format and optimization technology. In general, an application will contain multiple dex files, such as classes1.dex (main dex), classes2.dex, classes3.dex, and classes4.dex. Among them, the first dex file is the main dex file, and classes2.dex, classes3.dex, classes4.dex, etc. are secondary dex files. Among them, there is only one main dex file, and there can be one or more secondary dex files.

[0087] Optionally, in another embodiment of the present application, an implementation of step S102 is as follows: Figure 5 As shown, it may include:

[0088] S501 , traverse the first relationship graph and the second relationship graph respectively to obtain the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph.

[0089] It should be noted that the first relationship graph and the second relationship graph are traversed according to the breadth-first algorithm to obtain the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph. For example, the four major components Activity category has classes activity_1 to activity_n, the Service category has classes service_1 to service_n, and similarly, Provider has classes provider_1 to provider_n, and Receiver has classes receiver_1 to receiver_n, and the access frequency of each class is obtained respectively.

[0090] S502: Put each class in the first relationship graph into a first queue in descending order of access frequency.

[0091] It should be noted that a first queue is constructed, and each class in the first relationship graph is placed in the first queue in descending order of access frequency. In this queue, the higher the access frequency, the higher the ranking. For example Figure 6 shown.

[0092] S503: Put each class in the second relationship graph into the second queue in descending order of access frequency.

[0093] It should be noted that a second queue is constructed, and each class in the second relationship graph is placed in the second queue in descending order of access frequency. In this queue, the higher the access frequency, the higher the ranking.

[0094] S504: Based on the first queue and the second queue, classes whose access frequencies meet preset conditions are screened out, and the screened out classes are packaged into a main dex file.

[0095] It should be noted that the first queue and the second queue are traversed to filter out the top k classes with the highest access frequency, and the filtered classes are packaged into the main dex file. Among them, k can be set according to actual conditions, such as the maximum number of methods that the main dex file can accommodate.

[0096] Optionally, in another embodiment of the present application, an implementation of step S504 may include;

[0097] Perform a deep traversal on the first queue. If the number of methods of the traversed class is equal to a preset threshold and the traversal of the first queue has not been completed, stop the traversal and pack the traversed classes in the first queue into the main dex file; the threshold is the maximum number of methods that the main dex file can accommodate.

[0098] If the number of methods of the traversed classes is less than the threshold and the traversal of the first queue has been completed, a depth traversal is performed on the second queue, and the difference between the threshold and the number of methods of the classes of the first queue is calculated.

[0099] If the number of methods of the class traversed by the second queue is equal to the difference and the second queue has not completed the traversal, the traversal is stopped, and the traversed classes in the first queue and the traversed classes in the second queue are packaged into the main dex file.

[0100] If the number of methods of the class traversed by the second queue is less than the difference and the traversal of the second queue has been completed, the traversal is stopped, and the traversed classes in the first queue and the traversed classes in the second queue are packaged into the main dex file.

[0101] It should be noted that the first queue must be deeply traversed to traverse the first to n levels of dependencies. If the number of methods of the traversed class is equal to the preset threshold and the traversal of the first queue has not been completed, the traversal will be stopped, the remaining classes will not be traversed, and the traversed classes in the first queue will be packaged into the main dex file. Among them, the threshold is set to the maximum number of methods that the main dex file can accommodate. If the number of methods of the traversed class is less than the threshold and the traversal of the first queue has been completed, the second queue will continue to be deeply traversed, and the difference between the threshold and the number of methods of the class in the first queue will be calculated. If the number of methods of the class traversed by the second queue is equal to the difference and the traversal of the second queue has not been completed, the traversal will be stopped, the remaining classes will not be traversed, and the traversed classes in the first queue and the traversed classes in the second queue will be packaged into the main dex file. If the number of methods of the class traversed by the second queue is less than the difference and the second queue has completed the traversal, the traversal is stopped, and the traversed classes in the first queue and the traversed classes in the second queue are packaged into the main dex file.

[0102] S103. Pack non-high-frequency classes into a secondary dex file; wherein the non-high-frequency classes are classes other than high-frequency classes in the application.

[0103] It should be noted that when high-frequency classes are packaged into the main dex file, the remaining non-high-frequency classes are packaged into secondary dex files. Among them, non-high-frequency classes are classes other than high-frequency classes in the application, and secondary dex files are dex files other than the main dex file, such as classes2.dex, classes3.dex, classes4.dex, etc.

[0104] S104: When the application is cold started, the primary dex file is loaded, and after the application is cold started, the secondary dex file is loaded.

[0105] It should be noted that when the application is cold started, only the main dex file is loaded, and the secondary dex file is not loaded. The secondary dex file is loaded after the application cold start is completed. Since the high-frequency classes are packaged into the main dex file, it can ensure that the business scenarios commonly used by users during cold start can be covered in the main dex file, and only the main dex file is loaded during the application startup phase, which reduces the loading time and speeds up the application cold start.

[0106] In an optimization method for cold start of an application provided by the present application, a first relationship graph and a second relationship graph are first constructed based on the configuration file of the application; wherein the first relationship graph is used to characterize the class structure information corresponding to the components of the application configuration file; and the second relationship graph is used to characterize the class reference information corresponding to the components of the application configuration file. Then, based on the first relationship graph and the second relationship graph, the high-frequency classes of the application are screened out according to the access frequency of the first cold start scenario class counted by the online version, and the high-frequency classes are packaged into the main dex file. And the non-high-frequency classes are packaged into the secondary dex file. Finally, when the application is cold started, only the main dex file needs to be loaded, and the secondary dex file is loaded after the cold start of the application is completed. It can be seen that, using the method of the present application, by packaging the high-frequency classes into the main dex file, it is ensured that the business scenarios commonly used by users during cold start can be covered in the main dex file, and only the main dex file is loaded during the application startup phase, which reduces the loading time and speeds up the cold start of the application. The problem of slow cold start of applications in the prior art is solved.

[0107] Another embodiment of the present application also provides an optimization device for cold starting an application, such as Figure 7 As shown, including:

[0108] The construction unit 701 is used to construct a first relationship diagram and a second relationship diagram based on the application configuration file; wherein the first relationship diagram is used to represent the class structure information corresponding to the components of the application configuration file; and the second relationship diagram is used to represent the class reference information corresponding to the components of the application configuration file.

[0109] The screening unit 702 is used to screen out high-frequency classes of the application according to the access frequency of the classes based on the first relationship graph and the second relationship graph, and pack the high-frequency classes into the main dex file.

[0110] The packaging unit 703 is used to package the non-high-frequency classes into the secondary dex file; wherein the non-high-frequency classes are classes other than the high-frequency classes in the application.

[0111] The loading unit 704 is used to load the primary dex file when the application is cold started, and then load the secondary dex file after the application is cold started.

[0112] In this embodiment, the specific execution process of the construction unit 701, the screening unit 702, the packaging unit 703 and the loading unit 704 can be referred to the corresponding Figure 1 The content of the method embodiment will not be repeated here.

[0113] In an optimization device for cold start of an application provided by the present application, first, a construction unit 701 constructs a first relationship graph and a second relationship graph based on the configuration file of the application; wherein the first relationship graph is used to characterize the class structure information corresponding to the components of the application configuration file; and the second relationship graph is used to characterize the class reference information corresponding to the components of the application configuration file. Then, based on the first relationship graph and the second relationship graph, the screening unit 702 screens out the high-frequency classes of the application according to the access frequency of the first cold start scenario class counted by the online version, and packages the high-frequency classes into the main dex file. The packaging unit 703 packages the non-high-frequency classes into the secondary dex file. Finally, when the application is cold started, the loading unit 704 loads the main dex file until the application cold start is completed, and then loads the secondary dex file. It can be seen that, using the method of the present application, by packaging the high-frequency classes into the main dex file, it is ensured that the business scenarios commonly used by users during cold start can be covered in the main dex file, and only the main dex file is loaded in the application startup phase, which reduces the loading time and speeds up the cold start of the application. The problem of slow cold start of applications in the prior art is solved.

[0114] Optionally, in another embodiment of the present application, an implementation of the above-mentioned construction unit 701 may include:

[0115] The acquisition subunit is used to obtain component information of preset components based on the configuration file; wherein the preset components include Activity components, service components, Provider components and Receiver components.

[0116] The first generating subunit is used to parse the class structure in the preset component based on the component information, and to establish the index and dependency of the class according to the class structure to generate a first relationship graph.

[0117] The second generating subunit is used to parse the class reference in the preset component based on the component information, and to establish the index and dependency of the class according to the class reference to generate a second relationship graph.

[0118] In this embodiment, the specific execution process of the acquisition subunit, the first generation subunit and the second generation subunit can be referred to in the corresponding Figure 2 The contents of the embodiments will not be repeated here.

[0119] Optionally, in another embodiment of the present application, an implementation of the screening unit 702 may include:

[0120] The first traversal subunit is used to traverse the first relationship graph and the second relationship graph respectively to obtain the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph.

[0121] The first queue construction subunit is used to put each class in the first relationship graph into the first queue in descending order of the access frequency in the first cold start scenario.

[0122] The second queue construction subunit is used to put each class in the second relationship graph into the second queue in descending order of the access frequency in the first cold start scenario.

[0123] The screening subunit is used to screen out classes whose access frequencies meet preset conditions based on the first queue and the second queue, and pack the screened classes into the main dex file.

[0124] In this embodiment, the specific execution process of the first traversal subunit, the first queue construction subunit, the second queue construction subunit and the screening subunit can be referred to in the corresponding Figure 5 The contents of the embodiments will not be repeated here.

[0125] Optionally, in another embodiment of the present application, an implementation of the above screening subunit may include:

[0126] The second traversal sub-unit is used to perform a deep traversal on the first queue. If the number of methods of the traversed class is equal to a preset threshold and the traversal of the first queue has not been completed, the traversal is stopped and the traversed classes in the first queue are packaged into the main dex file; wherein the threshold is the maximum number of methods that the main dex file can accommodate.

[0127] The third traversal subunit is used to perform a deep traversal on the second queue if the number of methods of the traversed class is less than a threshold and the traversal of the first queue has been completed, and calculate the difference between the threshold and the number of methods of the class of the first queue.

[0128] The fourth traversal subunit is used to stop traversal if the number of methods of the class traversed by the second queue is equal to the difference and the second queue has not completed the traversal, and pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file.

[0129] The fifth traversal subunit is used to stop traversal if the number of methods of the class traversed by the second queue is less than the difference and the second queue has completed traversal, and pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file.

[0130] In this embodiment, the specific execution process of the second traversal subunit, the third traversal subunit, the fourth traversal subunit and the fifth traversal subunit can be found in the corresponding method embodiments described above, and will not be repeated here.

[0131] Another embodiment of the application also provides an electronic device, such as Figure 8 As shown, specifically including:

[0132] One or more processors 801.

[0133] The storage device 802 stores one or more programs.

[0134] When one or more programs are executed by one or more processors 801 , the one or more processors 801 implement any one of the methods in the above embodiments.

[0135] Another embodiment of the present application further provides a computer storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, any one of the methods in the above embodiments is implemented.

[0136] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0137] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0138] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for optimizing application cold start, characterized in that: include: Constructing a first relationship graph and a second relationship graph based on the application configuration file; wherein the first relationship graph is used to represent the class structure information corresponding to the components of the application configuration file; and the second relationship graph is used to represent the class reference information corresponding to the components of the application configuration file; Based on the first relationship graph and the second relationship graph, filter out high-frequency classes of the application according to the access frequency of the classes, and pack the high-frequency classes into a main dex file; Packing non-high-frequency classes into a secondary dex file; wherein the non-high-frequency classes are classes in the application other than the high-frequency classes; When the application is cold started, the primary dex file is loaded, and after the application is cold started, the secondary dex file is loaded.

2. The method according to claim 1, characterized in that The step of constructing the first relationship graph and the second relationship graph based on the configuration file of the application includes: Based on the configuration file, obtaining component information of the preset component; Based on the component information, the class structure in the preset component is parsed, and class indexes and dependencies are established according to the class structure to generate the first relationship graph; Based on the component information, the class references in the preset component are parsed, and class indexes and dependencies are established according to the class references to generate the second relationship graph.

3. The method according to claim 1, characterized in that The filtering out the high-frequency classes of the application according to the access frequency of the classes based on the first relationship graph and the second relationship graph, and packaging the high-frequency classes into the main dex file, includes: Traversing the first relationship graph and the second relationship graph respectively, obtaining the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph; Put each class in the first relationship graph into a first queue in descending order of access frequency; Put each class in the second relationship graph into the second queue in descending order of access frequency; Based on the first queue and the second queue, classes whose access frequencies meet preset conditions are screened out, and the screened classes are packaged into the main dex file.

4. The method according to claim 3, characterized in that The filtering out classes meeting preset conditions based on the first queue and the second queue, and packaging the filtered classes into the main dex file, includes: Performing a deep traversal on the first queue, if the number of methods of the traversed class is equal to a preset threshold and the traversal of the first queue has not been completed, stopping the traversal and packaging the traversed classes in the first queue into the main dex file; wherein the threshold is the maximum number of methods that the main dex file can accommodate; If the number of methods of the classes that have completed the traversal is less than the threshold and the first queue has completed the traversal, perform a deep traversal on the second queue and calculate the difference between the threshold and the number of methods of the classes of the first queue; If the number of methods of the class traversed by the second queue is equal to the difference and the traversal of the second queue has not been completed, stop the traversal and pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file; If the number of methods of the class traversed by the second queue is less than the difference and the traversal of the second queue has been completed, the traversal is stopped, and the traversed classes in the first queue and the traversed classes in the second queue are packaged into the main dex file.

5. An optimization device for application cold start, characterized in that: include: A construction unit, configured to construct a first relationship graph and a second relationship graph based on a configuration file of an application; wherein the first relationship graph is used to represent class structure information corresponding to components of the application configuration file; and the second relationship graph is used to represent class reference information corresponding to components of the application configuration file; A screening unit, configured to screen out high-frequency classes of the application according to the access frequency of the classes based on the first relationship graph and the second relationship graph, and pack the high-frequency classes into a main dex file; A packaging unit, used to package non-high-frequency classes into a secondary dex file; wherein the non-high-frequency classes are classes in the application other than the high-frequency classes; The loading unit is used to load the primary dex file when the application is cold started, and then load the secondary dex file after the application is cold started.

6. The device according to claim 5, characterized in that The construction unit comprises: An acquisition subunit, used for acquiring component information of a preset component based on the configuration file; A first generating subunit is used to parse the class structure in the preset component based on the component information, and establish the index and dependency of the class according to the class structure to generate the first relationship graph; The second generating subunit is used to parse the class reference in the preset component based on the component information, and establish the class index and dependency according to the class reference to generate the second relationship graph.

7. The device according to claim 5, characterized in that The screening unit comprises: A first traversal subunit is used to traverse the first relationship graph and the second relationship graph respectively to obtain the access frequency of each class in the first relationship graph and the access frequency of each class in the second relationship graph; A first queue construction subunit is used to put each class in the first relationship graph into a first queue in descending order of access frequency; A second queue construction subunit is used to put each class in the second relationship graph into the second queue in descending order of access frequency; The screening subunit is used to screen out classes whose access frequencies meet preset conditions based on the first queue and the second queue, and pack the screened classes into the main dex file.

8. The device according to claim 7, characterized in that The screening subunit comprises: A second traversal subunit is used to perform a deep traversal on the first queue. If the number of methods of the traversed class is equal to a preset threshold and the traversal of the first queue has not been completed, the traversal is stopped, and the traversed classes in the first queue are packaged into the main dex file; wherein the threshold is the maximum number of methods that the main dex file can accommodate; A third traversal subunit is used for performing a deep traversal on the second queue and calculating a difference between the threshold and the number of methods of the class of the first queue if the number of methods of the class that has completed the traversal is less than the threshold and the traversal of the first queue has been completed; a fourth traversal subunit, configured to stop traversal if the number of methods of the classes traversed by the second queue is equal to the difference and the traversal of the second queue has not been completed, and to pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file; The fifth traversal sub-unit is used to stop traversal if the number of methods of the class traversed by the second queue is less than the difference and the traversal of the second queue has been completed, and to pack the traversed classes in the first queue and the traversed classes in the second queue into the main dex file.

9. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 4.

10. A computer storage medium, characterized in that: A computer program is stored thereon, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Multi-subpackage application cold start optimization method and device

    CN112035176A

  • Application installation package generation method and device, application loading method and device, and electronic equipment

    CN113296826A

  • Streaming micro-service loading verification method based on DEX file class

    CN114924809A

  • Real time information feed processing

    US20110029636A1

  • System and method for fast boot of computer

    US20110252371A1