Configuration file optimization method, device, server and storage medium
By obtaining the installation package of the new version of the application and the configuration files of the old version of the application, extracting the identification information of the hotspot compilation unit and finding the matching compilation unit in the new version of the application, generating a new configuration file, the hotspots in the existing technology are solved. The compilation unit determines the application running lag caused by long time, which achieves early optimization of the application and improved user experience.
Patent Information
- Application Number
- CN202011595387.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-29
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2040-12-29
AI Technical Summary
The existing compilation optimization functions require the application to run for a period of time before the hotspot compilation unit can be determined, resulting in the problem of stuttering application operation.
By obtaining the installation package of the new version of the application and the configuration files of the old version of the application, extracting the identification information of the hotspot compilation unit, and finding matching compilation units in the compilation unit of the new version of the application, generating a new configuration file to achieve Optimize in advance.
Reduces the stuttering of the application during the first installation and improves the user experience.
Smart Images

Figure CN112559088B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a configuration file optimization method, device, server, and storage medium. Background Art
[0002] Electronic devices, such as tablet computers and smart terminals, have become one of the most commonly used consumer electronic products in people's daily lives. People usually install various applications in electronic devices to meet different needs. In order to improve the execution efficiency of electronic devices for applications, it is usually necessary to use the code optimization function of the compiler to compile and optimize the application. For example, a hotspot compilation unit is determined from multiple compilation units corresponding to the application. The compiler can convert the program code of the hotspot compilation unit into machine code according to the compilation optimization function, thereby avoiding just-in-time compilation of the hotspot compilation unit when the application is running.
[0003] However, the existing compilation optimization function usually requires the application to run for a period of time before determining the hot compilation unit, which is not timely enough, thus causing the application to run slowly. Summary of the invention
[0004] In view of the above problems, the present application proposes a configuration file optimization method, device, server and storage medium to solve the above problems.
[0005] In a first aspect, an embodiment of the present application provides a configuration file optimization method, which is applied to a server, and the method includes: obtaining an installation package of a new version application, and obtaining a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application; obtaining identification information of a hotspot compilation unit corresponding to the old version application from the first configuration file; based on the identification information, searching for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version application as a target compilation unit; based on the target compilation unit, generating a configuration file corresponding to the new version application as a second configuration file.
[0006] In a second aspect, an embodiment of the present application provides a configuration file optimization device, which is applied to a server, and the device includes: a first configuration file acquisition module, which is used to acquire an installation package of a new version application, and acquire a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application; an identification information acquisition module, which is used to acquire identification information of a hotspot compilation unit corresponding to the old version application from the first configuration file; a target compilation unit search module, which is used to search, based on the identification information, for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version application, as a target compilation unit; and a second configuration file acquisition module, which is used to generate a configuration file corresponding to the new version application as a second configuration file based on the target compilation unit.
[0007] In a third aspect, an embodiment of the present application provides a server, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.
[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.
[0009] The configuration file optimization method, device, server and storage medium provided in the embodiments of the present application obtain an installation package of a new version application, and obtain a configuration file corresponding to an old version application as a first configuration file. The new version application and the old version application are different versions of the same application. From the first configuration file, identification information of a hotspot compilation unit corresponding to the old version application is obtained. Based on the identification information, a compilation unit matching the hotspot compilation unit is searched from multiple compilation units in the installation package of the new version application as a target compilation unit. Based on the target compilation unit, a configuration file corresponding to the new version application is generated as a second configuration file. Thus, by migrating the configuration files of the new and old versions, the new version can be optimized in advance when it is installed for the first time, thereby reducing the running jam of the application and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1A schematic diagram of an application environment that can be used for the configuration file optimization method provided in the embodiment of the present application is shown;
[0012] Figure 2 A schematic diagram showing another application environment that can be used for the configuration file optimization method provided in the embodiment of the present application;
[0013] Figure 3 A schematic diagram of a flow chart of a configuration file optimization method provided by an embodiment of the present application is shown;
[0014] Figure 4 A schematic diagram of a flow chart of a configuration file optimization method provided by another embodiment of the present application is shown;
[0015] Figure 5 A schematic diagram of a flow chart of a configuration file optimization method provided in yet another embodiment of the present application is shown;
[0016] Figure 6 A schematic diagram of a flow chart of a configuration file optimization method provided by another embodiment of the present application is shown;
[0017] Figure 7 A schematic diagram of a flow chart of a configuration file optimization method provided by yet another embodiment of the present application is shown;
[0018] Figure 8 This application shows Figure 7 A schematic flow chart of step S520 of the configuration file optimization method shown;
[0019] Fig. 9 A module block diagram of a configuration file optimization device provided in an embodiment of the present application is shown;
[0020] Fig.10 A block diagram of a server according to an embodiment of the present application for executing a configuration file optimization method according to an embodiment of the present application is shown;
[0021] Fig.11 A storage unit for storing or carrying program codes for implementing a method for handling power-on exceptions according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0023] In the development of Android system, the most commonly used programming language is Java. Even if it is not Java, it is JVM language. The java source files in the Android project are compiled to generate Class files, and finally packaged into dex bytecode files. The dex bytecode is then translated into machine code through the virtual machine Dalvik or Android runtime Art. Just-in-time compilation JIT and pre-compilation AOT are different compilation strategies adopted by the virtual machine to improve operating efficiency.
[0024] In the early days of the Android system, every time a program was run, Dalvik would translate dex into machine code and hand it over to the system for call, and then to the underlying system for processing, which was very inefficient. In Android 2.2, a JIT compiler was added. Whenever a new class is encountered, the JIT compiler will compile the class in real time and turn it into a streamlined native instruction code. The next time the same logic is encountered, the speed will be faster. Because the JIT compiler only compiles a part of the code, it has a smaller memory footprint and device physical space occupancy, but the efficiency is still low as it interprets and executes at the same time.
[0025] After Android 5.0, Art officially replaced Dalvik. Art uses the AOT compilation method. That is, during the installation of the application, all dex bytecodes are translated into machine codes and stored in the storage space of the electronic device. That is, the dex2oat process will be started to pre-compile dex into ELF files. The interpretation process of dex bytecode has been completed, making the application run faster and further reducing the startup time of the application. However, the bytecode translation time during installation is too long, making the installation process very long. In addition, the translated machine code also occupies a larger body storage space.
[0026] In Android 7.0, the JIT compiler is adopted again, that is, the JIT+AOT compilation mode is adopted. When the application is installed, dex will not be compiled again. When the application is running, the dex file is first executed directly through the interpreter. The hot compilation unit will be identified and compiled by JIT and stored in the JIT code cache. A profile file is generated to record the index of the hot compilation unit. When the phone enters the idle or charging state, the system scans the configuration file in the application directory and executes the AOT process for compilation. At present, most terminal manufacturers use the ART+Interpreter+JIT+AOT mixed compilation mode. In this compilation mode, the installation speed of the application is significantly improved. As the application is used for a longer time, the number of hot compilation units of the application will increase, and the performance of the application will also get better and better.
[0027] Among them, what is recorded in the configuration file is the index of the hotspot compilation unit, which is matched one by one with the version of the installation package of the application. The index may change between different versions of the installation package of the application due to compatibility issues, that is, the index of the same compilation unit changes between different versions, or some compilation units in the old version are removed in the new version. In this way, it cannot be guaranteed that the configuration file of the old version can continue to be used in the new version (plus the checksum verification, which generally cannot be used). In addition, since the hotspot compilation unit needs to be determined during the operation of the application, that is, the hotspot compilation unit needs to be determined after the application has been running for a period of time, resulting in the new version of the application not having a corresponding hotspot compilation unit when it is run for the first time or in the initial stage, it can only use real-time compilation and cannot use pre-run compilation, which in turn causes the problem of application running stuck.
[0028] In view of the above problems, the inventors have discovered after long-term research and proposed the configuration file optimization method, device, server and storage medium provided in the embodiments of the present application. By migrating the configuration files of the new and old versions, the new version can be optimized in advance when it is first installed, reducing the running jam of the application and improving the user experience. The specific configuration file optimization method is described in detail in the subsequent embodiments.
[0029] The following is a description of an environment diagram that can be used for the hotspot code determination method provided in an embodiment of the present application.
[0030] See also Figure 1 , Figure 1 A schematic diagram of an application scenario of the configuration file optimization method provided in an embodiment of the present application is shown, and the application scenario includes: an electronic device 200 and a server 100. The electronic device 200 communicates with the server 100 via a network. The electronic device 200 can interact with the server 100 to obtain an installation package, a configuration file, etc. of an application from the server 100, or send configuration information to the server 100.
[0031] See also Figure 2 , Figure 2Another application scenario schematic diagram of the optimization method for the configuration file provided in the embodiment of the present application is shown. The electronic device 200 may include a first electronic device 210 and a second electronic device 220. Of course, the electronic device may also include a third electronic device, a fourth electronic device, a fifth electronic device... an Nth electronic device, etc., which are not limited here. That is, the application scenario includes: a first electronic device 210, a second electronic device 220, and a server 100. Among them, the first electronic device 210 and the server 100 perform data interaction, and the second electronic device 220 and the server 100 perform data interaction. The server 100 can receive the configuration information uploaded by the first electronic device 210, obtain the configuration information uploaded by the second electronic device 220, and use big data to improve the accuracy of the configuration file finally generated.
[0032] In some embodiments, the electronic device 200 may include a smart phone, a tablet computer, an e-book, a smart watch, and the like; the server 100 may include a traditional server, a cloud server, and the like, which are not limited here.
[0033] See also Figure 3 , Figure 3 The flowchart of the configuration file optimization method provided by an embodiment of the present application is shown. The configuration file optimization method is used to migrate the configuration files of the new and old versions, so that the new version can also be optimized in advance when it is first installed, thereby reducing the running delay of the application and improving the user experience. In a specific embodiment, the configuration file optimization method is applied to Fig. 9 The configuration file optimization device 300 and the server 100 ( Fig.10 ). The following will take the server as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the server used in this embodiment can be a cloud server or a traditional server, etc., which is not limited here. Figure 3 The process shown is described in detail, and the optimization method of the configuration file shown can specifically include the following steps:
[0034] Step S110: obtaining an installation package of a new version application, and obtaining a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application.
[0035] In this embodiment, the new version application and the old version application are different versions of the same application. For example, the new version application is the V2 version of application A, and the old version application is the V1 version of application A, that is, the new version application and the old version application are different versions of application A, and the new version application is obtained by upgrading or updating the old version application.
[0036] In some implementations, the server may obtain an installation package of a new version of the application. The server may have previously obtained and stored the installation package of the new version of the application, and may directly obtain the installation package of the new version of the application from the local server. Alternatively, the server may also be connected to a user terminal and obtain the installation package of the new version of the application uploaded by the user terminal, wherein the user terminal may correspond to an application developer.
[0037] In some embodiments, the server may obtain a configuration file corresponding to an old version application, and use the configuration file corresponding to the old version application as the first configuration file. The server may pre-store a configuration file corresponding to the old version application. For example, the server may pre-store a configuration file containing identification information, attribute information, index, etc. of a hotspot compilation unit, and then the configuration file corresponding to the old version application may be obtained from the local server. As a method, the number of the old version applications is one or more, wherein when the number of determined old version applications is one, the old version application and the new version application may be adjacent versions of applications; when the number of determined old version applications is multiple, the configuration file corresponding to each of the multiple old version applications may be obtained, and then the first configuration file may be generated based on the configuration file corresponding to each old version application. For example, the configuration files corresponding to the multiple old version applications may be merged to generate the first configuration file.
[0038] Step S120: Acquire identification information of the hotspot compilation unit corresponding to the old version application from the first configuration file.
[0039] In some embodiments, after obtaining the first configuration file, the server may parse the first configuration file, and obtain the identification information of the hotspot compilation unit corresponding to the old version of the application from the first configuration file. The compilation unit may be understood as a function, method or class in the source code of the application, and the hotspot compilation unit may be understood as a function, method or class in the source code of the application that is called more than a preset number of times. The configuration file is usually a binary file, which contains the identification information of the hotspot compilation unit in the source code of the application, the index of the hotspot compilation unit in the source code of the application, etc. The identification information may include, for example, identity (ID) information, wherein the identification information is the definition information of the compilation unit, which may be considered as the unique name of the compilation unit. As long as the compilation unit is not modified, that is, the versions are compatible, this name will not change.
[0040] Step S130: Based on the identification information, searching for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit.
[0041] Among them, although there are differences between the new version application and the old version application, the difference between the two is not too great, and correspondingly, the difference between the hotspot compilation unit corresponding to the new version application and the hotspot compilation unit corresponding to the old version application is not too great. Therefore, after obtaining the identification information of the hotspot compilation unit corresponding to the old version application, this embodiment searches for a matching compilation unit from multiple compilation units in the installation package of the new version application according to its identification information. If a matching compilation unit is found, it means that there is a compilation unit in the installation package of the new version application that is similar to the hotspot compilation unit corresponding to the old version application. Then, the similar compilation unit can be determined as the hotspot compilation unit corresponding to the new version application and recorded as the target compilation unit. If it is not found, it means that the compilation unit is removed or modified in the new version application, and the compilation unit will not be recorded as the target compilation unit.
[0042] For example, the new version application V2 corresponds to the new version installation package Y2, and the old version application V1 corresponds to the old version installation package Y1. After obtaining the new version installation package Y2 corresponding to the new version application V2, the server can detect whether the new version configuration file corresponding to the new version application V2 can be obtained. If not, the old version configuration file of the old version application V1 can be obtained, wherein the old version configuration file records the ID of the old version hotspot compilation unit of the old version application V1, for example, the ID of the old version hotspot compilation unit includes 1 and 2. If a matching compilation unit is not found from the new version installation package Y2 according to ID 1, and a matching compilation unit is found from the new version installation package Y2 according to ID 2, it can be determined that the found compilation unit is a compilation unit that matches the old version hotspot compilation unit 2, and the matching compilation unit is determined as the target compilation unit.
[0043] Step S140: Based on the target compilation unit, a configuration file corresponding to the new version application is generated as a second configuration file.
[0044] In this embodiment, after obtaining the target compilation unit, a configuration file corresponding to the new version of the application can be generated based on the target compilation unit, and the configuration file corresponding to the new version of the application is used as the second configuration file. The second configuration file includes the target compilation unit, for example, the second configuration file includes the hotspot compilation unit with an ID of 2.
[0045] It can be seen that based on the above method, the server can very quickly determine the hot compilation unit of the new version of the application, and thus quickly generate the corresponding configuration file. In this process, it is not necessary to spend time counting the usage frequency of each compilation unit during the operation of the new version of the application as the basis for determining the hot compilation unit, thereby improving the efficiency of determining the hot compilation unit, and further improving the timeliness of generating the configuration file corresponding to the new version of the application.
[0046] An embodiment of the present application provides a configuration file optimization method, which obtains an installation package of a new version application, and obtains a configuration file corresponding to an old version application as a first configuration file. The new version application and the old version application are different versions of the same application. From the first configuration file, identification information of a hotspot compilation unit corresponding to the old version application is obtained, and based on the identification information, a compilation unit matching the hotspot compilation unit is searched from multiple compilation units in the installation package of the new version application as a target compilation unit. Based on the target compilation unit, a configuration file corresponding to the new version application is generated as a second configuration file, so that by migrating the configuration files of the new and old versions, the new version can be optimized in advance when it is installed for the first time, thereby reducing the running jam of the application and improving the user experience.
[0047] See also Figure 4 , Figure 4 A schematic diagram of a configuration file optimization method provided by another embodiment of the present application is shown. The method is applied to the above server. Figure 4 The process shown is described in detail, and the configuration file optimization method may specifically include the following steps:
[0048] Step S210: obtaining an installation package of a new version application, and obtaining a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application.
[0049] For the detailed description of step S210, please refer to step S110, which will not be repeated here.
[0050] Step S220: Parse the first configuration file to obtain the index of the hotspot compilation unit recorded in the first configuration file.
[0051] In some implementations, since the first configuration file records the index of the hotspot compilation unit in the installation package of the old version application, after obtaining the first configuration file corresponding to the old version application, the index of the hotspot compilation unit recorded in the first configuration file can be obtained by parsing the first configuration file corresponding to the old version application. As a method, the hotspot compilation unit and the index of the hotspot compilation unit can correspond one to one, that is, a hotspot compilation unit in the installation package of the old version application can correspond to an index in the first configuration file. For example, when the number of indexes of the hotspot compilation units recorded in the first configuration file is n, the number of hotspot compilation units in the installation package representing the old version application is n, and the n hotspot compilation units correspond one to one to the n indexes.
[0052] Step S230: reading the installation package of the old version application based on the index, and obtaining identification information of the hotspot compilation unit corresponding to the old version application.
[0053] In some implementations, after obtaining the index of the hotspot compilation unit recorded in the first configuration file, the installation package of the old version application program may be read according to the index to obtain identification information of the hotspot compilation unit corresponding to the old version corresponding program.
[0054] Step S240: Based on the identification information, searching for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit.
[0055] Step S250: Based on the target compilation unit, a configuration file corresponding to the new version application is generated as a second configuration file.
[0056] For the detailed description of step S240 to step S250, please refer to step S130 to step S140, which will not be repeated here.
[0057] Another embodiment of the present application provides a configuration file optimization method, which obtains an installation package of a new version of the application, and obtains a configuration file corresponding to the old version of the application as a first configuration file, wherein the new version of the application and the old version of the application are different versions of the same application, parses the first configuration file, obtains an index of a hotspot compilation unit recorded in the first configuration file, reads the installation package of the old version of the application based on the index, obtains identification information of the hotspot compilation unit corresponding to the old version of the application, and based on the identification information, searches for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit, and generates a configuration file corresponding to the new version of the application as a second configuration file based on the target compilation unit. Compared to Figure 3 The optimization method of the configuration file shown in the figure, this embodiment also parses the first configuration file to obtain the index of the hotspot compilation unit recorded therein, and reads the installation package of the old version of the application based on the index to obtain the identification information of the hotspot compilation unit, so as to improve the accuracy and convenience of the obtained identification information.
[0058] See also Figure 5 , Figure 5 A schematic diagram of a configuration file optimization method provided by another embodiment of the present application is shown. The method is applied to the above server. Figure 5 The process shown is described in detail, and the configuration file optimization method may specifically include the following steps:
[0059] Step S310: obtaining an installation package of a new version application, and obtaining a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application.
[0060] The specific description of step S310 can be found in step S110 , which will not be repeated here.
[0061] Step S320: Parse the first configuration file to obtain the index of the hotspot compilation unit recorded in the first configuration file.
[0062] For the detailed description of step S320, please refer to step S220, which will not be repeated here.
[0063] Step S330: Read the installation package of the old version application based on the index, and obtain the descriptor of the hotspot compilation unit corresponding to the old version application.
[0064] In some implementations, after obtaining the index of the hotspot compilation unit recorded in the first configuration file, the installation package of the old version application can be read according to the index to obtain the descriptor of the hotspot compilation unit corresponding to the old version of the corresponding program. The descriptor is the definition information of the compilation unit, which can be considered as the unique name of the compilation unit. As long as the compilation unit is not modified, that is, the versions are compatible, the name will not change.
[0065] Step S340: traverse the installation package of the new version application based on the descriptor, and search for a compilation unit matching the hotspot compilation unit from multiple compilation units in the installation package of the new version application as the target compilation unit.
[0066] In some embodiments, after obtaining the descriptor of the hotspot compilation unit corresponding to the old version application, the multiple compilation units in the installation package of the new version application can be traversed based on the descriptor to find a compilation unit that matches the hotspot compilation unit from the multiple compilation units in the installation package of the new version application as the target compilation unit. As a way, after obtaining the descriptor of the hotspot compilation unit corresponding to the old version application, the multiple compilation units in the installation package of the new version application can be traversed based on the descriptor to find an index that matches the index of the hotspot compilation unit from the indexes of the multiple compilation units in the installation package of the new version application as the target index, and the compilation unit indicated by the target index is obtained as the target compilation unit.
[0067] Step S350: Based on the target compilation unit, generate a configuration file corresponding to the new version application as a second configuration file.
[0068] For the detailed description of step S350, please refer to step S140, which will not be repeated here.
[0069] Another embodiment of the present application provides a configuration file optimization method, which obtains an installation package of a new version of the application, and obtains a configuration file corresponding to the old version of the application as a first configuration file, wherein the new version of the application and the old version of the application are different versions of the same application, parses the first configuration file, obtains an index of a hotspot compilation unit recorded in the first configuration file, reads the installation package of the old version of the application based on the index, obtains a descriptor of the hotspot compilation unit corresponding to the old version of the application, traverses the installation package of the new version of the application based on the descriptor, searches for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit, and generates a configuration file corresponding to the new version of the application as a second configuration file based on the target compilation unit. Compared to Figure 3The optimization method of the configuration file shown in the figure, this embodiment also parses the first configuration file to obtain the index of the hotspot compilation unit recorded therein, and reads the installation package of the old version of the application based on the index to obtain the descriptor of the hotspot compilation unit, and traverses the installation package of the new version of the application through the descriptor to obtain the target compilation unit, so as to improve the accuracy and convenience of the obtained target compilation unit.
[0070] See also Figure 6 , Figure 6 A schematic diagram of a configuration file optimization method provided by another embodiment of the present application is shown. The method is applied to the above server. Figure 6 The process shown is described in detail, and the configuration file optimization method may specifically include the following steps:
[0071] Step S410: obtaining an installation package of a new version application, and obtaining a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application.
[0072] For the detailed description of step S410, please refer to step S110, which will not be repeated here.
[0073] Step S420: Acquire identification information of the hotspot compilation unit corresponding to the old version application from the first configuration file.
[0074] For the detailed description of step S420, please refer to step S220, which will not be repeated here.
[0075] Step S430: Based on the identification information, searching for a compilation unit having the identification information from multiple compilation units in the installation package of the old version of the application, and obtaining the name of the compilation unit having the identification information.
[0076] It is worth noting that in some cases, the identification information of the same or similar compilation units in the installation package of the new version of the application and the installation package of the old version of the application may be different, but for the readability of the code and the convenience of subsequent maintenance, their names are usually consistent. In this case, after obtaining the identification information of the hot compilation unit corresponding to the old version of the application, the server can search for the compilation unit with the identification information from the multiple compilation units in the installation package of the old version of the application, and obtain the name of the found compilation unit.
[0077] Step S440: Based on the name, searching for a compilation unit with the name from multiple compilation units in the installation package of the new version of the application as the target compilation unit.
[0078] After obtaining the name of the compilation unit with identification information, the compilation unit with the name can be searched from the installation package of the new version of the application as the target compilation unit according to the name, thereby improving the accuracy of obtaining the target compilation unit.
[0079] Taking the search for the hotspot compilation unit based on the identification information id1 as an example, since there is a corresponding relationship between the first configuration file and the installation package of the old version of the application, the server can find the compilation unit with the identification information id1 from the installation package of the old version of the application according to the identification information id1 of the hotspot compilation unit obtained from the first configuration file, and extract the name m1 of the compilation unit. If the first configuration file contains multiple identification information, similar operations as above are performed for each identification information to obtain the names of multiple hotspot compilation units. After obtaining the name m1, the server can search for the installation package of the new version of the application based on the name m1. Since there are certain differences in the compilation units in the installation packages of different versions, it may be impossible to find the compilation unit with the name m1. If it cannot be found, no processing is required. If it is found, it can be determined that the found compilation unit is the target compilation unit that matches the hotspot compilation unit corresponding to the old version of the application.
[0080] Step S450: Based on the target compilation unit, generate a configuration file corresponding to the new version application as a second configuration file.
[0081] For the detailed description of step S450, please refer to step S140, which will not be repeated here.
[0082] Another embodiment of the present application provides a configuration file optimization method, which obtains an installation package of a new version of an application, and obtains a configuration file corresponding to an old version of the application as a first configuration file. The new version of the application and the old version of the application are different versions of the same application. From the first configuration file, the identification information of the hotspot compilation unit corresponding to the old version of the application is obtained. Based on the identification information, a compilation unit with the identification information is searched from multiple compilation units of the installation package of the old version of the application, and the name of the compilation unit with the identification information is obtained. Based on the name, a compilation unit with the name is searched from multiple compilation units of the installation package of the new version of the application as a target compilation unit. Based on the target compilation unit, a configuration file corresponding to the new version of the application is generated as a second configuration file. Compared to Figure 3 The optimization method of the configuration file shown in the figure, this embodiment also obtains the name of the compilation unit with identification information from the installation package of the old version of the application, and searches for the compilation unit with the name from the installation package of the new version of the application as the target compilation unit, so as to improve the accuracy and convenience of obtaining the target compilation unit.
[0083] See also Figure 7 , Figure 7 A schematic diagram of a configuration file optimization method provided by another embodiment of the present application is shown. The method is applied to the above server. Figure 7 The process shown is described in detail, and the configuration file optimization method may specifically include the following steps:
[0084] Step S510: receiving configuration information uploaded by the electronic device each time the old version application is run, and obtaining a plurality of configuration information.
[0085] Among them, when the old version of the application is started for the first time on the electronic device, it can only run in interpreter mode because it does not perform ahead-of-time compilation (AOT), that is, there is no machine code of the application in Android. At this time, a thread (profile-saver) will be started in the runtime environment of the application to count the number of visits to each compilation unit in real time. Each time a compilation unit is called, the indicator counter (Count) in the access method (ArtMethod) opened in the memory is increased by 1. Only when the number of calls to the compilation unit reaches a certain threshold (Count in ArtMethod) will the index of the loaded compilation unit be recorded in the configuration file.
[0086] It is worth noting that the electronic device records the number of accesses to the compilation unit in the memory, that is, when the application exits the electronic device, all the counting information will be cleared. For some compilation units that are called every time the application is started, if the number of calls does not reach the threshold, they will not be recorded in the configuration file. In this way, although these compilation units play a critical role in starting and running the application, they are not compiled into machine code, which means that each time these compilation units are called, they will run in interpreter mode, which is less efficient.
[0087] Therefore, in this embodiment, a hook function (HOOK) can be added to the Android ART of the electronic device to capture the configuration information of the application at runtime through the hook function, wherein the configuration information can at least include the number of calls of each compilation unit in the compilation unit of the installation package for the old version of the application, and the index of each compilation unit. Then, the electronic device can upload the configuration information recorded in the memory to the server each time the old version of the application is run, and the server can obtain multiple configuration information. For example, assuming that the application is run on the electronic device three times in chronological order, the electronic device uploads the first configuration information corresponding to the first run recorded in the memory to the server when the old version of the application is run for the first time, and uploads the second configuration information corresponding to the second run recorded in the memory to the server when the old version of the application is run for the second time, and uploads the third configuration information corresponding to the third run recorded in the memory to the server when the old version of the application is run for the third time. Then the server can obtain the first configuration information, the second configuration information and the third configuration information.
[0088] Step S520: merging the multiple configuration information to obtain a first configuration file.
[0089] The server may be pre-configured with profman, which is a tool that can parse configuration files. After acquiring multiple configuration information, the server may use profman to merge the multiple configuration information to obtain the first configuration file.
[0090] For example, assuming that multiple configuration information includes first configuration information, second configuration information and third configuration information, wherein the first configuration information includes that compilation unit 1 is called 15 times, compilation unit 2 is called 10 times, and compilation unit 3 is called 5 times, the second configuration information includes that compilation unit 1 is called 20 times, compilation unit 2 is called 10 times, and compilation unit 3 is called 3 times, and the third configuration information includes that compilation unit 1 is called 30 times, compilation unit 2 is called 16 times, and compilation unit 3 is called 7 times, then the first configuration information, the second configuration information and the third configuration information are merged and processed, and it can be obtained that compilation unit 1 is called 60 times, compilation unit 2 is called 36 times, and compilation unit 3 is called 15 times, and then according to the pre-set hotspot compilation unit determination condition, whether compilation unit 1, compilation unit 2 and compilation unit 3 are hotspot compilation units is determined, wherein, when compilation unit 1 and compilation unit 2 are determined to be hotspot compilation units, and compilation unit 3 is determined to be a non-hotspot compilation unit, the obtained first configuration file can include the index of compilation unit 1 and the index of compilation unit 2.
[0091] In addition, the server can collect configuration information on all electronic devices running the old version of the application. Since the correctness of the configuration file is only related to the version of the application installation package and has nothing to do with the running device, big data can be used to improve the correctness of the first configuration file finally generated to balance the effectiveness of calling the compilation unit and the size of the machine code. Among them, the configuration file records the index of the hotspot compilation unit in the installation package of the application, so the configuration file is related to the installation package of the application and the index order of the hotspot compilation unit in the installation package. In other words, different versions of application installation packages have different corresponding configuration files, and the same application installation package has different versions (there may be code compatibility issues, resulting in different indexes for the same method in different versions), and the corresponding configuration files may also be different. Therefore, the correctness of the configuration file is matched one by one with the version of the application installation package.
[0092] See also Figure 8 , Figure 8 This application shows Figure 7 The flow chart of step S520 of the configuration file optimization method shown in FIG. In this embodiment, the configuration information at least includes the call count of each compilation unit in the compilation unit of the installation package of the old version application. Figure 8 The process shown is described in detail, and the method may specifically include the following steps:
[0093] Step S521: merging the plurality of configuration information to obtain the total number of calls of each compilation unit.
[0094] In this embodiment, the configuration information includes at least the number of calls to each compilation unit in the compilation unit of the installation package of the old version of the application. When multiple configuration information are merged, the number of calls to the same compilation unit in each configuration information can be added to obtain the total number of calls to each compilation unit.
[0095] For example, assuming that multiple configuration information includes first configuration information, second configuration information and third configuration information, wherein the first configuration information includes that compilation unit 1 is called 15 times, compilation unit 2 is called 10 times, and compilation unit 3 is called 5 times, the second configuration information includes that compilation unit 1 is called 20 times, compilation unit 2 is called 10 times, and compilation unit 3 is called 3 times, and the third configuration information includes that compilation unit 1 is called 30 times, compilation unit 2 is called 16 times, and compilation unit 3 is called 7 times, then the first configuration information, the second configuration information and the third configuration information are merged, and it can be obtained that the total number of calls to compilation unit 1 is 60 times, the total number of calls to compilation unit 2 is 36 times, and the total number of calls to compilation unit 3 is 15 times.
[0096] Step S522: determining a hotspot compilation unit from the plurality of compilation units in descending order of the total call count of each compilation unit.
[0097] In some implementations, after obtaining the total number of calls of each of the multiple compilation units, the hot compilation unit can be determined from the multiple compilation units in the order of the total number of calls of each compilation unit from high to low. As shown in the above example, compilation unit 1, compilation unit 2, and compilation unit 3 are sorted in the order of the total number of calls of each compilation unit from high to low to obtain: compilation unit 1-compilation unit 2-compilation unit 3, then, if two hot compilation units are determined from the three compilation units, compilation unit 1 and compilation unit 2 can be determined as hot compilation units, and if one hot compilation unit is determined from the three compilation units, compilation unit 1 can be determined as the hot compilation unit, which is not limited here.
[0098] In some implementations, in order to balance the existence of the configuration file (only when the configuration file exists can the code be compiled into machine code based on the configuration file) and the size of the configuration file (if the configuration file is too large and contains too many hotspot compilation units, the generated machine code file will be too large, which will have a negative impact on Android storage), a preset ratio can be set. Therefore, in this embodiment, a preset ratio of compilation units can be selected from multiple compilation units in the order of the total number of calls of each compilation unit from high to low, as hotspot compilation units, so that the storage of the configuration file and the size of the configuration file can be optimized.
[0099] In some embodiments, the preset ratio can be determined based on the proportion of valid compilation units in multiple compilation units of the installation package of the old version of the application. Generally, according to the test results, the truly valid compilation units account for 20% of the total compilation units, and the preset ratio can be set to 20%. Among them, the valid compilation unit refers to the compilation unit that is called during the operation of the application. The compilation unit in the application may include exception handling (it can only be called when an error occurs) and branch logic (according to usage, such as input A, call logic A, input B, call logic B). In this way, in a normal execution process, only a small part of the compilation units are actually called. During the use of the application, it should basically be normal logic, so most of the compilation units may not be called, so for compilation, they can be considered invalid compilation units.
[0100] Step S523: Based on the hotspot compilation unit, obtain the first configuration file.
[0101] In some implementations, after the hotspot compilation unit is obtained, a first configuration file may be obtained based on the hotspot compilation unit, wherein the first configuration file records an index of the hotspot compilation unit.
[0102] Step S530: obtaining an installation package of a new version application, and obtaining a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application.
[0103] Step S540: Acquire identification information of the hotspot compilation unit corresponding to the old version application from the first configuration file.
[0104] Step S550: Based on the identification information, searching for a compilation unit that matches the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit.
[0105] Step S560: Based on the target compilation unit, generate a configuration file corresponding to the new version application as a second configuration file.
[0106] For the detailed description of step S530 to step S560, please refer to step S110 to step S140, which will not be repeated here.
[0107] The present application provides a configuration file optimization method in another embodiment, which receives configuration information uploaded by the electronic device each time the old version of the application is run, obtains multiple configuration information, merges the multiple configuration information, obtains a first configuration file, obtains the installation package of the new version of the application, and obtains the configuration file corresponding to the old version of the application as the first configuration file. The new version of the application and the old version of the application are different versions of the same application. From the first configuration file, the identification information of the hotspot compilation unit corresponding to the old version of the application is obtained. Based on the identification information, a compilation unit matching the hotspot compilation unit is searched from multiple compilation units of the installation package of the new version of the application as the target compilation unit. Based on the target compilation unit, a configuration file corresponding to the new version of the application is generated as the second configuration file. Compared to Figure 3 The configuration file optimization method shown in the figure also uploads the configuration information to the server for storage, so that the generated configuration file is more accurate and reasonable, and can better reflect the method calling situation of the application in the actual usage scenario, so that the code compilation achieves the best effect.
[0108] See also Fig. 9 , Fig. 9 The module block diagram of the configuration file optimization device provided in the embodiment of the present application is shown. The configuration file optimization device 300 is applied to the above-mentioned server. Fig. 9As shown in the block diagram, the configuration file optimization device 300 includes: a first configuration file acquisition module 310, an identification information acquisition module 320, a target compilation unit search module 330 and a second configuration file acquisition module 340, wherein:
[0109] The first configuration file acquisition module 310 is used to acquire an installation package of a new version application and acquire a configuration file corresponding to an old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application.
[0110] The identification information acquisition module 320 is used to obtain the identification information of the hotspot compilation unit corresponding to the old version application from the first configuration file.
[0111] Furthermore, the identification information acquisition module 320 includes: an index acquisition submodule and an identification information acquisition submodule, wherein:
[0112] The index acquisition submodule is used to parse the first configuration file and obtain the index of the hotspot compilation unit recorded in the first configuration file.
[0113] The identification information acquisition submodule is used to read the installation package of the old version application based on the index and obtain the identification information of the hotspot compilation unit corresponding to the old version application.
[0114] Furthermore, the identification information acquisition submodule includes:
[0115] The descriptor acquisition unit is used to read the installation package of the old version application based on the index, and acquire the descriptor of the hotspot compilation unit corresponding to the old version application.
[0116] The target compilation unit search module 330 is used to search for a compilation unit matching the hotspot compilation unit from multiple compilation units in the installation package of the new version application based on the identification information, as a target compilation unit.
[0117] Furthermore, the target compilation unit search module 330 includes: a first target compilation unit search submodule, wherein:
[0118] The first target compilation unit search submodule is used to traverse the installation package of the new version application based on the descriptor, and search for a compilation unit matching the hotspot compilation unit from multiple compilation units in the installation package of the new version application as the target compilation unit.
[0119] Furthermore, the target compilation unit search module 330 includes: a name search submodule and a second target compilation unit search submodule, wherein:
[0120] The name search submodule is used to search for a compilation unit having the identification information from multiple compilation units of the installation package of the old version application based on the identification information, and obtain the name of the compilation unit having the identification information.
[0121] The second target compilation unit search submodule is used to search, based on the name, for a compilation unit with the name from multiple compilation units in the installation package of the new version of the application as the target compilation unit.
[0122] The second configuration file acquisition module 340 is used to generate a configuration file corresponding to the new version application as a second configuration file based on the target compilation unit.
[0123] Furthermore, the configuration file optimization device 300 further includes: a configuration information obtaining module and a first configuration file obtaining module, wherein:
[0124] The configuration information obtaining module is used to receive the configuration information uploaded by the electronic device each time the old version application is run, and obtain multiple configuration information.
[0125] The first configuration file obtaining module is used to merge the multiple configuration information to obtain a first configuration file.
[0126] Further, the configuration information at least includes the number of calls of each compilation unit in the multiple compilation units of the installation package of the old version application, and the first configuration file acquisition module includes: a total call number acquisition submodule, a hotspot compilation unit determination submodule and a first configuration file acquisition submodule, wherein:
[0127] The total call count acquisition submodule is used to merge the multiple configuration information to obtain the total call count of each compilation unit.
[0128] The hotspot compilation unit determination submodule is used to determine the hotspot compilation unit from the multiple compilation units in descending order of the total call times of each compilation unit.
[0129] Further, the hotspot compilation unit determination submodule includes: a hotspot compilation unit determination unit, wherein:
[0130] The hotspot compilation unit determining unit is used to select a preset proportion of compilation units from the plurality of compilation units in descending order of the total call times of each compilation unit as the hotspot compilation units.
[0131] The first configuration file obtaining submodule is used to obtain the first configuration file based on the hotspot compilation unit.
[0132] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0133] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0134] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0135] See also Fig.10 , which shows a structural block diagram of a server 100 provided in an embodiment of the present application. The server 100 may include a cloud server, a traditional server, etc. The server 100 in the present application may include one or more of the following components: a processor 110, a memory 120, a touch screen 130, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0136] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts within the entire server 100, and executes various functions and processes data of the server 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.
[0137] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the server 100 during use.
[0138] See also Fig.11 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 400 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0139] The computer readable storage medium 400 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 400 includes a non-transitory computer-readable storage medium. The computer readable storage medium 400 has storage space for program code 410 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 410 can be compressed, for example, in an appropriate form.
[0140] In summary, the configuration file optimization method, device, server and storage medium provided in the embodiments of the present application obtain an installation package of a new version application, and obtain a configuration file corresponding to the old version application as a first configuration file. The new version application and the old version application are different versions of the same application. From the first configuration file, the identification information of the hotspot compilation unit corresponding to the old version application is obtained. Based on the identification information, a compilation unit matching the hotspot compilation unit is searched from multiple compilation units in the installation package of the new version application as the target compilation unit. Based on the target compilation unit, a configuration file corresponding to the new version application is generated as a second configuration file. Therefore, by migrating the configuration files of the new and old versions, the new version can be optimized in advance when it is installed for the first time, thereby reducing the running jam of the application and improving the user experience.
[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A configuration file optimization method, characterized in that: Applied to a server, the method comprises: Receiving configuration information recorded in the memory of the electronic device uploaded each time the old version application is run, and obtaining multiple configuration information, wherein the configuration information is captured by the electronic device when the old version application is run, and the configuration information at least includes the number of calls of each compilation unit in the installation package of the old version application, and the index of each compilation unit, the electronic device records the number of calls of each compilation unit in the memory, and when the old version application is exited from the running of the electronic device, the number of calls of each compilation unit recorded in the memory of the electronic device is cleared; Merging the multiple configuration information to obtain a first configuration file; Obtain an installation package of a new version of the application, and obtain a configuration file corresponding to the old version of the application as a first configuration file, wherein the new version of the application and the old version of the application are different versions of the same application; Obtaining identification information of a hotspot compilation unit corresponding to the old version application from the first configuration file; Based on the identification information, searching for a compilation unit matching the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit; Based on the target compilation unit, a configuration file corresponding to the new version of the application is generated as a second configuration file.
2. The method according to claim 1, characterized in that The obtaining, from the first configuration file, identification information of the hotspot compilation unit corresponding to the old version application program includes: Parsing the first configuration file, and obtaining the index of the hotspot compilation unit recorded in the first configuration file; The installation package of the old version application is read based on the index, and identification information of the hotspot compilation unit corresponding to the old version application is obtained.
3. The method according to claim 2, characterized in that The step of reading the installation package of the old version application based on the index and obtaining identification information of the hotspot compilation unit corresponding to the old version application includes: Read the installation package of the old version application based on the index, and obtain the descriptor of the hotspot compilation unit corresponding to the old version application; The step of searching, based on the identification information, a compilation unit matching the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit includes: The installation package of the new version application is traversed based on the descriptor, and a compilation unit matching the hotspot compilation unit is searched from multiple compilation units of the installation package of the new version application as the target compilation unit.
4. The method according to claim 1, characterized in that: The step of searching, based on the identification information, a compilation unit matching the hotspot compilation unit from multiple compilation units in the installation package of the new version of the application as a target compilation unit includes: Based on the identification information, searching for a compilation unit having the identification information from multiple compilation units in the installation package of the old version of the application, and obtaining a name of the compilation unit having the identification information; Based on the name, a compilation unit with the name is searched from multiple compilation units in the installation package of the new version of the application program as the target compilation unit.
5. The method according to claim 1, characterized in that The configuration information is captured by the electronic device through a hook function.
6. The method according to claim 1, characterized in that The configuration information at least includes the number of calls of each compilation unit in the multiple compilation units of the installation package of the old version application program, and the merging of the multiple configuration information to obtain the first configuration file includes: Merge the multiple configuration information to obtain the total number of calls of each compilation unit; Determine a hotspot compilation unit from the plurality of compilation units in descending order of the total call count of each compilation unit; Based on the hotspot compilation unit, the first configuration file is obtained.
7. The method according to claim 6, characterized in that The step of determining a hotspot compilation unit from the plurality of compilation units in descending order of the total number of calls of each compilation unit comprises: A preset proportion of coding units are selected from the plurality of coding units in descending order of the total call times of each coding unit as the hotspot coding units.
8. The method according to claim 7, characterized in that The preset ratio is determined based on a ratio of valid compilation units in a plurality of compilation units in the installation package of the old version application.
9. A configuration file optimization device, characterized in that: Applied to a server, the device comprises: a configuration information acquisition module, configured to receive configuration information recorded in the memory of the electronic device and uploaded each time the electronic device completes running the old version application, and obtain multiple configuration information, wherein the configuration information is captured by the electronic device when the old version application is running, and the configuration information at least includes the number of calls for each compilation unit in the installation package of the old version application, and the index of each compilation unit, the electronic device records the number of calls for each compilation unit in the memory, and when the old version application exits running on the electronic device, the number of calls for each compilation unit recorded in the memory of the electronic device is cleared; A first configuration file obtaining module, used for merging the plurality of configuration information to obtain a first configuration file; A first configuration file acquisition module, used to acquire an installation package of a new version application, and acquire a configuration file corresponding to the old version application as a first configuration file, wherein the new version application and the old version application are different versions of the same application; An identification information acquisition module, used to acquire identification information of a hotspot compilation unit corresponding to the old version application from the first configuration file; a target compilation unit search module, configured to search, based on the identification information, for a compilation unit matching the hotspot compilation unit from among multiple compilation units in the installation package of the new version of the application program, as a target compilation unit; The second configuration file acquisition module is used to generate a configuration file corresponding to the new version application as a second configuration file based on the target compilation unit.
10. A server, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, and the memory stores instructions. When the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 8.
