[go: up one dir, main page]

CN119621191A - Application cold start optimization method, device, electronic device and storage medium - Google Patents

Application cold start optimization method, device, electronic device and storage medium Download PDF

Info

Publication number
CN119621191A
CN119621191A CN202411832784.4A CN202411832784A CN119621191A CN 119621191 A CN119621191 A CN 119621191A CN 202411832784 A CN202411832784 A CN 202411832784A CN 119621191 A CN119621191 A CN 119621191A
Authority
CN
China
Prior art keywords
class
queue
traversed
classes
application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202411832784.4A
Other languages
Chinese (zh)
Other versions
CN119621191B (en
Inventor
罗叶飞
屈淼
胡奕涵
贺子悦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan MgtvCom Interactive Entertainment Media Co Ltd
Original Assignee
Hunan MgtvCom Interactive Entertainment Media Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan MgtvCom Interactive Entertainment Media Co Ltd filed Critical Hunan MgtvCom Interactive Entertainment Media Co Ltd
Priority to CN202411832784.4A priority Critical patent/CN119621191B/en
Publication of CN119621191A publication Critical patent/CN119621191A/en
Application granted granted Critical
Publication of CN119621191B publication Critical patent/CN119621191B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

本申请提供了一种应用冷启动的优化方法、装置、电子设备及存储介质。其中,在应用冷启动的优化方法中,基于应用的配置文件构建第一关系图和第二关系图。然后基于第一关系图和第二关系图,按照类的访问频率筛选出应用的高频类,并将高频类打包进主dex文件中。以及将非高频类打包进行次dex文件中。最后在应用冷启动时,则加载主dex文件,直至应用冷启动完成后,加载次dex文件。由此可知,利用本申请的方法,通过将高频类打包进主dex文件中,确保冷启动时用户常用的业务场景都能在主dex文件中覆盖到,并且在应用启动阶段仅加载主dex文件,减少加载时间,加快应用冷启动的速度。解决了现有技术中应用冷启动较慢的问题。

The present application provides an optimization method, device, electronic device and storage medium for cold start of an application. Among them, in the optimization method for cold start of an application, a first relationship graph and a second relationship graph are constructed based on the configuration file of the application. 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 after the cold start of the application is completed, the secondary dex file is loaded. 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.

Description

Optimization method and device for application cold start, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an optimization method and apparatus for cold start application, an electronic device, and a storage medium.
Background
Along with development of science and technology, intelligent terminal products are becoming more and more popular, wherein a large number of intelligent terminals adopt an android system.
For a low version of the android device, the Java runtime environment employed is a Dalvik virtual machine. The biggest problem is that after the application is installed or updated, the application is started in a cold mode for the first time, the time is long, tens of seconds or even minutes are needed, a user needs to face a period of black screen to normally use the APP, and user experience is seriously affected.
Disclosure of Invention
In view of the above, the present application provides an optimization method, an apparatus, an electronic device and a storage medium for applying cold start, so as to solve the problem of slower cold start of the application in the prior art.
In order to achieve the above purpose, the present application provides the following technical solutions:
the first aspect of the application discloses an optimization method for cold start application, which comprises the following steps:
Constructing a first relation diagram and a second relation diagram based on the configuration file of the application, wherein the first relation diagram is used for representing class structure information corresponding to the components of the application configuration file;
Based on the first relation diagram and the second relation diagram, screening out the high-frequency class of the application according to the access frequency of the class, and packaging the high-frequency class into a main dex file;
Packaging non-high frequency classes into a secondary dex file, wherein the non-high frequency classes are classes except the high frequency classes in the application;
And when the application is started in a cold mode, loading the main dex file until the application is started in a cold mode, and loading the secondary dex file.
Optionally, in the above method, the constructing the first relationship graph and the second relationship graph based on the application configuration file includes:
Acquiring component information of a preset component based on the configuration file;
Analyzing a class structure in the preset component based on the component information, and establishing an index and a dependence of a class according to the class structure to generate the first relation diagram;
analyzing class references in the preset components based on the component information, and establishing indexes and dependencies of the classes according to the class references to generate the second relation diagram.
Optionally, in the above method, the screening the high-frequency class of the application according to the access frequency of the class based on the first relationship diagram and the second relationship diagram, and packing the high-frequency class into a main dex file includes:
traversing the first relation diagram and the second relation diagram respectively to acquire the access frequency of each class in the first relation diagram and the access frequency of each class in the second relation diagram;
placing each class in the first relation diagram into a first queue according to the order of the access frequency from high to low;
placing each class in the second relation diagram into a second queue according to the order of the access frequency from high to low;
And screening out classes with access frequency meeting preset conditions based on the first queue and the second queue, and packaging the screened classes into the main dex file.
Optionally, in the above method, the screening the class meeting the preset condition based on the first queue and the second queue, and packing the screened class into the master dex file includes:
performing depth traversal on the first queue, stopping the traversal and packing the traversed class in the first queue into the main dex file if the number of the traversed class is equal to a preset threshold value and the first queue does not complete the traversal, wherein the threshold value is the maximum number of methods which can be accommodated by the main dex file;
If the number of the methods for completing the traversed classes is smaller than the threshold value and the first queue is traversed, performing depth traversal on the second queue, and calculating to obtain a difference value between the threshold value and the number of the methods for completing the traversed classes of the first queue;
Stopping traversing if the number of the traversed classes in the second queue is equal to the difference value and the second queue does not complete traversing, and packaging the traversed classes in the first queue and the traversed classes in the second queue into the main dex file;
And if the number of the methods of the traversed classes of the second queue is smaller than the difference value and the second queue is traversed, stopping traversing, and packaging the traversed classes in the first queue and the traversed classes in the second queue into the main dex file.
The second aspect of the present application discloses an optimizing device for cold start application, comprising:
The system comprises a construction unit, a first relation graph and a second relation graph, wherein the construction unit is used for constructing a first relation graph and a second relation graph based on an application configuration file, the first relation graph is used for representing class structure information corresponding to a component of the application configuration file, and the second relation graph is used for representing class reference information corresponding to the component of the application configuration file;
The screening unit is used for screening the high-frequency class of the application according to the access frequency of the class based on the first relation diagram and the second relation diagram, and packaging the high-frequency class into a main dex file;
The packaging unit is used for packaging non-high-frequency classes into a secondary dex file, wherein the non-high-frequency classes are classes except the high-frequency classes in the application;
and the loading unit is used for loading the main dex file when the application is cold started until the application is cold started, and loading the secondary dex file.
Optionally, the above apparatus, the building unit includes:
The acquisition subunit is used for acquiring the component information of the preset component based on the configuration file;
the first generation subunit is used for analyzing the class structure in the preset component based on the component information, establishing class indexes and dependencies according to the class structure and generating the first relation diagram;
And the second generation subunit is used for analyzing the class references in the preset component based on the component information, establishing indexes and dependencies of the classes according to the class references, and generating the second relation graph.
Optionally, in the foregoing apparatus, the screening unit includes:
The first traversing subunit is used for traversing the first relation diagram and the second relation diagram respectively, and acquiring the access frequency of each class in the first relation diagram and the access frequency of each class in the second relation diagram;
A first queue construction subunit, configured to put each class in the first relationship diagram into a first queue according to an order from high to low of access frequency;
A second queue construction subunit, configured to put each class in the second relationship diagram into a second queue according to an order from high to low of access frequency;
And the screening subunit is used for screening out the classes with access frequency meeting preset conditions based on the first queue and the second queue, and packaging the screened classes into the main dex file.
Optionally, in the foregoing apparatus, the screening subunit includes:
the second traversing subunit is used for performing depth traversing on the first queue, stopping traversing and packing the traversed class in the first queue into the main dex file if the number of the traversed class is equal to a preset threshold value and the first queue does not complete traversing;
A third traversing subunit, configured to, if the number of methods for completing the traversed class is less than the threshold and the first queue has completed traversing, perform depth traversing on the second queue, and calculate to obtain a difference between the threshold and the number of methods for completing the traversed class of the first queue;
A fourth traversing subunit, configured to stop traversing if the number of methods of the traversed class in the second queue is equal to the difference value and the traversed class in the first queue and the traversed class in the second queue are not completed, and package the traversed class in the first queue and the traversed class in the second queue into the main dex file;
And a fifth traversing subunit, configured to stop traversing if the number of methods of the traversed class in the second queue is smaller than the difference value and the traversed class in the second queue is completed, and package the traversed class in the first queue and the traversed class in the second queue into the main dex file.
The third aspect of the present application discloses an electronic device, comprising:
One or more processors;
a storage device having one or more programs stored thereon;
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of the first aspects of the present application.
A fourth aspect of the application discloses a computer storage medium having stored thereon a computer program which, when executed by a processor, implements a method according to any of the first aspects of the application.
According to the technical scheme, in the optimization method for the application cold start, a first relation diagram and a second relation diagram are constructed based on the application configuration file, wherein the first relation diagram is used for representing class structure information corresponding to the components of the application configuration file, and the second relation diagram is used for representing class reference information corresponding to the components of the application configuration file. And then, based on the first relation diagram and the second relation diagram, the high-frequency class of the application is screened out according to the access frequency of the class, and the high-frequency class is packed into the main dex file. And packaging the non-high frequency class into a secondary dex file. And finally, loading the main dex file when the application is started in a cold mode, and sequentially loading other secondary dex files until the application is started in a cold mode. Therefore, by using the method of the application, the service scene commonly used by the user can be covered in the main dex file by packing the high-frequency class into the main dex file, and only the main dex file is loaded in the application starting stage, thereby reducing the loading time and accelerating the application cold starting speed. The problem of the application in prior art that the first cold start is slower is solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an optimization method using cold start disclosed in an embodiment of the present application;
FIG. 2 is a flow chart of one implementation of step S101 disclosed in another embodiment of the present application;
FIG. 3 is an exemplary diagram of a first relationship diagram disclosed in another embodiment of the present application;
FIG. 4 is an exemplary diagram of a second relationship diagram disclosed in another embodiment of the present application;
FIG. 5 is a flow chart of one implementation of step S102 disclosed in another embodiment of the present application;
FIG. 6 is an exemplary diagram of a first queue disclosed in another embodiment of the application;
FIG. 7 is a schematic diagram of an optimizing apparatus using cold start according to another embodiment of the present application;
Fig. 8 is a schematic diagram of an electronic device according to another embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the present disclosure, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
Moreover, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
As known from the background technology, for a device with a low version of the android system, the adopted Java running environment is a Dalvik virtual machine. The biggest problem is that after the application is installed or updated, the application is started in a cold mode for the first time, the time is long, tens of seconds or even minutes are needed, a user needs to face a period of black screen to normally use the APP, and user experience is seriously affected.
In view of the above, the application provides an optimization method, an apparatus, an electronic device and a storage medium for applying cold start, so as to solve the problem of slower application cold start in the prior art.
The embodiment of the application discloses an optimization method for cold start application, which is shown in fig. 1 and specifically comprises the following steps:
s101, constructing a first relation diagram and a second relation diagram based on an application configuration file, wherein the first relation diagram is used for representing class structure information corresponding to a component of the application configuration file, and the second relation diagram is used for representing class reference information corresponding to the component of the application configuration file.
It should be noted that, firstly, an application configuration manifest file of an application is obtained, which includes information such as a name, version, authority, component, etc. of the application. And then constructing a first relation diagram and a second relation diagram based on the component information of the application configuration manifest file, wherein the first relation diagram is used for representing class structure information corresponding to the component of the application configuration manifest file, and the second relation diagram is used for representing class reference information corresponding to the component of the application configuration manifest file.
Alternatively, in another embodiment of the present application, an implementation manner of step S101, as shown in fig. 2, may include:
S201, acquiring component information of a preset component based on a configuration file.
The preset component comprises an Activity component, a service component, a Provider component and a Receiver component.
It should be noted that, based on the application's manifest configuration file, component information of four large components, i.e., an Activity component, a service component, a Provider component, and a Receiver component, is obtained.
The Activity component is the most basic and most commonly used component in ‌ Android, and provides a screen that a user can use to interact with to complete a task. Each Activity is implemented as a separate class and inherits from the Activity base class. The activities communicate with each other through the Intent.
The Service component is a solution for implementing program background running in Android, which is typically used to perform tasks that do not require interaction with users. Service has two states, started and Bound. The Started state is initiated by the other component, while the Bound state is Bound by the other component. Service is not dependent on the user interface in operation, and Service can still remain operational even if the program switches to the background.
The Receive component is used to process system broadcasts, such as detecting changes in the power of a cell phone. It may receive broadcast messages from a system or application and perform corresponding operations.
The Provider component is used to enable data sharing between different applications. Each application has its own data space and other applications can access and manipulate shared data.
S202, analyzing a class structure in a preset component based on component information, and establishing an index and a dependence of the class according to the class structure to generate a first relation diagram.
It should be noted that, traversing the four component entries related to the application configuration manifest file, analyzing the class structure in the preset component according to the parent class, expansion and static relation, and establishing the index and the dependence of the class according to the class structure, and mapping to generate a first relation diagram, as shown in fig. 3. The first relationship graph should have at least the following information in each node:
Signing characters to a dictionary table of Class, field and Method structures;
the Class structure comprises a parent Class structure list of all inheritance and realization;
the Class structure comprises a String constant list which is all referenced;
The Class structure contains a list of all referenced constant methods.
S203, analyzing class references in the preset components based on the component information, and establishing indexes and dependencies of the classes according to the class references to generate a second relation diagram.
It should be noted that, based on the four component entries related to the application configuration manifest file, only the class references in the preset components are resolved, and the class indexes and dependencies are established according to the class references, so as to generate a second relationship diagram, as shown in fig. 4. Each node in the second relationship graph has at least the following information:
Signing characters to a dictionary table of Class, field and Method structures;
The Class structure contains a list of all the referenced types, which are PRIMITIVETYPE and Class.
S102, based on the first relation diagram and the second relation diagram, the applied high-frequency class is screened out according to the access frequency of the class, and the high-frequency class is packed into the main dex file.
Based on the first relation diagram and the second relation diagram, the high-frequency class of the application, namely the class with higher access frequency, is screened out according to the access frequency of the class. And packaging the screened high-frequency class into a main dex file. The dex file is an executable file format specific to the Android system and is mainly used for bearing core instructions and data of application programs. ‌ is not only a core component of the Android application program, but also carries key instructions and data during program running. The dex file provides powerful support for efficient operation of the Android application program through the unique file format and the optimization technology. Typically, an application will contain multiple dex files, such as class1. Dex (primary dex), class2. Dex, class3. Dex, class4. Dex, where the first dex file is the primary dex file and class2. Dex, class3. Dex, class4. Dex, etc. are the secondary dex files. Wherein, there is only one primary dex file, and there may be one or more secondary dex files.
Alternatively, in another embodiment of the present application, an implementation manner of step S102, as shown in fig. 5, may include:
s501, traversing the first relation diagram and the second relation diagram respectively, and obtaining the access frequency of each class in the first relation diagram and the access frequency of each class in the second relation diagram.
It should be noted that, the first relationship graph and the second relationship graph are traversed according to the breadth-first algorithm, so as 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-component Activity category includes the class activity_1 to activity_n and the Service category, and the class service_1 to service_n, the similar Provider, the class provider_1 to provider_n and the Receiver category, and the class receiver_1 to receiver_n respectively obtain the access frequency of each class.
S502, each class in the first relation diagram is put into a first queue according to the order of the access frequency from high to low.
It should be noted that, a first queue is constructed, and each class in the first relation diagram is put into the first queue according to the order of the access frequency from high to low. In this queue, the higher the access frequency, the higher the rank, for example as shown in FIG. 6.
S503, placing each class in the second relation diagram into a second queue according to the order of the access frequency from high to low.
It should be noted that, a second queue is constructed, and each class in the second relation diagram is put into the second queue according to the order of the access frequency from high to low. In this queue, the higher the access frequency, the higher the ranking.
S504, screening out classes with access frequency meeting preset conditions based on the first queue and the second queue, and packaging the screened classes into a main dex file.
It should be noted that, traversing the first queue and the second queue, screening out the classes with k names before the access frequency, and packing the screened classes into the main dex file. Wherein k can be set according to practical situations, such as the maximum number of methods which can be accommodated by the main dex file.
Alternatively, in another embodiment of the present application, an implementation of step S504 may include;
And performing depth traversal on the first queue, stopping the traversal if the number of the traversed classes is equal to a preset threshold value and the first queue does not complete the traversal, and packaging the traversed classes in the first queue into a main dex file, wherein the threshold value is the maximum number of methods which can be accommodated by the main dex file.
If the number of the methods for completing the traversed classes is smaller than the threshold value and the first queue has completed the traversed, performing depth traversing on the second queue, and calculating to obtain a difference value between the threshold value and the number of the methods for completing the traversed classes of the first queue.
If the number of the methods of the traversed classes of the second queue is equal to the difference value and the second queue does not complete the traversing, stopping the traversing, and packing the traversed classes in the first queue and the traversed classes in the second queue into a main dex file.
If the number of the methods of the traversed classes of the second queue is smaller than the difference value and the second queue is traversed, stopping traversing, and packaging the traversed classes in the first queue and the traversed classes in the second queue into a main dex file.
It should be noted that, the first queue needs to be traversed from one level to n levels, if the number of the traversed classes is equal to a preset threshold and the first queue does not complete the traversal, the traversal is stopped, the remaining classes are not traversed any more, and the traversed classes in the first queue are packed into the main dex file. Wherein, the threshold is changed to set the maximum number of methods which can be accommodated by the main dex file. If the number of the methods for completing the traversed classes is smaller than the threshold value and the first queue has completed the traversed, continuing to conduct deep traversing on the second queue, and calculating to obtain a difference value between the threshold value and the number of the methods for completing the traversed classes of the first queue. If the number of the methods of the class traversed by the second queue is equal to the difference value and the second queue does not complete the traversal, stopping the traversal of the rest classes, and packing the traversed classes in the first queue and the traversed classes in the second queue into a main dex file. If the number of the methods of the traversed class of the second queue is smaller than the difference value and the second queue has completed traversing, stopping traversing and packing the traversed class in the first queue and the traversed class in the second queue into a main dex file.
S103, packaging the non-high frequency class into a secondary dex file, wherein the non-high frequency class is a class except the high frequency class in the application.
It should be noted that, when the high frequency class is packed into the primary dex file, the remaining non-high frequency class is packed into the secondary dex file. The non-high frequency class is a class except the high frequency class in the application, and the secondary dex file is a dex file except the main dex file, for example, class2. Dex, class3. Dex, class4. Dex, and the like.
S104, loading the main dex file when the application is started in a cold mode until the application is started in a cold mode, and loading the secondary dex file.
When the application cold start is performed, only the main dex file is loaded, and the secondary dex file is not loaded until the application cold start is completed, and then the secondary dex file is loaded. Because the high-frequency class is packed into the main dex file, the service scene commonly used by a user can be covered in the main dex file during cold start, and only the main dex file is loaded in the application start stage, so that the loading time is reduced, and the application cold start speed is increased.
In the optimization method for the application cold start, a first relation diagram and a second relation diagram are constructed based on an application configuration file, wherein the first relation diagram is used for representing class structure information corresponding to a component of the application configuration file, and the second relation diagram is used for representing class reference information corresponding to the component of the application configuration file. And then, based on the first relation diagram and the second relation diagram, the high-frequency class of the application is screened out according to the access frequency of the first cold start scene class counted by the online version, and the high-frequency class is packed into the main dex file. And packaging the non-high frequency class into a secondary dex file. And finally, when the application is started in a cold way, only the main dex file is needed to be loaded until the application is started in a cold way, and then the secondary dex file is loaded. Therefore, by using the method of the application, the service scene commonly used by the user can be covered in the main dex file by packing the high-frequency class into the main dex file, and only the main dex file is loaded in the application starting stage, thereby reducing the loading time and accelerating the application cold starting speed. The problem of the prior art that the application cold start is slower is solved.
Another embodiment of the present application further provides an optimizing apparatus for cold start application, as shown in fig. 7, including:
The construction unit 701 is configured to construct a first relationship diagram and a second relationship diagram based on the configuration file of the application, where the first relationship diagram is used to characterize class structure information corresponding to the component of the application configuration file, and the second relationship diagram is used to characterize class reference information corresponding to the component of the application configuration file.
And a screening unit 702, configured to screen the applied high-frequency class according to the access frequency of the class based on the first relationship diagram and the second relationship diagram, and package the high-frequency class into the main dex file.
And a packing unit 703, configured to pack the non-high frequency class into the secondary dex file, where the non-high frequency class is a class other than the high frequency class in the application.
And a loading unit 704, configured to load the primary dex file when the application is cold started, until the application is cold started, and load the secondary dex file.
In this embodiment, the specific execution of the constructing unit 701, the filtering unit 702, the packaging unit 703 and the loading unit 704 can be referred to in the embodiment of the method corresponding to fig. 1, and will not be described herein again.
In the optimizing device for application cold start, a construction unit 701 firstly constructs a first relation diagram and a second relation diagram based on an application configuration file, wherein the first relation diagram is used for representing class structure information corresponding to a component of the application configuration file, and the second relation diagram is used for representing class reference information corresponding to the component of the application configuration file. Then, the screening unit 702 screens out the applied high-frequency class according to the access frequency of the first cold start scene class counted by the online version based on the first relation graph and the second relation graph, and packages the high-frequency class into the main dex file. The packing unit 703 packs the non-high frequency class into a secondary dex file. Finally, the loading unit 704 loads the main dex file when the application is cold started, until the application is cold started, and loads the secondary dex file. Therefore, by using the method of the application, the service scene commonly used by the user can be covered in the main dex file by packing the high-frequency class into the main dex file, and only the main dex file is loaded in the application starting stage, thereby reducing the loading time and accelerating the application cold starting speed. The problem of the prior art that the application cold start is slower is solved.
Alternatively, in another embodiment of the present application, an implementation manner of the above-mentioned construction unit 701 may include:
the device comprises an acquisition subunit, a configuration file acquisition subunit, a storage subunit and a storage subunit, wherein the acquisition subunit is used for acquiring component information of a preset component based on the configuration file, and the preset component comprises an Activity component, a service component, a Provider component and a Receiver component.
The first generation subunit is used for analyzing the class structure in the preset component based on the component information, establishing the index and the dependence of the class according to the class structure, and generating a first relation diagram.
The second generating subunit is used for analyzing the class references in the preset component based on the component information, establishing indexes and dependencies of the classes according to the class references, and generating a second relation graph.
In this embodiment, the specific execution process of the acquiring subunit, the first generating subunit, and the second generating subunit may refer to the content corresponding to the embodiment of fig. 2, and will not be described herein again.
Alternatively, in another embodiment of the present application, an implementation manner of the above screening unit 702 may include:
The first traversing subunit is configured to traverse the first relationship graph and the second relationship graph respectively, and obtain an access frequency of each class in the first relationship graph and an access frequency of each class in the second relationship graph.
And the first queue construction subunit is used for placing each class in the first relation diagram into the first queue according to the sequence from high to low of the first cold start scene access frequency.
And the second queue construction subunit is used for placing each class in the second relation diagram into the second queue according to the sequence from high to low of the first cold start scene access frequency.
And the screening subunit is used for screening out the classes with access frequencies meeting preset conditions based on the first queue and the second queue, and packaging the screened classes into a main dex file.
In this embodiment, the specific execution process of the first traversing subunit, the first queue constructing subunit, the second queue constructing subunit, and the screening subunit may refer to the content corresponding to the embodiment of fig. 5, and will not be described herein again.
Optionally, in another embodiment of the present application, an implementation manner of the above screening subunit may include:
And the second traversing subunit is used for carrying out deep traversing on the first queue, stopping traversing and packing the traversed class in the first queue into a main dex file if the number of the traversed class methods is equal to a preset threshold value and the first queue does not complete traversing, wherein the threshold value is the maximum number of the traversed methods which can be contained in the main dex file.
And the third traversing subunit is used for performing deep traversing on the second queue if the number of the methods for completing the traversed classes is smaller than the threshold value and the first queue has completed traversing, and calculating to obtain a difference value between the threshold value and the number of the methods for completing the traversed classes of the first queue.
And the fourth traversing subunit is used for stopping traversing if the number of the methods of the traversed class in the second queue is equal to the difference value and the second queue does not complete traversing, and packaging the traversed class in the first queue and the traversed class in the second queue into a main dex file.
And the fifth traversing subunit is used for stopping traversing if the number of the methods of the traversed class of the second queue is smaller than the difference value and the second queue has completed traversing, and packaging the traversed class in the first queue and the traversed class in the second queue into a main dex file.
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 may refer to the content corresponding to the embodiment of the method described above, which is not described herein again.
Another embodiment of the present application further provides an electronic device, as shown in fig. 8, specifically including:
one or more processors 801.
A storage device 802 on which one or more programs are stored.
The one or more programs, when executed by the one or more processors 801, cause the one or more processors 801 to implement the methods of any of the embodiments described above.
Another embodiment of the present application also provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a method according to any of the above embodiments.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for a system or system embodiment, since it is substantially similar to a method embodiment, the description is relatively simple, with reference to the description of the method embodiment being made in part. The systems and system embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. An optimization method for applying cold start, comprising:
Constructing a first relation diagram and a second relation diagram based on the configuration file of the application, wherein the first relation diagram is used for representing class structure information corresponding to the components of the application configuration file;
Based on the first relation diagram and the second relation diagram, screening out the high-frequency class of the application according to the access frequency of the class, and packaging the high-frequency class into a main dex file;
Packaging non-high frequency classes into a secondary dex file, wherein the non-high frequency classes are classes except the high frequency classes in the application;
And when the application is started in a cold mode, loading the main dex file until the application is started in a cold mode, and loading the secondary dex file.
2. The method of claim 1, wherein constructing the first and second relationship graphs based on the application-based profile comprises:
Acquiring component information of a preset component based on the configuration file;
Analyzing a class structure in the preset component based on the component information, and establishing an index and a dependence of a class according to the class structure to generate the first relation diagram;
analyzing class references in the preset components based on the component information, and establishing indexes and dependencies of the classes according to the class references to generate the second relation diagram.
3. The method of claim 1, wherein the screening the high frequency class of the application according to the access frequency of the class based on the first relationship diagram and the second relationship diagram, and packaging the high frequency class into a main dex file, comprises:
traversing the first relation diagram and the second relation diagram respectively to acquire the access frequency of each class in the first relation diagram and the access frequency of each class in the second relation diagram;
placing each class in the first relation diagram into a first queue according to the order of the access frequency from high to low;
placing each class in the second relation diagram into a second queue according to the order of the access frequency from high to low;
And screening out classes with access frequency meeting preset conditions based on the first queue and the second queue, and packaging the screened classes into the main dex file.
4. The method of claim 3, wherein screening out classes meeting a preset condition based on the first queue and the second queue, and packaging the screened classes into the master dex file, comprises:
performing depth traversal on the first queue, stopping the traversal and packing the traversed class in the first queue into the main dex file if the number of the traversed class is equal to a preset threshold value and the first queue does not complete the traversal, wherein the threshold value is the maximum number of methods which can be accommodated by the main dex file;
If the number of the methods for completing the traversed classes is smaller than the threshold value and the first queue is traversed, performing depth traversal on the second queue, and calculating to obtain a difference value between the threshold value and the number of the methods for completing the traversed classes of the first queue;
Stopping traversing if the number of the traversed classes in the second queue is equal to the difference value and the second queue does not complete traversing, and packaging the traversed classes in the first queue and the traversed classes in the second queue into the main dex file;
And if the number of the methods of the traversed classes of the second queue is smaller than the difference value and the second queue is traversed, stopping traversing, and packaging the traversed classes in the first queue and the traversed classes in the second queue into the main dex file.
5. An optimization device for applying cold start, comprising:
The system comprises a construction unit, a first relation graph and a second relation graph, wherein the construction unit is used for constructing a first relation graph and a second relation graph based on an application configuration file, the first relation graph is used for representing class structure information corresponding to a component of the application configuration file, and the second relation graph is used for representing class reference information corresponding to the component of the application configuration file;
The screening unit is used for screening the high-frequency class of the application according to the access frequency of the class based on the first relation diagram and the second relation diagram, and packaging the high-frequency class into a main dex file;
The packaging unit is used for packaging non-high-frequency classes into a secondary dex file, wherein the non-high-frequency classes are classes except the high-frequency classes in the application;
and the loading unit is used for loading the main dex file when the application is cold started until the application is cold started, and loading the secondary dex file.
6. The apparatus of claim 5, wherein the building unit comprises:
The acquisition subunit is used for acquiring the component information of the preset component based on the configuration file;
the first generation subunit is used for analyzing the class structure in the preset component based on the component information, establishing class indexes and dependencies according to the class structure and generating the first relation diagram;
And the second generation subunit is used for analyzing the class references in the preset component based on the component information, establishing indexes and dependencies of the classes according to the class references, and generating the second relation graph.
7. The apparatus of claim 5, wherein the screening unit comprises:
The first traversing subunit is used for traversing the first relation diagram and the second relation diagram respectively, and acquiring the access frequency of each class in the first relation diagram and the access frequency of each class in the second relation diagram;
A first queue construction subunit, configured to put each class in the first relationship diagram into a first queue according to an order from high to low of access frequency;
A second queue construction subunit, configured to put each class in the second relationship diagram into a second queue according to an order from high to low of access frequency;
And the screening subunit is used for screening out the classes with access frequency meeting preset conditions based on the first queue and the second queue, and packaging the screened classes into the main dex file.
8. The apparatus of claim 7, wherein the screening subunit comprises:
the second traversing subunit is used for performing depth traversing on the first queue, stopping traversing and packing the traversed class in the first queue into the main dex file if the number of the traversed class is equal to a preset threshold value and the first queue does not complete traversing;
A third traversing subunit, configured to, if the number of methods for completing the traversed class is less than the threshold and the first queue has completed traversing, perform depth traversing on the second queue, and calculate to obtain a difference between the threshold and the number of methods for completing the traversed class of the first queue;
A fourth traversing subunit, configured to stop traversing if the number of methods of the traversed class in the second queue is equal to the difference value and the traversed class in the first queue and the traversed class in the second queue are not completed, and package the traversed class in the first queue and the traversed class in the second queue into the main dex file;
And a fifth traversing subunit, configured to stop traversing if the number of methods of the traversed class in the second queue is smaller than the difference value and the traversed class in the second queue is completed, and package the traversed class in the first queue and the traversed class in the second queue into the main dex file.
9. An electronic device, comprising:
One or more processors;
a storage device having one or more programs stored thereon;
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-4.
10. A computer storage medium, having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the method of any of claims 1 to 4.
CN202411832784.4A 2024-12-12 2024-12-12 Optimization methods, devices, electronic equipment, and storage media for cold start applications Active CN119621191B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411832784.4A CN119621191B (en) 2024-12-12 2024-12-12 Optimization methods, devices, electronic equipment, and storage media for cold start applications

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411832784.4A CN119621191B (en) 2024-12-12 2024-12-12 Optimization methods, devices, electronic equipment, and storage media for cold start applications

Publications (2)

Publication Number Publication Date
CN119621191A true CN119621191A (en) 2025-03-14
CN119621191B CN119621191B (en) 2025-12-05

Family

ID=94902062

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411832784.4A Active CN119621191B (en) 2024-12-12 2024-12-12 Optimization methods, devices, electronic equipment, and storage media for cold start applications

Country Status (1)

Country Link
CN (1) CN119621191B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110029636A1 (en) * 2009-07-31 2011-02-03 Barry Smyth Real time information feed processing
US20110252371A1 (en) * 2010-04-13 2011-10-13 Sony Corporation System and method for fast boot of computer
CN112035176A (en) * 2020-07-15 2020-12-04 上海趣蕴网络科技有限公司 Multi-packet application cold start optimization method and device
CN113296826A (en) * 2020-07-30 2021-08-24 阿里巴巴集团控股有限公司 Generation method of application installation package, loading method and device thereof, and electronic equipment
CN114924809A (en) * 2022-05-19 2022-08-19 西安理工大学 A streaming microservice loading verification method based on DEX file class

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110029636A1 (en) * 2009-07-31 2011-02-03 Barry Smyth Real time information feed processing
US20110252371A1 (en) * 2010-04-13 2011-10-13 Sony Corporation System and method for fast boot of computer
CN112035176A (en) * 2020-07-15 2020-12-04 上海趣蕴网络科技有限公司 Multi-packet application cold start optimization method and device
CN113296826A (en) * 2020-07-30 2021-08-24 阿里巴巴集团控股有限公司 Generation method of application installation package, loading method and device thereof, and electronic equipment
CN114924809A (en) * 2022-05-19 2022-08-19 西安理工大学 A streaming microservice loading verification method based on DEX file class

Also Published As

Publication number Publication date
CN119621191B (en) 2025-12-05

Similar Documents

Publication Publication Date Title
CN111580954B (en) Extensible distributed data acquisition method and system
EP2791850B1 (en) Identifying application resources through implicit application models
CN102215251B (en) For analyzing the method and system of page load time
CN108023742A (en) A kind of expansion method of application, device and system
CN105468362A (en) Application deployment method and cloud computing system
US11681585B2 (en) Data migration for a shared database
CN111857736B (en) Cloud computing product generation method, device, equipment and storage medium
EP3251013A1 (en) Monitoring application loading
CN119621191B (en) Optimization methods, devices, electronic equipment, and storage media for cold start applications
CN109918112B (en) Game hot update method, device and storage medium
O'Sullivan et al. The cloud personal assistant for providing services to mobile clients
CN114706690B (en) Method and system for sharing GPU (graphics processing Unit) by Kubernetes container
CN117289906A (en) Low-code application development method, equipment and medium
CN113760481A (en) Distributed timed task scheduling system and method
CN109167826B (en) Method, device and system for putting WEB application on shelf
CN113849199A (en) Method and device for cross-system installation of application, electronic equipment and storage medium
CN106357704A (en) Method and device for invoking service on basis of development environments
US20160358082A1 (en) Customized Browser Out of Box Experience
US20230393826A1 (en) Fast retrieving hierarchical components on multi-tenant cross region multi-cloud
CN114675872B (en) Data processing method, device, equipment and storage medium for application program
KR101977602B1 (en) Apparatus and method for managing microservice
CN113031960B (en) Code compiling method, device, server and storage medium
CN117389567A (en) Multi-terminal application development method, device, medium and equipment
US20110145826A1 (en) Mechanism for partitioning program trees into environments
CN115858007A (en) Expansion component loading method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant