WO2021135947A1 - 热点代码处理方法、装置、电子设备及存储介质 - Google Patents
热点代码处理方法、装置、电子设备及存储介质 Download PDFInfo
- Publication number
- WO2021135947A1 WO2021135947A1 PCT/CN2020/136878 CN2020136878W WO2021135947A1 WO 2021135947 A1 WO2021135947 A1 WO 2021135947A1 CN 2020136878 W CN2020136878 W CN 2020136878W WO 2021135947 A1 WO2021135947 A1 WO 2021135947A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- hotspot
- code
- file
- application
- terminal device
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Definitions
- This application relates to the field of data processing technology, and more specifically, to a hot code processing method, device, electronic device, and storage medium.
- the virtual machine in order to improve the execution efficiency of the application program and improve the performance of the application program, during runtime, the virtual machine compiles the hot code in the code of the application program into machine code related to the local platform.
- the virtual machine In the electronic device, in order to improve the execution efficiency of the application program and improve the performance of the application program, during runtime, the virtual machine compiles the hot code in the code of the application program into machine code related to the local platform.
- This application proposes a hot code processing method, device, electronic equipment, and storage medium to improve the above problems.
- an embodiment of the present application provides a hotspot code processing method, the method includes: obtaining a core file of a target terminal device, the core file includes a hotspot configuration file of a system application, and the hotspot configuration file includes The hotspot code of the system application; when the target terminal device installs the system application through the kernel file, it compiles the hotspot code in the hotspot configuration file of the system application into machine code to obtain the system application The hotspot compilation file of the program; the target terminal device stores the hotspot compilation file.
- an embodiment of the present application provides a hotspot code processing method.
- the method includes: acquiring multiple hotspot code files of a target application, where the target application is a system application in a target terminal device, and the multiple A hotspot code file comes from multiple terminal devices that have run the target application; a hotspot configuration file is generated according to the multiple hotspot code files; when a hotspot code acquisition request for a system application in the target terminal device is received, Return the hotspot configuration file.
- an embodiment of the present application provides a hotspot code processing device.
- the device includes a core file obtaining module for obtaining a core file of a target terminal device, and the core file includes a hotspot configuration file of a system application.
- the hotspot configuration file includes the hotspot code of the system application; the installation module is used for the target terminal device to install the system application in the hotspot configuration file of the system application when the system application is installed through the core file.
- the hotspot code is compiled into machine code to obtain the hotspot compiled file of the system application; the storage module is used for the target terminal device to store the hotspot compiled file.
- an embodiment of the present application provides a hotspot code processing device.
- the device includes: a first file acquisition module for acquiring multiple hotspot code files of a target application, where the target application is a target terminal device
- the system application program of, the multiple hotspot code files come from multiple terminal devices that have run the target application;
- the second file acquisition module is used to generate a hotspot configuration file according to the multiple hotspot code files; return module , For returning the hotspot configuration file when a request for acquiring the hotspot code of the system application in the target terminal device is received.
- an embodiment of the present application provides an electronic device that includes one or more processors; a memory, which is electrically connected to the one or more processors; one or more programs, wherein the one One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method as described above.
- an embodiment of the present application provides a computer-readable storage medium in which a program code is stored, wherein the above-mentioned method is executed when the program code is running.
- Figure 1 shows a JIT architecture diagram provided by an embodiment of the present application.
- Fig. 2 shows a flowchart of a hotspot code processing method provided by an embodiment of the present application.
- Fig. 3 shows a flowchart of a hotspot code processing method provided by another embodiment of the present application.
- Fig. 4 shows a schematic diagram of interaction between a server and a terminal device provided by an embodiment of the present application.
- Fig. 5 shows another schematic diagram of interaction between a server and a terminal device provided by an embodiment of the present application.
- Fig. 6 shows a flowchart of a hotspot code processing method provided by another embodiment of the present application.
- Fig. 7 shows a flowchart of a hotspot code processing method provided by still another embodiment of the present application.
- Fig. 8 shows a functional module diagram of a hotspot code processing apparatus provided by an embodiment of the present application.
- Fig. 9 shows a functional module diagram of a hotspot code processing apparatus provided by another embodiment of the present application.
- FIG. 10 shows a structural block diagram of an electronic device proposed by an embodiment of the present application for executing the hotspot code processing method according to the embodiment of the present application.
- FIG. 11 shows a storage medium provided by an embodiment of the present application for storing or carrying program code for implementing the hotspot code processing method according to the embodiment of the present application.
- the code block In the virtual machine execution environment of the terminal device, if a code block runs frequently and the number of runs exceeds the set number of times, the code block is determined as a hot code, and the hot code is recorded and saved to the hot code File (profile).
- the code block may be a set of codes, or a method in the code.
- the hot code in the hot code file can be compiled by a just-in-time compiler (JIT, Just-In-Time Compiler) to obtain an odex file or be compiled by pre-compilation (AOT, Ahead-of-Time) Then get the oat file, the odex file compiled by the hot code and the oat file contain binary machine code, which can be directly handed over to the underlying processor (CPU, central processing unit) for execution. When the hot code needs to be executed again, it can be executed directly The compiled odex file or oat file of the hot code improves the running efficiency.
- JIT Just-In-Time Compiler
- AOT Ahead-of-Time
- the oat file contains the machine code for the program to run, it can be directly run by the Android runtime (ART, Android-Running-Time).
- the dex file if it is a cold code, it is executed by the java interpreter. If it is a hot code, it is compiled in real time by JIT and stored in the JIT code cache (JIT CODE CACHE). If you access the hotspot code again, you can execute the corresponding machine code directly from the cache.
- the hotspot code is put into the hotspot code file, and when the terminal device enters the idle (IDLE) and charged state, the hotspot code in the hotspot code file is executed by the AOT process to compile and generate an oat file.
- the code block Since the code block is run more than the set number of times, it is determined as the hot code. For the newly installed application, it needs to run in the terminal device for a period of time before the terminal device can determine the hot code according to the number of runs of the code in the application. . As for the system application of the terminal device, it is installed in the system before leaving the factory. When the user uses a new terminal device, the system application in the system application has not been determined to have a hot spot code, and the performance is poor.
- the embodiment of the application provides a hotspot code processing method.
- the kernel file obtained by kernel compilation includes the hotspot configuration file of the system application.
- the hotspot configuration file of the system application is Compile the hotspot code in, and store the compiled hotspot compilation file to improve the performance when using system applications. See Figure 2.
- This method includes:
- Step S110 Obtain a core file of the target terminal device, where the core file includes a hotspot configuration file of a system application, and the hotspot configuration file includes a hotspot code of the system application.
- the target terminal device can obtain the core file of the target terminal device.
- the core file can include the hotspot code of the system application of the target terminal device, and the hotspot code can be stored in the hotspot configuration file.
- the target terminal device may obtain the kernel file for system installation before leaving the factory.
- the system installation through the kernel file is not limited to before leaving the factory, and the user can also perform the system installation during other times of flashing and system upgrades.
- Step S120 when the target terminal device installs the system application through the kernel file, it compiles the hotspot code in the hotspot configuration file of the system application into machine code to obtain the hotspot compiled file of the system application.
- the system application can be installed.
- the kernel file includes the hotspot configuration file of the system application.
- the hotspot code in the hotspot configuration file of the system application is compiled.
- the hotspot code can be compiled into The machine code of the target terminal device. After the hotspot code in the hotspot configuration file is compiled, the hotspot compiled file is obtained.
- Step S130 The target terminal device stores the hotspot compiled file.
- the kernel file of the target terminal device includes the hotspot configuration file of the system application.
- the hotspot code in the hotspot configuration file is compiled into machine code and stored, After the system application is installed, it can get good running performance.
- This application also provides an embodiment, in which the storage of the hotspot configuration file is included. Specifically, referring to FIG. 3, the method provided in this embodiment includes:
- Step S210 Perform kernel compilation on the kernel source code of the target terminal device.
- Step S220 Store the hotspot configuration file of the system application in the compiled kernel file.
- the hotspot configuration file of the system application of the target terminal device can be obtained for hotspot compilation to obtain the hotspot compiled file.
- the hotspot configuration file of each system application in the target terminal device can be obtained from the server, and the hotspot configuration file of each system application includes the hotspot code of the system application.
- the hotspot configuration file of each system application can be obtained from multiple hotspot code files, which come from multiple terminal devices that have run the system application, so that the hotspot code in the hotspot configuration file can be Get a good running effect.
- the hotspot configuration file from the server, and may also be obtained from other electronic devices.
- the generation method of the hotspot configuration file is also not limited.
- the developer may select the code as the hotspot code in the hotspot configuration file according to the running characteristics of the system application.
- the hotspot configuration file obtained from the server may be the target terminal device or other electronic devices.
- the timing of putting the hotspot configuration file into the kernel file is not limited, and the execution device for compiling the kernel source code to obtain the kernel file is also not limited.
- step S210 is executed before step S220.
- the target terminal device may perform kernel compilation on the kernel source code to obtain the kernel file, and the target terminal device then stores the hotspot configuration file in the kernel file.
- other devices may also perform kernel compilation on the kernel source code to obtain a kernel file, such as a terminal device operated by a developer or other terminal device, or a server.
- the target terminal device can obtain the kernel file from other devices, and then store the hotspot configuration file in the kernel file.
- another device may also perform kernel compilation on the kernel source code to obtain a kernel file, and the other device then stores the hotspot configuration file in the kernel file.
- the target terminal device can obtain the core file including the hotspot configuration file from the other device.
- step S210 and step S220 can be performed in parallel. That is, in this embodiment, when the kernel source code of the target terminal device is kernel compiled, the hotspot configuration file of the system application can be stored in the compiled kernel file.
- the hotspot configuration file can be stored in a designated directory.
- the kernel source code of the target terminal device is compiled
- the hotspots of the system application in the designated directory
- the configuration file is stored in the compiled kernel file.
- a designated directory may be newly created, and the designated directory is used to store hotspot configuration files of system applications.
- the kernel source code you can add instruction code, which is used to instruct to obtain the hotspot configuration file in the newly-built designated directory when the kernel is compiled, and store it in the compiled kernel file.
- the specified directory may be created in the kernel source code in advance, or it may be newly created based on the instruction code.
- the hotspot configuration files of all system applications can be stored in the designated directory, and each hotspot configuration file includes unique identification information, indicating which hotspot configuration file each hotspot configuration file is.
- each hotspot configuration file is identified according to the unique identification information of the hotspot configuration file.
- each hotspot configuration file is identified according to the specified directory.
- the kernel file may include a target file
- the target file is a file used to store the hot code of the system application in the kernel file, and different system applications correspond to different target files.
- the target file may be a file automatically generated when the kernel is compiled to obtain the kernel file, or it may be an instruction code added to the kernel source code to instruct the kernel to generate the target file during compilation.
- the target file can be stored in the kernel file.
- the hotspot configuration file of the system application in the specified directory is stored in the target file in the kernel file.
- the hotspot configuration file in the specified directory is stored in the generated target file.
- Step S230 when the target terminal device installs the system application through the kernel file, it compiles the hotspot code in the hotspot configuration file of the system application into machine code to obtain the hotspot compiled file of the system application.
- the target terminal device can be flashed through the kernel file, that is, the target terminal device can be system installed through the kernel file.
- the kernel file includes the installation code of the system application program. When the system is installed through the kernel file, the system application program will be installed.
- the compilation of the hotspot code is triggered, and the hotspot code in the hotspot configuration file of the system application is compiled.
- the hotspot configuration file is stored in the target file
- the hotspot code in the target file is compiled to obtain the hotspot compiled file
- the hotspot compiled file includes the binary machine code after the hotspot code is compiled.
- the way to compile the hotspot code may be AOT compilation, and the hotspot compiled file after the compilation may correspond to an oat file.
- Step S240 The target terminal device stores the hotspot compiled file.
- the hotspot compilation file of each system application can be stored in the directory where each application stores the hotspot compilation file.
- the machine code in the hotspot compiled file can be run directly, which can improve the running speed.
- a hotspot configuration file is added to the kernel file obtained by kernel compilation, and the system application is installed on the installation code of the system application in the kernel file when the system is installed through the kernel file.
- the hotspot code in the hotspot configuration file can be compiled into machine code, so that the system application can run directly on the compiled machine code of the hotspot code at runtime, which improves the performance of the system application .
- a core file that does not include a hotspot configuration file may also be obtained.
- the target terminal device may obtain and store the hotspot configuration file of each system application.
- the hotspot configuration files of different system applications can be stored in a directory dedicated to storing hotspot codes in related system applications.
- compilation can be triggered to compile the hotspot code in the hotspot configuration file of each system application to obtain the hotspot compilation file. The compilation can be triggered before the target terminal device leaves the factory, or before the system application is used, or at other moments before the system application itself generates the hotspot code.
- the embodiment of the present application proposes a hotspot code processing method, which can obtain hotspot configuration files of a system application in a target terminal device from multiple terminal devices, so as to improve the performance of the system application in the target terminal device.
- the server 101 is connected to a plurality of terminal devices 102 in a network.
- the terminal device may be a smart device capable of running application programs, such as a smart phone, a tablet computer, an electronic device, or a smart wearable device.
- the target terminal device may be a smart device of the same type as the terminal device 102, or a smart device of a different type from the terminal device 102.
- the server may obtain the hotspot code file from multiple terminal devices that have generated the hotspot code file of the system application of the target terminal device, and then select the hotspot code from the obtained hotspot code files to generate a hotspot configuration file.
- the hotspot configuration file is returned.
- the server that generates the hotspot configuration file and the server that returns the hotspot configuration file to the terminal device may be the same server or different servers.
- the server 101 may generate a hotspot configuration file, and upon receiving the hotspot code acquisition request sent by the terminal device 102, return the hotspot configuration file to the terminal device 102.
- the server 1011 can generate the hotspot configuration file, and the server 1012 can receive the hotspot code acquisition request sent by the terminal device 102. , And upon receiving the hotspot code acquisition request sent by the terminal device 102, the server 1011 requests the hotspot code configuration file. When the server 1011 receives the hotspot code acquisition request sent by the server 1012, it returns the hotspot configuration file to the server 1012. The server 1012 then sends the obtained hotspot configuration file to the terminal device 102 requesting the hotspot code.
- each terminal device 102 can be connected to the server 1012 and the server 1011 in a network, and FIG. 5 only shows part of the network connection diagram.
- FIG. 6 which shows a hot code processing method provided by an embodiment of the present application, and the method can be applied to a server.
- the method may include:
- Step S310 Obtain a plurality of hotspot code files of the target application, the target application is a system application in the target terminal device, and the plurality of hotspot code files come from a plurality of terminal devices that have run the target application .
- the terminal device After the terminal device runs the application for a period of time, some code blocks have been run for a set number of times and are determined as hotspot codes. Therefore, the terminal device may store a hotspot code file including the hotspot code.
- the server may obtain the hotspot code of the application program from the terminal device, where the server may obtain the hotspot code of the application program generated in the terminal device by obtaining the hotspot code file in the terminal device.
- the server may obtain the hotspot code of the system application in the target terminal device.
- the system application in the target terminal device is defined as the target application.
- the server may obtain the hotspot code files of the target application from multiple terminal devices connected to the network, and obtains multiple hotspot code files from multiple electronic devices.
- Step S320 Generate a hotspot configuration file according to the multiple hotspot code files.
- each hotspot code file includes one or more hotspot codes.
- a hotspot code can be selected from the multiple hotspot code files to generate a hotspot configuration file.
- Step S330 When receiving the hotspot code acquisition request of the system application in the target terminal device, return the hotspot configuration file.
- the server When the server receives the hotspot code acquisition request for the system application in the target terminal device, it may return the generated hotspot configuration file to the requester.
- the server may obtain the system application hotspot code file of the target terminal device from multiple terminal devices, and select the hotspot code from the obtained hotspot code files to generate the hotspot configuration file.
- the target terminal device can obtain the hotspot configuration file, compile the hotspot configuration file before leaving the factory to obtain the hotspot compiled file, and improve the performance of the system application.
- This application also provides an embodiment, which describes a specific way of obtaining a hotspot configuration file of a system application.
- the hot code processing method provided by this embodiment includes:
- Step S410 Obtain multiple hot code files of a target application, the target application being a system application in a target terminal device, and the multiple hot code files are from multiple terminal devices that have run the target application .
- the multiple terminal devices that generate the hotspot code file and are used to obtain the hotspot code file may be a terminal device of the same model as the target terminal device, or a terminal device of a different model from the target terminal device.
- all or part of the terminal device connected to the server network can be used as a terminal device for the server to obtain the hotspot code file.
- the target terminal device may be terminal devices of certain manufacturers, terminal devices of certain models, and so on. Specifically, which terminal devices are used as target terminal devices are not limited in the embodiments of the present application, and which types of terminal devices are used as target terminal devices can be set in the server according to requirements.
- the server may obtain a terminal device list from an electronic device, and the terminal device list includes terminal devices that need to obtain system applications, that is, the terminal device in the terminal device list is the target terminal device.
- the system application program of the target terminal device may be an application program that is installed in the system before leaving the factory, or an application program that includes an installation code in a kernel file. Which applications are the system applications in the target terminal device can be set on the server, or the target terminal device or the developer background, etc., notify the server which applications are the system applications in the target terminal device.
- the terminal device list corresponding to various types of terminal devices, there may also be a system program list, and the system program list corresponding to each type of terminal device includes various system applications in the terminal device.
- the server may obtain hot code files of multiple applications from multiple terminal devices, such as obtaining hot code files of all applications in each terminal device. Then determine the hot code file of the system application in the target terminal device from the obtained hot code file.
- the server may only obtain the hotspot code file of the target application from multiple terminal devices.
- an application list may be stored in the server, and the application list includes multiple application programs.
- the server can determine whether each application in the stored application list is a system application of the target terminal device; if so, obtain the hot code file of the system application from multiple terminal devices.
- the server may also store a system application list of the target terminal device, and the system application list includes the system application program of the target terminal device. Get the hot code files of each system application in the system application list in turn.
- the manner in which the server obtains the hot code of the application from multiple terminal devices is not limited in the embodiment of the present application.
- the server when it obtains the hotspot code file of the application from multiple terminal devices, it can initiate a hotspot code file acquisition request to multiple terminal devices, and the hotspot code file acquisition request carries the hotspot to be acquired.
- the program ID of the application of the code file may return the hot code file of the application corresponding to the program identifier to the server according to the hot code file obtaining request, and the server obtains the hot code file returned by the terminal device.
- the server can update the hot code file of the application at a set frequency, that is, the server can send the hot code file to all or part of the terminal devices that have the corresponding application every preset time. Request, get the hotspot code file.
- the server sends the hotspot code file acquisition request, if a terminal device is not connected to the server network, when the terminal device is connected to the server network, it can send the hotspot code file acquisition request to the terminal device.
- the server and the terminal device may negotiate in advance, and the terminal device periodically sends the hot code file of the application that the server requires to the server, so that the server can obtain the hot code of the application sent in the terminal device. file.
- the negotiation between the server and the terminal device can be a negotiation with the manufacturer of the terminal device to set up the sending of the hotspot code file on the terminal device; optionally, the negotiation between the server and the terminal device can also be It is the pre-negotiation between the server and the related application program.
- the client side of the application program installed on the terminal device sends the hotspot code file to the server.
- the hotspot code file obtained by the server in addition to the hotspot code of the application, it can also include other information related to the application, such as the unique identity information of the application.
- the unique identity information can include the name of the application and the application.
- the version name and the version number of the application program can be used to accurately locate the identity of the hot code file and determine the hot code file of different applications.
- applications with different identity information can be considered as different applications.
- the program codes may be different, and the hotspot codes may be different.
- applications with the same name and the same version are treated as the same application, applications with different names are treated as different applications, and applications with the same name and different versions are treated as different applications, that is, The application with the same program code at the time of launch is regarded as the same application.
- Step S420 Select a hotspot code meeting preset conditions from the multiple hotspot code files, and generate a hotspot configuration file.
- multiple hotspot code files can be obtained from multiple terminal devices, and the multiple hotspot code files are obtained from different terminal devices.
- the hotspot configuration file of the system application is generated according to the multiple hotspot code files of the system application.
- the embodiment of the present application takes as an example to obtain a plurality of hotspot code files of a system application and generate a hotspot configuration file according to the plurality of hotspot code files.
- the manner of obtaining hotspot configuration files of various system applications can refer to the corresponding descriptions in the foregoing embodiments.
- the server When the server generates a hotspot configuration file based on multiple hotspot code files, it can select a hotspot code that meets preset conditions from the multiple hotspot code files to generate a hotspot configuration file. For example, if the server obtains the hotspot code files of the target application including A and B, selects the hotspot codes a1, a2, and a3 from A, and selects the hotspot code b1 from B, then it can generate the hotspot codes a1, a2, and a3. And b1's hotspot configuration file.
- the hotspot configuration file may only include the selected hotspot code, or may include other information, such as the unique identification information of the target application.
- the target application is a system application in the target terminal device.
- the preset conditions can be set according to requirements, so that the hotspot code included in the generated hotspot configuration file covers as much as possible the code blocks that the target user will frequently run when using the target application.
- the target user is a user who uses the hotspot profile.
- the preset condition may include the popularity of the hotspot code.
- the popularity of the hotspot code can be determined by the number of users who frequently use the function corresponding to the hotspot code, or in other words, measured by the number of occurrences of the hotspot code in multiple hotspot code files.
- the number of occurrences of the hotspot code in multiple hotspot code files is the number of hotspot code files that include the hotspot code. For example, if among the obtained multiple hot code files, 5 hot code files all include a certain hot code c, it can be determined that the number of occurrences of the hot code c is 5.
- the number of occurrences of each hotspot code in the multiple hotspot code files can be counted; according to the occurrence times of each hotspot code, select Multiple hot codes. Among them, the number of occurrences of the selected hotspot code is higher, that is, the number of occurrences of the selected hotspot code is not less than the number of occurrences of the unselected hotspot code.
- the hot code files of the target application obtained by the server include A, B, C, D, and E.
- Hotspot code file A includes hotspot codes c1, c2, c3, and c4;
- hotspot code file B includes hotspot codes c1, c2, c4;
- hotspot code file C includes hotspot codes c1 and c5;
- hotspot code file D includes hotspot codes c1, c4, c5 and c6.
- the different hot codes in the multiple hot code files obtained by the server include c1, c2, c3, c4, c5, and c6.
- the number of hot code files including hot code c1 is 4, and the number of occurrences of hot code c1 is 4;
- the number of hot code files including hot code c2 is 2, and the number of occurrences of hot code c2 is 2;
- the number of hot code files including hot code c3 is 1, and the number of occurrences of hot code c3 is 1;
- including hot code c4 The number of hotspot code files is 3, the number of occurrences of hotspot code c4 is 3;
- the number of hotspot code files including hotspot code c5 is 2, and the number of occurrences of hotspot code c5 is 2;
- the number of hotspot code files including hotspot code c6 Is 1, and the number of occurrences of hotspot code c6 is 1.
- the different hotspot codes corresponding to the highest number of occurrences are c1, c4, c2, c5, c6 and c3.
- the number of hot files corresponding to c5 and c2 is the same, which is 2; the number of hot files corresponding to c6 and c3 is the same , Both are 1.
- the hotspot codes at the top of c1, c4, c2, c5, c6 and c3 are selected, among which, The positions of c2 and c5 can be interchanged, and the positions of c6 and c3 can be interchanged.
- the front means that the selection is from the front to the back, or in other words, when the previous hot code is not selected, the unselected hot code is not selected, so that the number of occurrences of the selected hot code is not less than the appearance of the unselected hot code frequency.
- all hotspot codes can be used to generate hotspot configuration files.
- the hotspot codes c1, c2, c3, c4, c5, and c6 are selected to generate a hotspot configuration file, and the generated hotspot configuration file includes c1, c2, c3, c4, c5, and c6.
- part of the hotspot codes may be selected from all the hotspot codes to generate a hotspot configuration file.
- the generated hotspot configuration file can be set to include a preset number of hotspot codes.
- the preset number is selected according to the number of occurrences in descending order. Set the number of hot codes.
- the preset number can be a preset value. For example, in the foregoing example, if the preset number is 2, since the number of occurrences of c1 and c4 is more than the number of occurrences of c2, c5, c3, and c6, select c1 And c4, generate a hotspot configuration file including c1 and c4.
- the specific value of the preset number is not specifically limited.
- the method for determining the preset number may be to determine a range of use time, and obtain the target application generated by the use time within the use time range. Calculate the average number of hot codes of the obtained hot code files, and round up or down as the preset number.
- the use time range is 3 months, and 4 hot code files generated by the target application with the use time of 3 months are obtained. There are a total of different hot code files in the 4 hot code files, and the average number of hot code files is 17 /4, round down to get 4, with 4 as the preset number.
- the use duration range may be a duration range in which the target application can generate most of the hot codes. For users who are just starting to use the target application, most of the hot codes can basically represent code blocks that may run frequently.
- the hotspot codes can be selected according to the number of occurrences from large to small, so that the total data volume of the selected hotspot codes is less than the preset data volume and reaches the maximum selectable number.
- the data volume of the hotspot codes can be accumulated sequentially according to the number of occurrences from large to small. When the data volume of the accumulated hot codes is greater than or equal to the preset data volume, the last one of the accumulated hot codes is discarded. Get the selected hotspot code.
- the amount of data can be a number of bytes, and the unit can be B, KB, MB, GB, etc.
- the hotspot codes are selected cumulatively from c1, c4, c2, c5, c6, and c3. If the data volume of c1 and c4 is less than the preset data volume, the total data volume of c1, c4 and c2 is greater than the preset data volume. If the amount of data is larger, select c1 and c4 to generate hotspot configuration files.
- the ordering of the hotspot codes with the same number of occurrences may be parallel.
- the accumulated data amount of the hot code is greater than or equal to the preset data amount, the last one of the accumulated hot codes is discarded. If the last one of the accumulated hot codes has a hot code whose sorting is parallel, then the sorting is selected as parallel.
- the hotspot code to calculate the total amount of accumulated data.
- the hotspot codes are selected cumulatively from c1, c4, c2, c5, c6, and c3. If the data volume of c1 and c4 is less than the preset data volume, the total data volume of c1, c4 and c2 is greater than the preset data volume. Because the number of occurrences of c2 and c5 is the same, calculate whether the total data volume of c1, c4, and c5 is greater than the preset data volume.
- the total data volume of c1, c4, and c5 is greater than the preset data volume, select c1 and c4 to generate the hotspot profile; if the total data volume of c1, c4, and c5 is less than the preset data volume, select c1 c4 and c5, and continue to calculate whether the total data volume of c1, c4, c5, and c6 is greater than the preset data volume; if the total data volume of c1, c4, and c5 is equal to the preset data volume, select c1, c4, and c5 Used to generate a hotspot configuration file, and no longer continue to calculate whether the total data volume of c1, c4, c5, and c6 is greater than the preset data volume.
- the specific value of the preset data amount is not specifically limited.
- the preset data amount can be determined by determining a range of usage time, and obtaining the target application whose usage time is within the usage time range.
- the hot code file generated by the program and the average data volume of the obtained hot code file are calculated and rounded up or down as the preset data volume.
- the use time range is 3 months, and 4 hot code files generated by the target application with the use time of 3 months are obtained.
- the 4 hot code files have a total of 1200 kb of different hot code files, and the average data of the hot code files
- the selection can be made according to the popularity of the hotspot code, that is, a hotspot code with a popularity greater than or equal to a certain degree of popularity is selected.
- the popularity of the hot code can be represented by the number of appearances of the hot code, and the hot code with the number of appearances greater than or equal to a specified number can be selected.
- c1, c4, c2, and c5 are selected for generating hotspot configuration files.
- the running time of the target application is too short, and the generated hot codes may be insufficient or unrepresentative.
- most of the hot codes may be generated.
- most of the hot codes can basically represent code blocks that may run frequently. Therefore, in this embodiment, from the multiple hot code files, a hot code file whose use time of the target application program reaches a preset time length is selected as the target code file.
- the multiple hot code files obtained by the server include hot code file A, hot code file B, hot code file C, and hot code file D.
- the target application program that generates hot code file B and hot code file C The use time reaches the preset time, and the use time of the target application that generates the hot code file A and the hot code file D does not reach the preset time, then the hot code file B and the hot code file C are selected as the target code file.
- target code file as the hot code file for selecting the hot code, and select the hot code from the target code file according to the number of occurrences of each hot code, so that the number of occurrences of the selected hot code is not less than the number of occurrences of the unselected hot code .
- the selection method of selecting hotspot codes from the target code file can refer to the foregoing embodiment, such as selecting all hotspot codes in the target code file; or, for example, according to the number of occurrences. From large to small, select a preset number of hot codes; or select hot codes whose occurrence times are greater than or equal to a specified number; or, if the total data amount of the selected hot codes is less than the preset data amount, etc., it is not repeated here.
- the number of selected target code files can also be limited by specifying the duration.
- the designated duration is greater than the preset duration, and from the multiple hotspot code files, a hotspot code file whose use duration of the target application reaches the preset duration and is less than the designated duration is selected as the target code file.
- Hotspot codes are selected according to the number of corresponding hotspot files in descending order, if there are unselected hotspot codes and the selected hotspot codes have the same number of occurrences, the same number of occurrences can be selected. Hotspot codes that are not selected are also selected for generating hotspot configuration files.
- the system application programs of the target terminal device of different models may be different. Then, for each model of target terminal device, the server can obtain the hotspot configuration file of its system application.
- the acquisition method please refer to the acquisition method described above.
- the same system applications can be reused.
- the target terminal device of model H1 has a system application P1
- the target terminal device of model H2 also has a system application P1.
- the hotspot configuration file of the system application P1 of the target terminal device of model H1 is obtained, the hotspot configuration file It can also be used as a hotspot configuration file of the system application P1 of the target terminal device of model H2.
- Step S430 Upon receiving the hotspot code acquisition request of the system application in the target terminal device, return the hotspot configuration file.
- the server When the server receives the request for obtaining the hotspot code of the target application, it selects the hotspot configuration file according to the obtaining request and returns it to the requester.
- the server can generate hotspot configuration files of different system applications in the target terminal device.
- the server receives the hotspot code acquisition request, it can determine the hotspot configuration file of which system application to return to the requester according to the unique identification information of the application carried in the hotspot code acquisition request.
- the terminal device 102 requests the hotspot configuration file of the target application from the server 101 that generates the hotspot configuration file, and the server 101 may return the hotspot configuration file of the target application to the terminal. equipment.
- another server may also initiate an acquisition request for the hotspot code of the target application. That is, the server that generates the hotspot configuration file and the server that sends the hotspot configuration file to the target terminal device may be different servers.
- the server 1011 generates the hotspot configuration file.
- the terminal device 102 requests the server 1012 for the hotspot configuration file of the target application.
- the hotspot configuration file is generated on the server 1011, and the server 1012 requests the server 1011 for the hotspot configuration file.
- the server 1011 selects the hotspot configuration file of the target application and sends it to the server 1012, and the server 1012 sends the hotspot configuration file to the terminal device 102 after obtaining the hotspot configuration file from the server 1011.
- the server described is the server 1011 or the server 101 that generates the hotspot configuration file.
- the terminal device requesting the hotspot configuration file from the server may be the target terminal device or other terminal devices. If other terminal devices request the hotspot configuration file from the server, and if the target terminal device needs to obtain the hotspot configuration file, the target terminal device may then obtain the hotspot configuration file from the other terminal device.
- the server selects the hotspot code of the target application to generate a hotspot configuration file according to the popularity, so that the generated hotspot configuration file is more likely to include code blocks that are frequently run when new users use the target application.
- the hotspot compilation file of the target application is generated, the execution efficiency of the target application is improved, thereby improving the performance of the target application.
- An embodiment of the present application also provides a hotspot code processing device 500.
- the device 500 includes: a first file obtaining module 510 for obtaining multiple hotspot code files of a target application. Is a system application in a target terminal device, and the multiple hotspot code files come from multiple terminal devices that have run the target application; the second file acquisition module 520 is configured to generate Hotspot configuration file; the return module 530 is used to return the hotspot configuration file when a request for obtaining the hotspot code of the system application in the target terminal device is received.
- the first file obtaining module 510 may be used to determine whether each application in the application list is a system application of the target terminal device; if so, obtain the hotspot code of the system application from multiple terminal devices file.
- the first file obtaining module 510 may be used to obtain hotspot code files of the applications in the multiple terminal devices; determine the hotspot code files of the system applications in the target terminal device from the obtained hotspot code files.
- An embodiment of the present application also provides a hotspot code processing device 600.
- the device 600 includes a core file obtaining module 610 for obtaining a core file of a target terminal device, and the core file includes a system application program.
- the hotspot configuration file of the hotspot, the hotspot configuration file includes the hotspot code of the system application;
- the installation module 620 is used to install the system application when the target terminal device installs the system application through the kernel file
- the hotspot code in the hotspot configuration file is compiled into machine code to obtain the hotspot compiled file of the system application;
- the storage module 630 is used for the target terminal device to store the hotspot compiled file.
- the kernel file obtaining module 610 may be used to store the hotspot configuration file of the system application in the designated directory in the compiled kernel file when the kernel source code of the target terminal device is kernel compiled.
- the apparatus 600 may further include a file obtaining module, configured to obtain a hotspot configuration file of a system application in the target terminal device from a server, and the hotspot configuration file is obtained according to a plurality of hotspot code files.
- the hotspot code file comes from multiple terminal devices that have run the system application; the storage module is used to store the hotspot configuration file in the designated directory.
- the device 600 may further include a directory creation module, which is used to create a designated directory for storing the hotspot configuration file of the system application.
- a directory creation module which is used to create a designated directory for storing the hotspot configuration file of the system application.
- the kernel file obtaining module 610 may also be used to store the hotspot configuration file of the system application in a specified directory in a target file in a kernel file, where the target file is a target file in the kernel file for storing the The file of the hot code of the system application.
- the installation module 620 may be used to install the system application when the kernel file is used for system installation; when the system application is installed, to compile the hot code in the target file Is the machine code.
- the coupling or direct coupling or communication connection between the displayed or discussed modules may be through some interfaces, and the indirect coupling or communication connection between the devices or modules may be electrical, Mechanical or other forms.
- the functional modules in the various embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module.
- the above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.
- FIG. 10 shows a structural block diagram of an electronic device 700 provided by an embodiment of the present application.
- the electronic device 700 in this application may be a server or a terminal device, that is, it may be a server, a target terminal device or other terminal devices.
- the electronic device 700 may include one or more of the following components: a processor 710, a memory 720, and one or more programs, where one or more programs may be stored in the memory 720 and configured to be processed by one or more
- the device 710 executes, and one or more programs are configured to execute the method described in the foregoing method embodiment.
- the processor 710 may include one or more processing cores.
- the processor 710 uses various interfaces and lines to connect various parts of the entire electronic device 700, and executes by running or executing instructions, programs, code sets, or instruction sets stored in the memory 720, and calling data stored in the memory 720.
- Various functions and processing data of the electronic device 700 may adopt at least one 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).
- DSP Digital Signal Processing
- FPGA Field-Programmable Gate Array
- PLA Programmable Logic Array
- the processor 710 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), a modem, and the like.
- the CPU mainly processes the operating system, user interface, and application programs; the GPU is used for rendering and drawing of display content; the modem is used for processing wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 710, but may be implemented by a communication chip alone.
- the memory 720 may include random access memory (RAM) or read-only memory (Read-Only Memory).
- a hotspot code processing device may be stored in the memory 720.
- the hotspot code processing device may be the aforementioned device 500 or device 600.
- the memory 720 may be used to store instructions, programs, codes, code sets or instruction sets.
- the memory 720 may include a program storage area and a data storage area, where the program storage area may store instructions for implementing the operating system and instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.) , Instructions used to implement the following various method embodiments, etc.
- the data storage area can also store data created by the electronic device 700 during use, and the like.
- FIG. 11 shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application.
- the computer-readable storage medium 800 stores program code, and the program code can be invoked by a processor to execute the method described in the foregoing method embodiment.
- the computer-readable storage medium 800 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
- the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium.
- the computer-readable storage medium 800 has storage space for the program code 810 for executing any method steps in the above-mentioned methods. These program codes can be read from or written into one or more computer program products.
- the program code 810 may be compressed in a suitable form, for example.
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
一种热点代码处理方法、装置、电子设备及存储介质,在该方法中,服务器可以生成热点配置文件。目标终端设备可以获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码(S110)。目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件(S120),所述目标终端设备将所述热点编译文件存储(S130),从而在系统应用程序未生成有热点代码的情况下,也可以具有良好的性能。
Description
相关申请的交叉引用
本申请要求于2019年12月31日提交的申请号为201911408505.0的中国申请的优先权,其在此出于所有目的通过引用将其全部内容并入本文。
本申请涉及数据处理技术领域,更具体地,涉及一种热点代码处理方法、装置、电子设备及存储介质。
在电子设备中,为了提高应用程序的执行效率以提高应用程序的性能,在运行时,虚拟机会将应用程序的代码中的热点代码编译成与本地平台相关的机器码。但是,对于应用程序而言,需要运行一段时间确定哪些代码为热点代码,在应用程序安装初期,无法通过热点代码的编译提升应用程序的性能。
发明内容
本申请提出了一种热点代码处理方法、装置、电子设备及存储介质,以改善上述问题。
第一方面,本申请实施例提供了一种热点代码处理方法,该方法包括:获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码;目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件;所述目标终端设备将所述热点编译文件存储。
第二方面,本申请实施例提供了一种热点代码处理方法,该方法包括:获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备;根据所述多个热点代码文件生成热点配置文件;在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
第三方面,本申请实施例提供了一种热点代码处理装置,该装置包括:内核文件获取模块,用于获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码;安装模块,用于目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件;存储模块,用于所述目标终端设备将所述热点编译文件存储。
第四方面,本申请实施例提供了一种热点代码处理装置,该装置包括:第一文件获取模块,用于获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备;第二文件获取模块,用于根据所述多个热点代码文件生成热点配置文件;返回模块,用于 在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
第五方面,本申请实施例提供了一种电子设备,该电子设备包括一个或多个处理器;存储器,与所述一个或多个处理器电连接;一个或多个程序,其中所述一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行如上述的方法。
第六方面,本申请实施列提供一种计算机可读存储介质,所述计算机可读存储介质中存储有程序代码,其中,在所述程序代码运行时执行上述的方法。
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请实施例提供的一种JIT架构图。
图2示出了本申请一个实施例提供的热点代码处理方法的流程图。
图3示出了本申请另一个实施例提供的热点代码处理方法的流程图。
图4示出了本申请实施例提供的服务器与终端设备的一种交互示意图。
图5示出了本申请实施例提供的服务器与终端设备的另一种交互示意图。
图6示出了本申请又一个实施例提供的热点代码处理方法的流程图。
图7示出了本申请再一个实施例提供的热点代码处理方法的流程图。
图8示出了本申请一实施例提供的热点代码处理装置的功能模块图。
图9示出了本申请另一实施例提供的热点代码处理装置的功能模块图。
图10示出了本申请实施例提出的用于执行根据本申请实施例的热点代码处理方法的电子设备的结构框图。
图11示出了本申请实施例提供的用于保存或者携带实现根据本申请实施例的热点代码处理方法的程序代码的存储介质。
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。
在终端设备的虚拟机执行环境中,若某个代码块频繁运行,运行次数超过设定的次数,将该代码块确定为热点代码(hot code),将该热点代码记录下来并保存到热点代码文件(profile)。其中,可以理解的,该代码块可以是一个代码集合,或者是代码中的一个方法(method)。
为了提高热点代码的运行效率,可以将热点代码文件中的热点代码经由即时编译器(JIT,Just-In-Time Compiler)编译后获得odex文件或者经预编译(AOT,Ahead-of-Time)编译后得到oat文件,热点代码编译后的odex文件以及oat文件中包含的是二进制机器码,可直接交由底层处理器(CPU,central processing unit)执行,当再次需要执行热点代码时,可以直接执行热点代码编译后的odex文件或者oat文件,提高了运行效率。
以如图1所示的安卓系统中的JIT架构为例,由于oat文件中包含的是程序运行的机器码,因此可以直接被安卓运行时(ART,Android-Running-Time)运行。而dex文件中,如果是非热点代码(cold code),是交由java解释器(Interpreter)执行,如果是热点代码,则交由JIT实时编译后存放到JIT代码缓存(JIT CODE CACHE)中,下次再次访问该热点代码,则可以直接从cache中执行对应的机器码。并且,将热点代码放入热点代码文件,当终端设备进入空闲(IDLE)且充电状态时,将热点代码文件中的该热点代码执行AOT 过程进行编译生成oat文件。
由于代码块的运行次数超过设定的次数才确定为热点代码,则对于新安装的应用程序而言,需要在终端设备中运行一段时间,终端设备才能根据应用程序中代码的运行次数确定热点代码。而对于终端设备的系统应用程序,在出厂前即在系统中安装,用户在使用新的终端设备时,其中的系统应用程序未确定有热点代码,性能较差。
本申请实施例提供了一种热点代码处理方法,在内核编译获得的内核文件中包括系统应用程序的热点配置文件,在通过内核文件对系统应用程序进行安装时,将系统应用程序的热点配置文件中的热点代码进行编译,并存储编译后的热点编译文件,以提升在使用系统应用程序时的性能请参见图2,该方法包括:
步骤S110:获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码。
对目标终端设备的内核源码进行内核编译,可以获得目标终端设备的内核文件,如获得的内核文件为内核编译后的镜像文件。因此,目标终端设备可以获取到目标终端设备的内核文件,该内核文件中可以包括目标终端设备的系统应用程序的热点代码,该热点代码可以存放于热点配置文件中。在本申请实施例中,目标终端设备可以在出厂前获得内核文件进行系统安装。当然,在本申请实施例中,通过内核文件进行系统安装也并不限制为出厂前,用户其他时候的刷机以及系统升级时也可以进行系统安装。
步骤S120:目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件。
在通过内核文件进行系统安装时,可对系统应用程序进行安装。
在该内核文件中,包括系统应用程序的热点配置文件,在通过内核文件进行系统应用程序安装时,对系统应用程序的热点配置文件中的热点代码进行编译,具体的,可以将热点代码编译为目标终端设备的机器码。热点配置文件中热点代码编译后获得热点编译文件。
步骤S130:所述目标终端设备将所述热点编译文件存储。
将编译后的热点编译文件存储,从而在目标终端设备运行系统应用程序时,以及系统安装后系统应用程序首次运行时,由于热点代码已经编译为机器码,运行速度更快,系统应用程序的性能更好。
在本申请实施例中,目标终端设备的内核文件中包括系统应用程序的热点配置文件,在通过内核文件进行系统应用程序的安装时,将热点配置文件中的热点代码编译为机器码并存储,使系统应用程序在安装后,即可获得良好的运行性能。
本申请还提供了一种实施例,在该实施例中,包括对热点配置文件的存放。具体的,请参见图3,该实施例提供的方法包括:
步骤S210:对所述目标终端设备的内核源码进行内核编译。
步骤S220:将系统应用程序的热点配置文件存放到编译后的内核文件中。
在对目标终端设备进行内核编译前,可以获取所述目标终端设备的系统应用程序的热点配置文件,用于进行热点编译获得热点编译文件。
在本申请实施例中,可以从服务器获取目标终端设备中各系统应用程序的热点配置文件,每个系统应用程序的热点配置文件中包括该系统应用程序的热点代码。其中,每个系统应用程序的热点配置文件可以根据多个热点代码文件获得,该多个热点代码文件来自于运行过该系统应用程序的多个终端设备,以使热点配置文件中的热点代码可以获得良好的运行效果。
当然,在本申请实施例中,并不限定为热点配置文件从服务器获取,也可以是从其他电子设备获取。热点配置文件的生成方式也不限定,例如也可以是由开发人员根据系统应用程序的运行特征选取代码作为热点配置文件中的热点代码。
在本申请实施例中,从服务器获取热点配置文件的可以是目标终端设备,也可以是其他电子设备。
在本申请实施例中,热点配置文件放入内核文件的时机并不限定,对内核源码进行编译获得内核文件的执行设备也并不限定。
在一种实施方式中,可以是,对内核源码进行编译获得内核文件,再将热点配置文件存放于内核文件中。也就是说,在该实施方式中,步骤S210先于步骤S220执行。
可选的,在该实施方式中,可以由该目标终端设备对内核源码进行内核编译获得内核文件,目标终端设备再将热点配置文件存放于内核文件中。
可选的,在该实施方式中,也可以由其他设备对内核源码进行内核编译获得内核文件,如开发人员操作的终端设备或者其他终端设备,或者服务器等。目标终端设备可以从其他设备获取到内核文件,再将热点配置文件存放于内核文件中。
可选的,在该实施方式中,也可以由其他设备对内核源码进行内核编译获得内核文件,该其他设备再将热点配置文件存放于内核文件中。目标终端设备可以从该其他设备获取到包括热点配置文件的内核文件。
在另一种实施方式中,步骤S210与步骤S220可以并行执行。即,在该实施方式中,对所述目标终端设备的内核源码进行内核编译时,可以将系统应用程序的热点配置文件存放到编译后的内核文件中。
具体的,在该实施方式中,在获得热点配置文件后,可以将热点配置文件存放在指定目录下,对所述目标终端设备的内核源码进行内核编译时,将指定目录下系统应用程序的热点配置文件存放到编译后的内核文件中。
在该实施方式中,可以新建有指定目录,该指定目录用于存放系统应用程序的热点配置文件。在内核源码中,可以添加指令代码,该指令代码用于指示在进行内核编译时,获取新建的指定目录下的热点配置文件,并存放到编译后的内核文件中。其中,该指定目录可以是预先创建于内核源码,也可以是基于指令代码进行新建。
其中,可选的,所有系统应用程序的热点配置文件都可以存储于该指定目录下,每个热点配置文件包括唯一身份信息,表明各个热点配置文件分别为哪一系统应用程序的热点配置文件。在将指定目录下的热点配置文件存放到编译后的内核文件中时,根据热点配置文件的唯一身份信息对各个热点配置文件进行辨识。
可选的,也可以是,对应不同系统应用程序分别创建指定目录,将不同系统应用程序的热点配置文件存放在相应的指定目录下。在将指定目录下的热点配置文件存放到编译后的内核文件中时,根据指定目录辨识各个热点配置文件。
在本申请实施例中,在内核文件中可以包括目标文件,该目标文件为内核文件中用于存放系统应用程序的热点代码的文件,不同的系统应用程序对应不同的目标文件。其中,该目标文件可以是内核编译获得内核文件时自动生成的文件,也可以是通过内核源码中加入的指令代码,指示内核编译时生成该目标文件。
在将热点配置文件存放于内核文件中时,可以存放于内核文件中的该目标文件。例如在上述另一种实施方式中,对所述目标终端设备的内核源码进行内核编译时,将指定目录下系统应用程序的热点配置文件存放于内核文件中的目标文件。或者说,在对目标终端设备的内核源码进行编译形成内核文件的过程中,就将指定目录下的热点配置文件存放到生成的目标文件中。
步骤S230:目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件。
获得内核文件后,可以通过内核文件对目标终端设备进行刷机,即可以通过内核文件对目标终端设备进行系统安装。在内核文件中,包括系统应用程序的安装代码,在通过内 核文件进行系统安装时,会对系统应用程序进行安装。
在对系统应用程序进行安装时,触发对热点代码的编译,对系统应用程序的热点配置文件中的热点代码进行编译。具体的,若将热点配置文件存放在目标文件中,则在进行系统应用程序安装时,将目标文件中的热点代码编译,获得热点编译文件,热点编译文件中包括热点代码编译后的二进制机器码。
在本申请实施例中,对热点代码进行编译的方式可以是AOT编译,编译后的热点编译文件对应可以是oat文件。
步骤S240:所述目标终端设备将所述热点编译文件存储。
将热点编译文件进行存储。其中,各个系统应用程序的热点编译文件可以存储在各个应用程序用于存放热点编译文件的目录下。在系统应用程序运行时,热点编译文件中的机器码可以直接运行,可以提高运行速度。
在本申请实施例中,在内核编译获得的内核文件中添加热点配置文件,通过内核文件进行系统安装时,对内核文件中系统应用程序的安装代码进行系统应用程序的安装。在系统应用程序的安装时,可以将热点配置文件中的热点代码编译为机器码,从而使系统应用程序在运行时可以直接对热点代码编译后的机器码直接运行,提高了系统应用程序的性能。
另外,在本申请实施例中,也可以获取不包括热点配置文件的内核文件,目标终端设备通过该内核文件进行系统安装后,可以获取并存储各系统应用程序的热点配置文件。不同的系统应用程序的热点配置文件,可以存放在相关系统应用程序专门用于存放热点代码的目录下。在将热点配置文件存放后,可以触发编译,对各个系统应用程序的热点配置文件中的热点代码进行编译,获得热点编译文件。该编译的触发可以在目标终端设备出厂前,或者在系统应用程序使用前等,或者也可以在系统应用程序自身生成热点代码前的其他时刻。
本申请实施例提出了一种热点代码处理方法,可以从多个终端设备获取目标终端设备中系统应用程序的热点配置文件,提升目标终端设备中系统应用程序的性能。如图4所示,服务器101与多个终端设备102网络连接。该终端设备可以是智能手机、平板电脑、电子设备、智能穿戴设备等能够运行应用程序的智能设备。目标终端设备可以是与该终端设备102相同类型的智能设备,也可以是与终端设备102不同类型的智能设备。
服务器可以从已经产生有目标终端设备的系统应用程序的热点代码文件的多个终端设备中获取热点代码文件,再从获得的热点代码文件中选择热点代码生成热点配置文件。在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将热点配置文件返回。
在本申请实施例中,生成热点配置文件的服务器与返回热点配置文件到终端设备的服务器可以是同一个服务器或不同的服务器。当是同一个服务器时,如图4所示,服务器101可以生成热点配置文件,并且在接收到终端设备102发送的热点代码的获取请求,向终端设备102返回热点配置文件。
当生成热点配置文件的服务器与返回热点配置文件到终端设备的服务器为不同的服务器,如图5所示,服务器1011可以生成热点配置文件,服务器1012可以接收终端设备102发送的热点代码的获取请求,并且在接收到终端设备102发送的热点代码的获取请求,向服务器1011请求热点代码配置文件。服务器1011在接收到服务器1012发送的热点代码的获取请求时,将热点配置文件返回给服务器1012。服务器1012再将获取到的热点配置文件发送给请求热点代码的终端设备102。在图5中,各个终端设备102都可以和服务器1012以及服务器1011网络连接,图5中仅示出了部分网络连接示意。
下面将对本申请实施例进行详细的说明。
请参阅图6,示出了本申请实施例提供的一种热点代码处理方法,该方法可应用于服务器。具体的,该方法可以包括:
步骤S310:获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设 备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备。
终端设备在对应用程序运行一段时间后,有些代码块的运行次数达到设定的次数,被确定为热点代码,因此,在终端设备中,可以存储有包括热点代码的热点代码文件。
服务器可以从终端设备端获取应用程序的热点代码,其中,服务器可以通过获取终端设备中的热点代码文件的方式获取终端设备中产生的应用程序的热点代码。
在本申请实施例中,服务器可以获取目标终端设备中系统应用程序的热点代码。为便于描述,定义目标终端设备中的系统应用程序为目标应用程序。
服务器可以从网络连接的多个终端设备中获取到目标应用程序的热点代码文件,则从多个电子设备获取到多个热点代码文件。
步骤S320:根据所述多个热点代码文件生成热点配置文件。
服务器获取到的多个热点代码文件中,每个热点代码文件包括一个或多个热点代码。可以从该多个热点代码文件中选择热点代码生成热点配置文件。
步骤S330:在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
当服务器接收到对目标终端设备中系统应用程序的热点代码获取请求,可以将生成的热点配置文件返回给请求方。
在本申请实施例中,服务器可以从多个终端设备中获取目标终端设备中系统应用程序热点代码文件,并从获取到的热点代码文件中选择热点代码生成热点配置文件。使目标终端设备可以获取到该热点配置文件,在出厂前即对热点配置文件进行编译获得热点编译文件,提升系统应用程序的性能。
本申请还提供了一实施例,描述了获取系统应用程序的热点配置文件的具体方式。请参见图7,该实施例提供的热点代码处理方法包括:
步骤S410:获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备。
在本申请实施例中,生成有热点代码文件并用于获取热点代码文件的多个终端设备,可以是与目标终端设备型号相同的终端设备,也可以是与目标终端设备型号不同的终端设备。可选的,与服务器网络连接的终端设备的全部或部分,都可以作为服务器获取热点代码文件的终端设备。
目标终端设备可以是某些厂商的终端设备、某些型号的终端设备等。具体以哪些终端设备作为目标终端设备在本申请实施例中并不限定,可以根据需求在服务器设置将哪些类型的终端设备作为目标终端设备。例如,服务器可以从一电子设备获取终端设备列表,该终端设备列表包括需要获取系统应用程序的终端设备,即该终端设备列表中的终端设备为目标终端设备。
目标终端设备的系统应用程序可以是出厂前在系统中进行安装的应用程序,或者说在内核文件中包括了安装代码的应用程序。哪些应用程序为目标终端设备中的系统应用程序可以在服务器设置,或者由目标终端设备或者开发者后台等通知服务器哪些应用程序为目标终端设备中的系统应用程序。例如,可选的,终端设备列表中,对应各个型号的终端设备,还可以有系统程序列表,每个型号的终端设备对应的系统程序列表包括该终端设备中的各种系统应用程序。
在一种实施方式中,服务器可以从多个终端设备中获取多种应用程序的热点代码文件,如获取各终端设备中所有应用程序的热点代码文件。再从获取的热点代码文件中确定目标终端设备中系统应用程序的热点代码文件。
在另一种实施方式中,服务器可以仅从多个终端设备获取目标应用程序的热点代码文 件。
可选的,在该实施方式中,服务器中可以存储有应用程序列表,该应用程序列表中包括多种应用程序。服务器可以判断存储的应用程序列表中各个应用程序是否为目标终端设备的系统应用程序;若是,从多个终端设备中获取所述系统应用程序的热点代码文件。
可选的,在该实施方式中,服务器也可以存储有目标终端设备的系统应用程序列表,系统应用程序列表中包括目标终端设备的系统应用程序。依次获取系统应用程序列表中各系统应用程序的热点代码文件。
服务器从多个终端设备获取应用程序的热点代码的方式在本申请实施例中并不限定。
在一种具体的实施方式中,服务器从多个终端设备获取应用程序的热点代码文件时,可以向多个终端设备发起热点代码文件获取请求,并在该热点代码文件获取请求中携带需要获取热点代码文件的应用程序的程序标识。多个终端设备可以根据该热点代码文件获取请求,向服务器返回程序标识对应的应用程序的热点代码文件,服务器获取到终端设备返回的热点代码文件。
在该实施方式中,服务器可以按照设置的频率更新应用程序的热点代码文件,也就是说,服务器可以每隔预设的时间,向安装有相应应用程序的全部或者部分终端设备发送热点代码文件获取请求,获取热点代码文件。服务器在发送热点代码文件获取请求时,若有终端设备未与服务器网络连接,则当该终端设备在与服务器网络连接时,可以向该终端设备发送热点代码文件获取请求。
在另一种实施方式中,服务器和终端设备可以预先协商,由终端设备定期将服务器有需求的应用程序的热点代码文件发送到服务器,从而服务器可以获取到终端设备中发送的应用程序的热点代码文件。在该实施方式中,可选的,服务器与终端设备的协商,可以是与终端设备的厂商协商,在终端设备进行热点代码文件的发送设置;可选的,服务器与终端设备的协商,也可以是服务器与相关应用程序预先协商,当应用程序在终端设备安装,由应用程序安装于终端设备的客户端将热点代码文件发送到服务器。
在服务器获取到的热点代码文件中,除了包括应用程序的热点代码,还可以包括其他与应用程序相关的信息,如应用程序的唯一身份信息,该唯一身份信息可以包括应用程序的名称、应用程序的版本名称以及应用程序的版本号等,以准确定位到热点代码文件的身份,确定不同应用程序的热点代码文件。
在本申请实施例中,不同身份信息的应用程序,可以认为是不同的应用程序。可选的,由于同一名称不同版本的应用程序,其程序代码可能有不同,可能产生的热点代码也不同。在本申请实施例中,将同一名称同一版本的应用程序作为相同应用程序进行处理,不同名称的应用程序作为不同的应用程序,相同名称不同版本的应用程序作为不同的应用程序,也就是说,将上线时程序代码相同的应用程序作为相同的应用程序。
步骤S420:从所述多个热点代码文件中选择满足预设条件的热点代码,生成热点配置文件。
对于目标终端设备的每一系统应用程序,可以从多个终端设备获取到多个热点代码文件,该多个热点代码文件从不同的终端设备获得。根据该系统应用程序的多个热点代码文件生成该系统应用程序的热点配置文件。本申请实施例以获取一系统应用程序的多个热点代码文件,并根据多个热点代码文件生成热点配置文件为例进行说明。获取各种系统应用程序的热点配置文件的方式可以参阅前述实施例中的对应描述。
服务器根据多个热点代码文件生成热点配置文件时,可以从多个热点代码文件中选择满足预设条件的热点代码生成热点配置文件。例如,服务器获取到目标应用程序的热点代码文件包括A和B,从A中选择到热点代码a1、a2以及a3,从B中选择到热点代码b1,则可以生成包括热点代码a1、a2、a3以及b1的热点配置文件。该热点配置文件可以仅包括选择的热点代码,也可以包括其他信息,如目标应用程序的唯一身份信息。该目标应用 程序为目标终端设备中的系统应用程序。
在本申请实施例中,预设条件可以根据需求设置,使生成的热点配置文件包括的热点代码尽可能覆盖到目标用户在使用目标应用程序时会经常运行到的代码块。该目标用户为使用该热点配置文件的用户。
由于热点代码的热度越高,代表该热点代码越可能是获取热点配置文件的电子设备中频繁运行的代码。在本申请实施例中,该预设条件可以包括热点代码的热度。其中,热点代码的热度可以由经常使用该热点代码对应的功能的用户数量确定,或者说,通过热点代码在多个热点代码文件中的出现次数衡量。
在本申请实施例中,热点代码在多个热点代码文件中的出现次数,即包括该热点代码的热点代码文件数量。例如,若获取到的多个热点代码文件中,有5个热点代码文件都包括某热点代码c,则可以确定该热点代码c的出现次数为5。
在本申请实施例中,对于所述多个热点代码文件中的不同热点代码,可以统计每个热点代码在所述多个热点代码文件中的出现次数;根据每个热点代码的出现次数,选择多个热点代码。其中,选择的热点代码的出现次数靠前,即选择的热点代码的出现次数不小于未选择的热点代码的出现次数。
例如,服务器获取到目标应用程序的热点代码文件包括A、B、C、D以及E。热点代码文件A中包括热点代码c1,c2,c3以及c4;热点代码文件B中包括热点代码c1,c2,c4;热点代码文件C中包括热点代码c1以及c5;热点代码文件D中包括热点代码c1,c4,c5以及c6。
则服务器获取到的多个热点代码文件中的不同热点代码包括c1,c2,c3,c4,c5以及c6,其中,包括热点代码c1的热点代码文件的数量为4,热点代码c1的出现次数为4;包括热点代码c2的热点代码文件的数量为2,热点代码c2的出现次数为2;包括热点代码c3的热点代码文件的数量为1,热点代码c3的出现次数为1;包括热点代码c4的热点代码文件的数量为3,热点代码c4的出现次数为3;包括热点代码c5的热点代码文件的数量为2,热点代码c5的出现次数为2;包括热点代码c6的热点代码文件的数量为1,热点代码c6的出现次数为1。
对应出现次数由多到少的不同的热点代码分别为c1,c4,c2,c5,c6以及c3,其中c5和c2对应的热点文件数量相同,都为2;c6和c3对应的热点文件数量相同,都为1。
则从依次排列的多个不同热点代码c1,c2,c3,c4,c5以及c6中选择热点代码时,选择的为c1,c4,c2,c5,c6以及c3中靠前的热点代码,其中,c2和c5的位置可以互换,c6和c3的位置可以互换。该靠前表示,从前往后选,或者说,在前面的热点代码未选的情况下,不选后面未选的热点代码,使选择的热点代码的出现次数不小于未选择的热点代码的出现次数。
作为一种具体的实施方式,可以将所有热点代码用于生成热点配置文件。例如在前述举例说明中,选择热点代码c1,c2,c3,c4,c5以及c6生成热点配置文件,在生成的热点配置文件中包括c1,c2,c3,c4,c5以及c6。
为了减少选择的热点代码的总的数据量,在本申请实施例中,可以从所有热点代码中选择部分热点代码,用于生成热点配置文件。
作为一种具体的实施方式,可以设置生成的热点配置文件包括预设数量的热点代码,在根据每个热点代码的出现次数,选择多个热点代码时,按照出现次数由大到小,选择预设数量的热点代码。
该预设数量可以是预先设置的一个值,例如,在前述举例说明中,若预设数量为2,由于c1以及c4的出现次数比c2,c5,c3以及c6的出现次数多,则选择c1以及c4,生成包括c1以及c4的热点配置文件。
在本申请实施例中,预设数量的具体数值并不做具体限定,例如,预设数量的确定方 式可以是,确定一个使用时长范围,获取使用时长在该使用时长范围内的目标应用程序产生的热点代码文件,并计算获得的热点代码文件的平均热点代码数量,向上取整或向下取整作为预设数量。例如,使用时长范围为3个月,获取使用时长为3个月的目标应用程序产生的热点代码文件4个,该4个热点代码文件中总共有不同的热点代码17,平均热点代码数量为17/4,向下取整得到4,以4作为预设数量。其中,该使用时长范围可以是目标应用程序可以产生大部分热点代码的一个时长范围。对于刚开始使用目标应用程序的用户,该大部分的热点代码已经基本可以代表可能频繁运行的代码块。
该预设数量也可以根据预先设置的比例计算,具体可以计算不同热点代码的数量与比例的乘积,获得预设数量。其中,若不同热点代码的数量与比例的乘积并非整数,可以根据需求向上取整或向下取整。例如在前述举例说明中,若预先设置的比例为0.3,因为不同热点代码的数量与比例的乘积为6*0.3=1.8,向上取整,得到预设数量为2,选择c1以及c4用于生成热点配置文件。
作为一种实施方式,可以按照出现次数由大到小选择热点代码,使选择的热点代码的总数据量小于预设数据量,且达到最大的可选择数量。在该实施方式中,可以按照出现次数由大到小,依次累计热点代码的数据量,当累计到热点代码的数据量大于或等于预设数据量时,舍弃累计的热点代码中的最后一个,得到选择的热点代码。其中,数据量可以是一个字节数,单位可以是B,KB,MB,GB等。
例如在前述举例说明中,从c1,c4,c2,c5,c6以及c3依次累计选择热点代码,若c1和c4的数据量小于预设数据量,c1、c4和c2的总数据量大于预设的数据量,则选择c1以及c4用于生成热点配置文件。
可选的,在本申请实施例中,当按照出现次数由大到小的排序选择热点代码时,出现次数相同的热点代码的排序可以是并列。当累计到热点代码的数据量大于或等于预设数据量时,舍弃累计的热点代码中的最后一个,若该累计的热点代码中的最后一个有排序是并列的热点代码,则选择排序是并列的热点代码,计算累计的总的数据量。
例如在前述举例说明中,从c1,c4,c2,c5,c6以及c3依次累计选择热点代码,若c1和c4的数据量小于预设数据量,c1、c4和c2的总数据量大于预设的数据量,由于c2和c5出现次数相同,再计算c1、c4以及c5的总数据量是否大于预设的数据量。若c1、c4以及c5的总数据量大于预设的数据量,则选择c1以及c4用于生成热点配置文件;若c1、c4以及c5的总数据量小于预设的数据量,则选择c1、c4以及c5,并继续计算c1、c4、c5以及c6的总数据量是否大于预设的数据量;若c1、c4以及c5的总数据量等于预设的数据量,则选择c1、c4以及c5用于生成热点配置文件,不再继续计算c1、c4、c5以及c6的总数据量是否大于预设的数据量。
在本申请实施例中,预设数据量的具体数值并不做具体限定,例如,预设数据量的确定方式可以是,确定一个使用时长范围,获取使用时长在该使用时长范围内的目标应用程序产生的热点代码文件,并计算获得的热点代码文件的平均数据量,向上取整或向下取整作为预设数据量。例如,使用时长范围为3个月,获取使用时长为3个月的目标应用程序产生的热点代码文件4个,该4个热点代码文件中总共有不同的热点代码1200kb,热点代码文件的平均数据量为1200kb/4=300kb,以300kb作为预设数据量。
作为一种实施方式,可以根据热点代码的热度进行选择,即选择热度大于或等于一定热度的热点代码。其中,热点代码的热度可以通过热度代码出现次数表示,则可以选择出现次数大于或等于指定数量的热点代码。
例如,在前述举例说明中,若指定数量为2,由于c1,c4,c2以及c5的出现次数大于或等于2,则选择c1,c4,c2以及c5用于生成热点配置文件。
作为一种实施方式,目标应用程序的运行时间过短,可能产生的热点代码不够或不具有代表性,在目标应用程序运行一段时间后,可能就生成了大部分的热点代码。对于刚开 始使用目标应用程序的用户,该大部分的热点代码已经基本可以代表可能频繁运行的代码块。因此,在该实施方式中,从所述多个热点代码文件中,选择目标应用程序使用时长达到预设时长的热点代码文件,作为目标代码文件。例如,在服务器获得的多个热点代码文件中包括热点代码文件A、热点代码文件B、热点代码文件C以及热点代码文件D,其中,产生热点代码文件B以及热点代码文件C的目标应用程序的使用时长达到预设时长,产生热点代码文件A以及热点代码文件D的目标应用程序的使用时长未达到预设时长,则选择热点代码文件B以及热点代码文件C作为目标代码文件。
以目标代码文件作为选择热点代码的热点代码文件,根据每个热点代码的出现次数,从目标代码文件中选择热点代码,使选择的热点代码的出现次数不小于未选择的热点代码对应的出现次数。
在该实施方式中,根据每个热点代码对应的出现次数,从目标代码文件中选择热点代码的选择方式可以参照前述实施方式,如选择目标代码文件中的所有热点代码;或者如按照出现次数由大到小,选择预设数量的热点代码;或者如选择出现次数大于或等于指定数量的热点代码;或者如使选择的热点代码的总数据量小于预设数据量等,在此不再赘述。
可选的,在该实施方式中,还可以通过指定时长对选择的目标代码文件的数量进行限定。具体的,指定时长大于预设时长,从所述多个热点代码文件中,选择目标应用程序使用时长达到预设时长、且小于指定时长的热点代码文件,作为目标代码文件。
可选的,在本申请实施例中,按照对应的热点文件数量由大到小选择热点代码后,若有未选择的热点代码以及已选择的热点代码出现次数相同,可以将该出现次数相同的未选择的热点代码也选择用于生成热点配置文件。
另外,在本申请实施例中,若目标终端设备包括多种型号,不同型号的目标终端设备的系统应用程序可能不同。则对于每一型号的目标终端设备,服务器可以获取其系统应用程序的热点配置文件。获取方式可以参见上述描述的获取方式。
可选的,对于不同型号的目标终端设备,若有相同的系统应用程序,该相同的系统应用程序可以复用。例如,型号H1的目标终端设备具有系统应用程序P1,型号H2的目标终端设备也具有系统应用程序P1,在获取到型号H1的目标终端设备系统应用程序P1的热点配置文件时,该热点配置文件也可以作为型号H2的目标终端设备的系统应用程序P1的热点配置文件。
步骤S430:在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
服务器接收到对所述目标应用程序的热点代码的获取请求时,根据获取请求选择热点配置文件返回给请求方。
可以理解的,在本申请实施例中,服务器可以生成目标终端设备中不同系统应用程序的热点配置文件。服务器在接收到热点代码获取请求时,可以根据热点代码获取请求携带的应用程序唯一身份信息,确定将哪一系统应用程序的热点配置文件返回到请求方。
在一些实施方式中,若如图4所示,终端设备102向生成热点配置文件的服务器101请求目标应用程序的热点配置文件,服务器101可以将选择该目标应用程序的热点配置文件返回到该终端设备。
在一些实施方式中,如图5所示,也可以是其他服务器发起对所述目标应用程序的热点代码的获取请求。即生成热点配置文件的服务器与将热点配置文件发送到目标终端设备的可以为不同的服务器。如图5所示,生成热点配置文件的为服务器1011,终端设备102向服务器1012请求目标应用程序的热点配置文件,热点配置文件在服务器1011生成,服务器1012向服务器1011请求获取热点配置文件。服务器1011选择目标应用程序的热点配置文件发送到服务器1012,服务器1012在从服务器1011获取到热点配置文件后发送给终端设备102。在本申请实施例中,若无特殊说明,描述的服务器为生成热点配置文件的服 务器1011或服务器101。
在本申请实施例中,从服务器请求热点配置文件的终端设备可以是目标终端设备,也可以是其他终端设备。若是其他终端设备从服务器请求获得热点配置文件,并且若目标终端设备需要获取该热点配置文件,目标终端设备可以再从该其他终端设备获取热点配置文件。
在本申请实施例中,服务器根据热度选择目标应用程序的热点代码生成热点配置文件,使生成的热点配置文件更可能包括新用户使用目标应用程序时经常运行到的代码块,在根据热点配置文件生成目标应用程序的热点编译文件后,提高了目标应用程序的执行效率,从而提高了目标应用程序的性能。
本申请实施例还提供了一种热点代码处理装置500,请参见图8,该装置500包括:第一文件获取模块510,用于获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备;第二文件获取模块520,用于根据所述多个热点代码文件生成热点配置文件;返回模块530,用于在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
可选的,第一文件获取模块510可以用于判断应用程序列表中各个应用程序是否为所述目标终端设备的系统应用程序;若是,从多个终端设备中获取所述系统应用程序的热点代码文件。
可选的,第一文件获取模块510可以用于获取所述多个终端设备中应用程序的热点代码文件;从获取的热点代码文件中确定目标终端设备中系统应用程序的热点代码文件。
本申请实施例还提供了一种热点代码处理装置600,请参见图9,该装置600包括:内核文件获取模块610,用于获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码;安装模块620,用于目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件;存储模块630,用于所述目标终端设备将所述热点编译文件存储。
可选的,内核文件获取模块610可以用于对所述目标终端设备的内核源码进行内核编译时,将指定目录下系统应用程序的热点配置文件存放到编译后的内核文件中。
可选的,该装置600还可以包括文件获取模块,用于从服务器获取所述目标终端设备中系统应用程序的热点配置文件,所述热点配置文件根据多个热点代码文件获得,所述多个热点代码文件来自于运行过所述系统应用程序的多个终端设备;存放模块,用于将所述热点配置文件存放在所述指定目录下。
可选的,该装置600还可以包括目录新建模块,用于新建指定目录,用于存放所述系统应用程序的热点配置文件。
可选的,内核文件获取模块610还可以用于将指定目录下系统应用程序的所述热点配置文件存放于内核文件中的目标文件,所述目标文件为所述内核文件中用于存放所述系统应用程序的热点代码的文件。
可选的,安装模块620可以用于在通过所述内核文件进行系统安装时,对所述系统应用程序进行安装;对所述系统应用程序进行安装时,将所述目标文件中的热点代码编译为机器码。
需要说明的是,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述装置和模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。另外,方法实施例中的各种实施方式,都可以对应有相应的模块,在本申请实施例中不再一一赘述。
在本申请所提供的几个实施例中,所显示或讨论的模块相互之间的耦合或直接耦合或 通信连接可以是通过一些接口,装置或模块的间接耦合或通信连接,可以是电性,机械或其它的形式。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
请参考图10,其示出了本申请实施例提供的一种电子设备700的结构框图。本申请中的电子设备700可以是服务器或者终端设备,即可以是服务器,目标终端设备或者其他终端设备。
该电子设备700可以包括一个或多个如下部件:处理器710、存储器720,以及一个或多个程序,其中一个或多个程序可以被存储在存储器720中并被配置为由一个或多个处理器710执行,一个或多个程序配置用于执行如前述方法实施例所描述的方法。
处理器710可以包括一个或者多个处理核。处理器710利用各种接口和线路连接整个电子设备700内的各个部分,通过运行或执行存储在存储器720内的指令、程序、代码集或指令集,以及调用存储在存储器720内的数据,执行电子设备700的各种功能和处理数据。可选地,处理器710可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器710可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器710中,单独通过一块通信芯片进行实现。
存储器720可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。例如,存储器720中可以存储有热点代码处理装置。该热点代码处理装置可以为前述的装置500或装置600。存储器720可用于存储指令、程序、代码、代码集或指令集。存储器720可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现下述各个方法实施例的指令等。存储数据区还可以存储电子设备700在使用中所创建的数据等。
请参考图11,其示出了本申请实施例提供的一种计算机可读存储介质的结构框图。该计算机可读存储介质800中存储有程序代码,所述程序代码可被处理器调用执行上述方法实施例中所描述的方法。
计算机可读存储介质800可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。可选地,计算机可读存储介质800包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。计算机可读存储介质800具有执行上述方法中的任何方法步骤的程序代码810的存储空间。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。程序代码810可以例如以适当形式进行压缩。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不驱使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。
Claims (20)
- 一种热点代码处理方法,其特征在于,所述方法包括:获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码;目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件;所述目标终端设备将所述热点编译文件存储。
- 根据权利要求1所述的方法,其特征在于,所述获取目标终端设备的内核文件,包括:对所述目标终端设备的内核源码进行内核编译时,将指定目录下系统应用程序的热点配置文件存放到编译后的内核文件中。
- 根据权利要求2所述的方法,其特征在于,所述对所述目标终端设备的内核源码进行内核编译时,将指定目录下系统应用程序的热点配置文件存放到编译后的内核文件中之前,还包括:从服务器获取所述目标终端设备中系统应用程序的热点配置文件,所述热点配置文件根据多个热点代码文件获得,所述多个热点代码文件来自于运行过所述系统应用程序的多个终端设备;将所述热点配置文件存放在所述指定目录下。
- 根据权利要求3所述的方法,其特征在于,所述将所述热点配置文件存放在所述指定目录下之前,还包括:新建指定目录,用于存放所述系统应用程序的热点配置文件。
- 根据权利要求4所述的方法,其特征在于,所述新建指定目录,包括:对应不同系统应用程序分别创建指定目录,用于将不同系统应用程序的热点配置文件存放在相应的指定目录下。
- 根据权利要求2-5任一项所述的方法,其特征在于,所述对所述目标终端设备的内核源码进行内核编译时,将指定目录下系统应用程序的热点配置文件存放到编译后的内核文件中之前,还包括:在所述内核源码中添加指令代码,所述指令代码用于指示在进行内核编译时,获取新建的指定目录下的热点配置文件,并存放到编译后的内核文件中。
- 根据权利要求2所述的方法,其特征在于,所述将指定目录下系统应用程序的热点配置文件存放到编译后的内核文件中,包括:将指定目录下系统应用程序的所述热点配置文件存放于内核文件中的目标文件,所述目标文件为所述内核文件中用于存放所述系统应用程序的热点代码的文件。
- 根据权利要求7所述的方法,其特征在于,所述目标终端设备在通过所述内核文件对所述系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,包括:在通过所述内核文件进行系统安装时,对所述系统应用程序进行安装;对所述系统应用程序进行安装时,将所述目标文件中的热点代码编译为机器码。
- 一种热点代码处理方法,其特征在于,所述方法包括:获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备;根据所述多个热点代码文件生成热点配置文件;在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
- 根据权利要求9所述的方法,其特征在于,所述获取目标应用程序的多个热点代码文件,包括:判断应用程序列表中各个应用程序是否为所述目标终端设备的系统应用程序;若是,从所述多个终端设备中获取所述系统应用程序的热点代码文件。
- 根据权利要求9所述的方法,其特征在于,所述获取目标应用程序的多个热点代码文件,包括:获取所述多个终端设备中应用程序的热点代码文件;从获取的热点代码文件中确定目标终端设备中系统应用程序的热点代码文件。
- 根据权利要求11所述的方法,其特征在于,所述获取所述多个终端设备中应用程序的热点代码文件,包括:向多个终端设备发起热点代码文件获取请求,所述热点代码文件获取请求中携带需要获取热点代码文件的应用程序的程序标识;接收所述多个终端设备返回的与所述程序标识对应的应用程序的热点代码文件。
- 根据权利要求9所述的方法,其特征在于,所述获取目标应用程序的多个热点代码文件,包括:获取系统应用程序列表中各系统应用程序的热点代码文件,所述系统应用程序列表中包括目标终端设备的系统应用程序。
- 根据权利要求9所述的方法,其特征在于,所述根据所述多个热点代码文件生成热点配置文件,包括:从所述多个热点代码文件中选择满足预设条件的热点代码,生成热点配置文件,所述预设条件包括热点代码的热度,所述热点代码的热度由使用该热点代码对应的功能的用户数量确定,或者由热点代码在多个热点代码文件中的出现次数确定。
- 根据权利要求9-14任一项所述的方法,其特征在于,所述热点代码文件中至少包括应用程序的热点代码、应用程序的名称、应用程序的版本名称以及应用程序的版本号中的一项。
- 一种热点代码处理装置,其特征在于,所述装置包括:内核文件获取模块,用于获取目标终端设备的内核文件,所述内核文件中包括系统应用程序的热点配置文件,所述热点配置文件中包括所述系统应用程序的热点代码;安装模块,用于目标终端设备在通过所述内核文件对系统应用程序进行安装时,将所述系统应用程序的热点配置文件中的热点代码编译为机器码,获得所述系统应用程序的热点编译文件;存储模块,用于所述目标终端设备将所述热点编译文件存储。
- 一种热点代码处理装置,其特征在于,所述装置包括:第一文件获取模块,用于获取目标应用程序的多个热点代码文件,所述目标应用程序为目标终端设备中的系统应用程序,所述多个热点代码文件来自于运行过所述目标应用程序的多个终端设备;第二文件获取模块,用于根据所述多个热点代码文件生成热点配置文件;返回模块,用于在接收到对目标终端设备中系统应用程序的热点代码获取请求时,将所述热点配置文件返回。
- 根据权利要求17所述的装置,其特征在于,所述第一文件获取模块用于:判断应用程序列表中各个应用程序是否为所述目标终端设备的系统应用程序;若是,从多个终端设备中获取所述系统应用程序的热点代码文件。
- 一种电子设备,其特征在于,所述电子设备包括:一个或多个处理器;存储器,与所述一个或多个处理器电连接;一个或多个程序,其中所述一个或多个程序被存储在所述存储器中并被配置为由所述一个或多个处理器执行,所述一个或多个程序配置用于执行如权利要求1至8或9-15任一项所述的方法。
- 一种计算机可读取存储介质,其特征在于,所述计算机可读取存储介质中存储有程序代码,所述程序代码可被处理器调用执行如权利要求1至8或9-15任一项所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911408505.0A CN113126994A (zh) | 2019-12-31 | 2019-12-31 | 热点代码处理方法、装置、电子设备及存储介质 |
CN201911408505.0 | 2019-12-31 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021135947A1 true WO2021135947A1 (zh) | 2021-07-08 |
Family
ID=76685872
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/136878 WO2021135947A1 (zh) | 2019-12-31 | 2020-12-16 | 热点代码处理方法、装置、电子设备及存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113126994A (zh) |
WO (1) | WO2021135947A1 (zh) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116088888B (zh) * | 2022-07-22 | 2023-10-31 | 荣耀终端有限公司 | 应用程序更新方法及相关装置 |
CN118051239A (zh) * | 2022-11-17 | 2024-05-17 | 蔚来移动科技有限公司 | 应用程序的配置文件获取及应用程序的安装方法 |
CN116627426B (zh) * | 2023-05-29 | 2023-11-24 | 合芯科技有限公司 | 一种硬件描述语言增量编译方法及装置 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104598274A (zh) * | 2015-01-13 | 2015-05-06 | 北京京东尚科信息技术有限公司 | 一种自动插桩编译安装方法及系统 |
CN105468428A (zh) * | 2015-12-04 | 2016-04-06 | 上海斐讯数据通信技术有限公司 | 一种安卓源代码编译方法及系统 |
CN106775893A (zh) * | 2016-12-30 | 2017-05-31 | 北京小米移动软件有限公司 | 对程序预编译的方法及装置 |
CN109960507A (zh) * | 2017-12-14 | 2019-07-02 | 广东欧珀移动通信有限公司 | 编译优化方法、装置、存储介质、智能终端及服务器 |
US20190272180A1 (en) * | 2016-11-15 | 2019-09-05 | Google Llc | Bootstrapping Profile-Guided Compilation and Verification |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7150012B2 (en) * | 2002-10-15 | 2006-12-12 | Nokia Corporation | Method and apparatus for accelerating program execution in platform-independent virtual machines |
CN110609689A (zh) * | 2019-08-23 | 2019-12-24 | 北京安云世纪科技有限公司 | 一种应用的安装运行方法及装置 |
CN110543338A (zh) * | 2019-09-09 | 2019-12-06 | 北京安云世纪科技有限公司 | 一种文件的动态加载方法及装置 |
-
2019
- 2019-12-31 CN CN201911408505.0A patent/CN113126994A/zh active Pending
-
2020
- 2020-12-16 WO PCT/CN2020/136878 patent/WO2021135947A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104598274A (zh) * | 2015-01-13 | 2015-05-06 | 北京京东尚科信息技术有限公司 | 一种自动插桩编译安装方法及系统 |
CN105468428A (zh) * | 2015-12-04 | 2016-04-06 | 上海斐讯数据通信技术有限公司 | 一种安卓源代码编译方法及系统 |
US20190272180A1 (en) * | 2016-11-15 | 2019-09-05 | Google Llc | Bootstrapping Profile-Guided Compilation and Verification |
CN106775893A (zh) * | 2016-12-30 | 2017-05-31 | 北京小米移动软件有限公司 | 对程序预编译的方法及装置 |
CN109960507A (zh) * | 2017-12-14 | 2019-07-02 | 广东欧珀移动通信有限公司 | 编译优化方法、装置、存储介质、智能终端及服务器 |
Also Published As
Publication number | Publication date |
---|---|
CN113126994A (zh) | 2021-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021135947A1 (zh) | 热点代码处理方法、装置、电子设备及存储介质 | |
CN111078318B (zh) | 配置文件的处理方法、装置、系统及存储介质 | |
CN110187931B (zh) | 小程序的运行方法及装置 | |
EP3035191B1 (en) | Identifying source code used to build executable files | |
CN111061484A (zh) | 代码编译方法、装置、服务器、用户终端及可读介质 | |
TWI626593B (zh) | 一種軟體升級的方法及裝置 | |
US10929149B2 (en) | Method and system for updating firmware | |
WO2021115177A1 (zh) | 应用安装方法、装置、终端设备、服务器及存储介质 | |
CN110968331B (zh) | 应用程序运行的方法和装置 | |
CN110113391B (zh) | 一种客户端上线方法、装置及一种客户端运行方法、装置 | |
CN106648755B (zh) | 一种在安卓art环境中动态加载dex的方法及装置 | |
CN109840096A (zh) | 操作系统的安装方法及装置 | |
EP3534266B1 (en) | Method, apparatus and system for prefetching data | |
CN110231941A (zh) | 适用于运行移动设备的原生应用程序的无需完全安装的应用程序级运行环境 | |
CN112506584B (zh) | 资源文件加载方法、装置、设备、存储介质以及产品 | |
WO2022078280A1 (zh) | 一种人工智能ai训练的方法、系统及设备 | |
WO2017148157A1 (zh) | Android设备的应用程序本地化安装方法和装置 | |
CN116643778A (zh) | 一种应用程序优化方法及电子设备 | |
CN108108203B (zh) | 用于安装包下载安装过程的方法、装置及系统 | |
WO2021115178A1 (zh) | 应用程序预编译的方法、装置、服务器及存储介质 | |
CN113608742A (zh) | 检测方法、代码包处理方法、运行控制方法及计算设备 | |
CN107423093B (zh) | 控制方法及装置、计算机装置和计算机可读存储介质 | |
WO2021121188A1 (zh) | 配置文件的处理方法、装置、系统及存储介质 | |
WO2021136012A1 (zh) | 热点代码处理方法、装置、服务器及存储介质 | |
CN111679842A (zh) | 应用程序热更新处理方法、装置及系统 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20910038 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20910038 Country of ref document: EP Kind code of ref document: A1 |