Bytecode compilation method, bytecode compilation device and computer readable storage medium
By dynamically allocating CPU core resources and based on the terminal's bytecode compilation scenario and CPU core information, it solves the problem of dex2oat occupying too many CPU resources and improves the user experience and compilation efficiency of the Android system.
Patent Information
- Application Number
- CN202011074115.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-09
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-10-09
AI Technical Summary
In the Android system, during the conversion process of Java bytecode to machine code, the dex2oat tool consumes a large amount of CPU resources, causing terminal freezes and delays, especially affecting the user experience during real-time translation tasks.
By determining the correspondence between the current bytecode compilation scenario of the terminal and the CPU core information, dynamically allocate CPU core resources, allocate appropriate CPU cores for compilation based on user perception and execution real-time performance, and reduce the occurrence of lagging.
It effectively reduces the lagging phenomenon of the terminal system, improves the user experience, and ensures the efficiency and smoothness of the compilation process.
Smart Images

Figure CN112346718B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of terminal control technology, and in particular to a bytecode compiling method, a bytecode compiling device, and a computer-readable storage medium. Background Art
[0002] In the Android system, Java (a computer programming language) is the main development language for terminal applications, but the terminal cannot directly use the Java bytecode programmed in this language. Therefore, in order to facilitate the use of the terminal, the Java bytecode needs to be parsed and translated one by one through the dex2oat program, and then the machine code that the terminal can support is obtained. Among them, dex2oat (dex file to oat file) is a tool that optimizes dex files into binary format files. However, using dex2oat for work is a heavy-load operation that requires a large amount of central processing unit (CPU) resources, which makes it easy for the central processing unit to cause other operations to jam when executing other processes.
[0003] In the related art, the method of reducing the number of dex2oat compilation threads is adopted to solve the problem of dex2oat occupying too many CPU resources. However, when encountering tasks that require real-time translation, the terminal still experiences freezes and delays due to the insufficient number of dex2oat running threads, which affects the user experience. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a bytecode compiling method, a bytecode compiling device and a computer-readable storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, a bytecode compilation method is provided, which is applied to a terminal, and the bytecode compilation method includes: determining a current bytecode compilation scenario of the terminal. Based on the correspondence between the bytecode compilation scenario and the CPU core information, determining the current CPU core information matching the current bytecode compilation scenario, the core information including: the execution capability of the core and the number of cores. According to the current bytecode compilation scenario and the current CPU core information, bytecode compilation is performed.
[0006] In one embodiment, the correspondence between the bytecode compilation scenario and the CPU core information is predetermined in the following manner: a plurality of bytecode compilation scenarios are determined, and the user perception and execution real-time of the plurality of bytecode compilation scenarios are determined. Based on the user perception and execution real-time, matching CPU core information is respectively allocated to the plurality of bytecode compilation scenarios, wherein, if the first user perception is higher than the second user perception, the number of CPUs allocated to the first user perception is greater than the number of CPUs allocated to the second user perception, and the execution capability of the CPU core allocated to the first user perception is stronger than the execution capability of the CPU allocated to the second user perception; and / or if the first execution real-time is higher than the second execution real-time, the number of CPUs allocated to the first execution real-time is greater than the number of CPUs allocated to the second execution real-time, and the execution capability of the CPU core allocated to the first execution real-time is stronger than the execution capability of the CPU allocated to the second execution real-time.
[0007] In another embodiment, determining the current bytecode compilation scenario of the terminal includes: based on the bytecode compilation currently executed by the terminal, determining that the current bytecode compilation scenario of the terminal is one of the following scenarios or a combination thereof: application installation scenario, system first startup scenario, system startup scenario, system startup completion scenario, background idle scenario, plug-in compilation scenario, application update scenario, or application first use scenario.
[0008] In another embodiment, the bytecode compilation is performed according to the current bytecode compilation scenario and the current CPU core information, including: adding a scenario parameter representing the current bytecode compilation scenario to a data packet parsing and management object, and passing it to a bytecode compilation execution thread through a data packet bytecode compilation optimization service. Adding the scenario parameter representing the current bytecode compilation scenario to the startup parameters of the bytecode compilation execution thread, and performing bytecode compilation using the current bytecode corresponding to the current CPU core information.
[0009] In another embodiment, the bytecode compilation method further includes: outputting a bytecode compilation operation log, wherein the operation log includes the current bytecode compilation scenario and the current CPU core information, obtaining CPU core adjustment information input by a user based on the operation log, and adjusting the CPU core information corresponding to the current bytecode compilation scenario based on the CPU core adjustment information.
[0010] According to a second aspect of an embodiment of the present disclosure, a bytecode compilation device is provided, which is applied to a terminal, and the bytecode compilation device includes: a determination unit, which is used to determine a current bytecode compilation scenario of the terminal, and based on the correspondence between the bytecode compilation scenario and the CPU core information, determine the current CPU core information matching the current bytecode compilation scenario, the core information including: the execution capability of the core and the number of cores. A compilation unit, which is used to perform bytecode compilation according to the current bytecode compilation scenario and the current CPU core information.
[0011] In one embodiment, the determination unit predetermines the correspondence between the bytecode compilation scenario and the CPU core information in the following manner: determine multiple bytecode compilation scenarios, and determine the user perception and execution real-time of the multiple bytecode compilation scenarios. Based on the user perception and execution real-time, the multiple bytecode compilation scenarios are respectively assigned matching CPU core information, wherein if the first user perception is higher than the second user perception, the number of CPUs assigned to the first user perception is greater than the number of CPUs assigned to the second user perception, and the CPU core execution capability assigned to the first user perception is stronger than the CPU execution capability assigned to the second user perception; and / or if the first execution real-time is higher than the second execution real-time, the number of CPUs assigned to the first execution real-time is greater than the number of CPUs assigned to the second execution real-time, and the CPU core execution capability assigned to the first execution real-time is stronger than the CPU execution capability assigned to the second execution real-time.
[0012] In another embodiment, the determination unit determines the current bytecode compilation scenario of the terminal in the following manner: based on the bytecode compilation currently executed by the terminal, determine that the current bytecode compilation scenario of the terminal is one of the following scenarios or a combination thereof: application installation scenario, system first startup scenario, system startup scenario, system startup completion scenario, background idle scenario, plug-in compilation scenario, application update scenario, or application first use scenario.
[0013] In another embodiment, the compilation unit performs bytecode compilation according to the current bytecode compilation scenario and the current CPU core information in the following manner: adding a scenario parameter representing the current bytecode compilation scenario to a data packet parsing and management object, and passing it to a bytecode compilation execution thread through a data packet bytecode compilation optimization service. Adding the scenario parameter representing the current bytecode compilation scenario to the startup parameters of the bytecode compilation execution thread, and performing bytecode compilation using the current bytecode corresponding to the current CPU core information.
[0014] In another embodiment, the bytecode compilation device further includes: an output unit, configured to output a running log of the bytecode compilation, wherein the running log includes the current bytecode compilation scenario and the current CPU core information; and an adjustment unit, configured to obtain CPU core adjustment information input by a user based on the running log, and adjust the CPU core information corresponding to the current bytecode compilation scenario based on the CPU core adjustment information.
[0015] According to a third aspect of an embodiment of the present disclosure, a bytecode compiling device is provided, comprising: a memory for storing instructions; and a processor for calling the instructions stored in the memory to execute any one of the bytecode compiling methods described above.
[0016] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, in which instructions are stored. When the instructions are executed by a processor, any one of the above-mentioned bytecode compilation methods is executed.
[0017] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: through the bytecode compilation method provided by the present disclosure, it is possible to call the CPU core corresponding to the current bytecode compilation scenario for compilation based on the correspondence between the bytecode compilation scenario and the CPU core information, thereby reducing the probability of the occurrence of the lag phenomenon and improving the user experience of using the terminal.
[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] Figure 1 The figure is a flowchart of a bytecode compiling method according to an exemplary embodiment.
[0021] Figure 2 The figure is a flowchart of another bytecode compiling method according to an exemplary embodiment.
[0022] Figure 3 The figure is a block diagram of a bytecode compiling device according to an exemplary embodiment.
[0023] Figure 4 The figure is a block diagram of another bytecode compiling device according to an exemplary embodiment. DETAILED DESCRIPTION
[0024] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0025] In the related art, in order to solve the problem that dex2oat occupies too many CPU resources in the process of parsing and translating Java bytecode, the method of reducing the number of dex2oat compilation threads is adopted to ensure the smoothness of the terminal system during operation. However, using this method, the CPU load cannot be accurately allocated. And when the CPU in the terminal is eight-core, the execution capability between the small core and the super-large core is very different. When some operations have high real-time requirements, the reduction in the number of compilation threads can easily lead to problems such as freezes and delays that affect the user experience.
[0026] In view of this, the present disclosure provides a bytecode compilation method, which can determine the CPU core information required for the current bytecode compilation scenario according to the correspondence between the bytecode compilation scenario and the CPU core information, and then use appropriate CPU core information for the current bytecode compilation scenario to reduce the probability of lag, thereby improving the user experience of using the terminal.
[0027] The bytecode compilation method provided by the present disclosure is applied to a terminal. In one example, the type of terminal may include a mobile terminal, such as a mobile phone, a tablet, a notebook, etc. In another example, the structure of the terminal may include a double-sided screen terminal, a folding screen terminal, a full-screen terminal, etc.
[0028] Figure 1 is a flowchart of a bytecode compiling method according to an exemplary embodiment. Figure 1 As shown, the bytecode compiling method includes the following steps S11 to S13.
[0029] In step S11, the current bytecode compilation scenario of the terminal is determined.
[0030] In the disclosed embodiment, in order to facilitate the adaptation of the called CPU core information to the current bytecode encoding scenario that needs to be compiled, the current bytecode compilation scenario of the terminal is determined before the call, so that when compiling, the execution capabilities of each core can be reasonably used, thereby improving the compilation speed.
[0031] In step S12, based on the correspondence between the bytecode compilation scenario and the CPU core information, the current CPU core information matching the current bytecode compilation scenario is determined.
[0032] In the disclosed embodiment, the execution capabilities of the cores in the CPU are different. Therefore, in order to facilitate the reasonable use of each core, give full play to their respective execution capabilities, thereby reducing unnecessary CPU resources and ensuring the normal operation of other processes, different CPU core information is used for compilation for different bytecode compilation scenarios. Among them, the core information includes: the execution capability of the core and the number of cores. In one example, the number of cores can be determined based on the real-time execution of the terminal when performing the bytecode compilation scenario or in combination with factors such as user perception. Based on the correspondence between the bytecode compilation scenario and the CPU core information, according to the current bytecode compilation scenario of the current terminal, the current CPU core information that matches the current bytecode compilation scenario for compilation is determined, thereby facilitating the reasonable call of the CPU load during compilation and speeding up the compilation process.
[0033] In step S13, bytecode compilation is performed according to the current bytecode compilation scenario and the current CPU core information.
[0034] In the disclosed embodiment, in order to facilitate the current bytecode compilation scenario to quickly complete the compilation, the bytecode compilation is performed using the current CPU core information matched to the current bytecode compilation scenario, thereby reducing the compilation time. And due to the reasonable call of the CPU core information, the CPU load in running the current bytecode compilation scenario can be effectively allocated, which helps the CPU to reduce terminal system freezes and other problems when controlling other processes at the same time, so as to improve the user experience.
[0035] Through the above embodiments, the bytecode compilation method provided by the present invention can use the current CPU core information suitable for the current bytecode compilation scenario for compilation according to the correspondence between the bytecode compilation scenario and the CPU core information, and then reasonably allocate CPU resources to ensure that the current bytecode compilation scenario is compiled normally while avoiding freezes and delays in other processes, thereby improving the user experience.
[0036] In real life, most terminals use eight-core CPUs, including 2 to 4 super-large cores, and the rest are small cores or small and large cores. The execution capabilities of small cores and super-large cores are very different. Small cores have low execution capabilities, while large cores have relatively strong execution capabilities. Super-large cores have the strongest execution capabilities, but relatively speaking, the stronger the execution capabilities, the more CPU resources they occupy, and the faster the compilation speed.
[0037] In one embodiment, the correspondence between the bytecode compilation scenario and the CPU core information can be determined based on the user's perception of the current bytecode compilation scenario and the execution real-time performance of the current bytecode compilation scenario. In order to facilitate the reasonable use of CPU resources during parsing, meet the user's usage requirements, and not affect other running processes in the terminal, before determining the CPU core information corresponding to the bytecode compilation scenario, the impact of each bytecode compilation scenario on user perception and execution real-time performance during compilation is pre-determined. Then, when matching separately, the CPU resources can be reasonably allocated, so that the CPU reduces the phenomenon of jamming and delay when controlling the operation of each process, so that the terminal operation is more in line with the user's usage requirements. Among them, the allocated core information may include multiple cores with low execution capabilities and multiple cores with high execution capabilities, or only cores with low execution capabilities. The more cores there are, the stronger the execution capability of the CPU core is in compilation; conversely, the fewer cores there are, the weaker the execution capability of the CPU core is in compilation.
[0038] In one example, the core information corresponding to the bytecode compilation scenario can be determined based on user perception. If the first user perception is higher than the second user perception, the number of CPUs allocated to the first user perception is greater than the number of CPUs allocated to the second user perception, and the CPU core execution capability allocated to the first user perception is stronger than the CPU execution capability allocated to the second user perception. If the user's user perception of a certain bytecode compilation scenario is high, it can be characterized that the user is relatively familiar with and understands the bytecode compilation scenario based on past feelings and cognition. Therefore, in order to facilitate improving the user's usage experience or shortening the compilation time, a relatively large number of cores are allocated to the bytecode compilation scenario with high user perception, thereby speeding up the compilation rate of the bytecode compilation scenario. If the user's user perception of a certain bytecode compilation scenario is low, that is, the user is relatively unfamiliar and unaware of or completely unaware of the bytecode compilation scenario based on past feelings and cognition, a relatively small number of cores can be allocated to the bytecode compilation scenario, thereby ensuring that the bytecode compilation scenario is compiled without affecting the operation of other processes.
[0039] In another example, the core information corresponding to the bytecode compilation scenario can be determined based on the priority of the process of the CPU load, that is, the execution real-time required by the bytecode compilation scenario. If the first execution real-time is higher than the second execution real-time, the number of CPUs allocated to the first execution real-time is greater than the number of CPUs allocated to the second execution real-time, and the execution capability of the CPU cores allocated to the first execution real-time is stronger than the execution capability of the CPUs allocated to the second execution real-time. That is, if the execution real-time requirement of the bytecode compilation scenario is relatively strong, a relatively large number of cores are allocated to the bytecode compilation scenario, thereby speeding up the compilation rate of the bytecode compilation scenario. If the execution real-time requirement of the bytecode compilation scenario is relatively low, a relatively small number of cores are allocated to the bytecode compilation scenario, thereby avoiding affecting the operation of other processes.
[0040] In another example, the core information corresponding to the bytecode compilation scenario can be determined based on user perception and execution real-time performance, so that the user experience of using the terminal can be improved when performing allocation matching. When the user perception is higher and the execution real-time performance is higher, the number of CPUs allocated is larger, and the relative CPU core execution capability is stronger. When the user perception is lower and the execution real-time performance is lower, the number of CPUs allocated is smaller, and the relative CPU core execution capability is weaker.
[0041] In one embodiment, the bytecode compilation scenario can be refined and determined based on the scenario that dex2oat needs to parse and translate in the terminal. The current bytecode compilation scenario can include one or a combination of the following scenarios: application installation scenario, system first startup scenario, system startup scenario, system startup completion scenario, background idle scenario, plug-in compilation scenario, application update scenario, or application first use scenario. Then, when determining the current bytecode compilation scenario of the terminal, the current bytecode compilation scenario is determined according to the bytecode compilation currently executed by the terminal. Then, relevant core information can be called in time for compilation.
[0042] In another embodiment, in order to facilitate timely calling of core information and quickly determine the current bytecode compilation scenario, the scenario parameters representing the current bytecode compilation scenario are pre-added to the data packet parsing and management object, and then when the trigger is triggered to start compiling the current bytecode compilation scenario, the scenario parameters can be passed to the bytecode compilation execution thread through the bytecode compilation optimization service in the data packet to determine the current bytecode compilation scenario. The scenario parameters representing the current bytecode compilation scenario are added to the startup parameters of the bytecode compilation execution thread, and according to the correspondence between the bytecode compilation scenario and the CPU core information, the CPU corresponding to the current CPU core information matching the current bytecode compilation scenario is used to perform bytecode compilation. Therefore, when compiling, the scene parameters that can be obtained can quickly determine the current bytecode compilation scenario, and the corresponding CPU core information can be called in time for bytecode compilation, thereby improving the execution efficiency of the CPU.
[0043] In one implementation scenario, the compilation process is as follows: Take the application update scenario as an example to determine the current bytecode compilation scenario. Install the application in PackageManagerServeice.java, add the scenario parameter (reason) for distinguishing the updated application as REASON_UPDATE in executePostCommitSteps(), and pass the scenario parameter down to PackageDexOptimizer.java performDexOpt() and Installer.java:dexopt(). Call the Installd daemon through binder. When executing dexopt.cpp:dexopt(), start dex2oat and add the scenario parameters to the startup parameters. Thus, dex2oat.cc calls the corresponding CPU core information for bytecode compilation according to the obtained scenario parameters.
[0044] In another embodiment, the correspondence between the bytecode compilation scenario and the CPU core information is determined in advance to obtain a relationship comparison table as shown in Table 1. For ease of understanding, this embodiment and the embodiments described below will be described using a CPU with eight cores as an example. Among them, each number represents a core, and the smaller the number, the weaker the execution capability of the corresponding core. Furthermore, during compilation, the CPU can determine the current bytecode compilation scenario and the called CPU core information based on the scenario parameters passed during the compilation process. Thereby improving the execution efficiency of the CPU during bytecode compilation and saving the compilation time of bytecode compilation.
[0045] Bytecode compilation scenario Scene Parameters Information about the CPU core being called Installation application scenarios install 0,1,2,3,4,5,6,7 System first startup scenario first-boot 0,1,2,3,4,5,6,7 The system is starting the scene Booting 0,1,2,3,4,5,6,7 System startup complete scene boot 0,1,4,5 Background idle scene bg-dexopt 0,1,2,3,4,5,6,7 Plugin compilation scene secondary 0,1,4,5 Application update scenario update 0,1,2,3,4,5 Application first use scenario first-use 0,1,2,3,4
[0046] Table 1
[0047] In order to improve the calling accuracy of the CPU core, the present disclosure also provides another bytecode compilation method.
[0048] Figure 2 is a flowchart of another bytecode compilation method according to an exemplary embodiment. Figure 2 As shown, the bytecode compiling method includes the following steps S21 to S25.
[0049] In step S21, the current bytecode compilation scenario of the terminal is determined.
[0050] In step S22, based on the correspondence between the bytecode compilation scenario and the CPU core information, the current CPU core information matching the current bytecode compilation scenario is determined.
[0051] In step S23, bytecode compilation is performed according to the current bytecode compilation scenario and the current CPU core information.
[0052] In step S24, the running log of the bytecode compilation is output.
[0053] In the disclosed embodiment, in order to facilitate the determination of whether the bytecode compilation scenario and its corresponding CPU core information are reasonably allocated and whether they have an impact on other processes controlled by the CPU, the CPU operation log is output to obtain the bytecode compilation operation log. Among them, the current bytecode compilation scenario and the current CPU core information included in the operation log are analyzed. This facilitates understanding the actual bytecode compilation situation through the operation log, so as to make reasonable adjustments.
[0054] In step S25, the CPU core adjustment information input by the user based on the operation log is obtained, and the CPU core information corresponding to the current bytecode compilation scenario is adjusted based on the CPU core adjustment information.
[0055] In the disclosed embodiment, the correspondence between the bytecode compilation scenario and the CPU core information is adjusted in a timely manner through the content reflected in the running log, so that the adjusted correspondence can better meet the actual application needs, reduce the impact on other processes during bytecode compilation, and thus improve the user experience when the user uses the terminal.
[0056] In one example, according to the content shown in the running log, it can be known that the scenario parameter is boot, that is, the current bytecode compilation scenario is system startup completion, and its corresponding CPU core information may affect the foreground task during bytecode compilation, so the corresponding relationship is adjusted, and the four cores 0, 1, 4, and 5 are used as the CPU core information corresponding to the current bytecode compilation scenario. Therefore, it is verified through the running log, and the following content is output:
[0057] I dex2oat:dex2oat ofppid 1138,cpu affinity is set to 0,1,4,5,success.
[0058] I dex2oat: / apex / com.android.runtime / bin / dex2oat
[0059] --classpath-dir= / data / app / com.tencent.mtt-UhDEEnmux4FtMt0zYyNSUQ==
[0060] --compilation-reason=boot
[0061] This means that it is reasonable to use cores 0, 1, 4, and 5 as the CPU core information corresponding to the system startup. The compilation-reason value corresponds to different scenarios, and cpu affinity is set to indicates the CPU core in this scenario.
[0062] In another example, if the current bytecode compilation scenario is background idle, it means that when the CPU provides bytecode compilation for the current bytecode compilation scenario, there is no other user interaction that needs to be controlled. Therefore, all cores in the CPU can be allocated to the current bytecode compilation scenario for bytecode compilation, that is, the CPU core information corresponding to background idle is eight cores (0, 1, 2, 3, 4, 5, 6, 7), and the CPU core has the strongest execution capability at this time. Verify through the running log, and output the following content:
[0063] I dex2oat:dex2oat ofppid 1138,cpu affinity is set to 0,1,4,5,2,3,6,7success.
[0064] I dex2oat: / apex / com.android.runtime / bin / dex2oat
[0065] --classpath-dir= / data / app / com.tencent.mtt-UhDEEnmux4FtMt0zYyNSUQ==
[0066] --compilation-reason=bg-dexopt
[0067] This means that it is reasonable to use eight cores as the corresponding CPU core information for system startup and no adjustment is required.
[0068] Based on the same concept, the embodiment of the present disclosure also provides a bytecode compiling device.
[0069] It is understandable that the bytecode compilation device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.
[0070] Figure 3 1 is a block diagram of a bytecode compiling device according to an exemplary embodiment. The bytecode compiling device 100 is applied to a terminal, referring to Figure 3 The bytecode compiling device 100 includes a determining unit 101 and a compiling unit 102.
[0071] The determination unit 101 is used to determine the current bytecode compilation scenario of the terminal, and based on the correspondence between the bytecode compilation scenario and the CPU core information, determine the current CPU core information matching the current bytecode compilation scenario, the core information including: the execution capability of the core and the number of cores.
[0072] The compiling unit 102 is used to compile bytecodes according to the current bytecode compiling scenario and the current CPU core information.
[0073] In one embodiment, the determination unit 101 predetermines the correspondence between the bytecode compilation scenario and the CPU core information in the following manner: determine multiple bytecode compilation scenarios, and determine the user perception and execution real-time of the multiple bytecode compilation scenarios. Based on the user perception and execution real-time, the multiple bytecode compilation scenarios are respectively assigned matching CPU core information, wherein if the first user perception is higher than the second user perception, the number of CPUs assigned to the first user perception is greater than the number of CPUs assigned to the second user perception, and the CPU core execution capability assigned to the first user perception is stronger than the CPU execution capability assigned to the second user perception; and / or if the first execution real-time is higher than the second execution real-time, the number of CPUs assigned to the first execution real-time is greater than the number of CPUs assigned to the second execution real-time, and the CPU core execution capability assigned to the first execution real-time is stronger than the CPU execution capability assigned to the second execution real-time.
[0074] In another embodiment, the determination unit 101 determines the current bytecode compilation scenario of the terminal in the following manner: based on the bytecode compilation currently executed by the terminal, the current bytecode compilation scenario of the terminal is determined to be one of the following scenarios or a combination thereof: application installation scenario, system first startup scenario, system startup scenario, system startup completion scenario, background idle scenario, plug-in compilation scenario, application update scenario, or application first use scenario.
[0075] In another embodiment, the compiling unit 102 performs bytecode compilation according to the current bytecode compilation scenario and the current CPU core information in the following manner: adding the scenario parameters representing the current bytecode compilation scenario to the data packet parsing and management object, and passing it to the bytecode compilation execution thread through the data packet bytecode compilation optimization service. Adding the scenario parameters representing the current bytecode compilation scenario to the startup parameters of the bytecode compilation execution thread, and using a CPU matching the current CPU core information to perform bytecode compilation.
[0076] In another embodiment, the bytecode compilation device further includes: an output unit for outputting a running log of the bytecode compilation, wherein the running log includes a current bytecode compilation scenario and current CPU core information; and an adjustment unit for obtaining CPU core adjustment information input by a user based on the running log, and performing bytecode compilation using the current bytecode corresponding to the current CPU core information.
[0077] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0078] Figure 4 1 is a block diagram of a bytecode compiling device 200 according to an exemplary embodiment. For example, the bytecode compiling device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0079] Reference Figure 4 The bytecode compiling apparatus 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .
[0080] The processing component 202 generally controls the overall operation of the bytecode compilation device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 202 may include one or more modules to facilitate the interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate the interaction between the multimedia component 208 and the processing component 202.
[0081] The memory 204 is configured to store various types of data to support the operation of the bytecode compiling device 200. Examples of such data include instructions for any application or method operating on the bytecode compiling device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0082] The power component 206 provides power to various components of the bytecode compiling apparatus 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the bytecode compiling apparatus 200.
[0083] The multimedia component 208 includes a screen that provides an output interface between the bytecode compilation device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the bytecode compilation device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0084] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the bytecode compilation device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.
[0085] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0086] The sensor component 214 includes one or more sensors for providing various aspects of status evaluation for the bytecode compiling device 200. For example, the sensor component 214 can detect the open / closed state of the bytecode compiling device 200, the relative positioning of components, such as the display and keypad of the bytecode compiling device 200, and the sensor component 214 can also detect the position change of the bytecode compiling device 200 or a component of the bytecode compiling device 200, the presence or absence of user contact with the bytecode compiling device 200, the orientation or acceleration / deceleration of the bytecode compiling device 200, and the temperature change of the bytecode compiling device 200. The sensor component 214 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor component 214 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 214 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0087] The communication component 216 is configured to facilitate wired or wireless communication between the bytecode compilation device 200 and other devices. The bytecode compilation device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0088] In an exemplary embodiment, the bytecode compiling apparatus 200 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0089] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the bytecode compiling apparatus 200 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0090] It is further understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar thereto. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.
[0091] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.
[0092] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.
[0093] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.
[0094] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0095] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A bytecode compilation method, characterized in that: Applied to a terminal, the bytecode compilation method includes: Determining a current bytecode compilation scenario of the terminal; Based on the correspondence between the bytecode compilation scenario and the CPU core information, determine the current CPU core information matching the current bytecode compilation scenario, the core information including: the execution capability of the core and the number of the cores; Perform bytecode compilation according to the current bytecode compilation scenario and the current CPU core information; The correspondence between the bytecode compilation scenario and the CPU core information is predetermined in the following manner: Determining a plurality of bytecode compilation scenarios, and determining user perception and execution real-time performance of the plurality of bytecode compilation scenarios; Based on user perception and execution real-time, matching CPU core information is allocated to the multiple bytecode compilation scenarios respectively, wherein: If the first user perception is higher than the second user perception, the number of CPUs allocated to the first user perception is greater than the number of CPUs allocated to the second user perception, and the CPU core execution capability allocated to the first user perception is stronger than the CPU execution capability allocated to the second user perception; and / or If the first execution real-time requirement is higher than the second execution real-time requirement, the number of CPUs allocated to the first execution real-time requirement is greater than the number of CPUs allocated to the second execution real-time requirement, and the CPU core execution capability allocated to the first execution real-time requirement is stronger than the CPU execution capability allocated to the second execution real-time requirement.
2. The bytecode compiling method according to claim 1, characterized in that: The determining of the current bytecode compilation scenario of the terminal includes: Based on the bytecode compilation currently executed by the terminal, determining that the current bytecode compilation scenario of the terminal is one of the following scenarios or a combination thereof: The scenarios include application installation, system first startup, system startup, system startup completion, background idle, plug-in compilation, application update, or application first use.
3. The bytecode compiling method according to claim 1, characterized in that: The performing bytecode compilation according to the current bytecode compilation scenario and the current CPU core information includes: Adding the scenario parameters representing the current bytecode compilation scenario to the data packet parsing and management object, and passing them to the bytecode compilation execution thread through the data packet bytecode compilation optimization service; The scenario parameters characterizing the current bytecode compilation scenario are added to the startup parameters of the bytecode compilation execution thread, and the bytecode is compiled using the current CPU core information corresponding to the current bytecode.
4. The bytecode compiling method according to claim 1 or 3, characterized in that: The bytecode compilation method further comprises: Outputting a running log of bytecode compilation, wherein the running log includes the current bytecode compilation scenario and the current CPU core information; The CPU core adjustment information input by the user based on the operation log is obtained, and the CPU core information corresponding to the current bytecode compilation scenario is adjusted based on the CPU core adjustment information.
5. A bytecode compiling device, characterized in that: Applied to a terminal, the bytecode compiling device comprises: a determining unit, configured to determine a current bytecode compilation scenario of the terminal, and determine current CPU core information matching the current bytecode compilation scenario based on a correspondence between the bytecode compilation scenario and the CPU core information, wherein the core information includes: a core execution capability and a core quantity; A compiling unit, configured to compile bytecodes according to the current bytecode compiling scenario and the current CPU core information; The determining unit predetermines the correspondence between the bytecode compilation scenario and the CPU core information in the following manner: Determining a plurality of bytecode compilation scenarios, and determining user perception and execution real-time performance of the plurality of bytecode compilation scenarios; Based on user perception and execution real-time, matching CPU core information is allocated to the multiple bytecode compilation scenarios respectively, wherein: If the first user perception is higher than the second user perception, the number of CPUs allocated to the first user perception is greater than the number of CPUs allocated to the second user perception, and the CPU core execution capability allocated to the first user perception is stronger than the CPU execution capability allocated to the second user perception; and / or If the first execution real-time requirement is higher than the second execution real-time requirement, the number of CPUs allocated to the first execution real-time requirement is greater than the number of CPUs allocated to the second execution real-time requirement, and the CPU core execution capability allocated to the first execution real-time requirement is stronger than the CPU execution capability allocated to the second execution real-time requirement.
6. The bytecode compiling device according to claim 5, characterized in that: The determining unit determines the current bytecode compilation scenario of the terminal in the following manner: Based on the bytecode compilation currently executed by the terminal, determining that the current bytecode compilation scenario of the terminal is one of the following scenarios or a combination thereof: The scenarios include application installation, system first startup, system startup, system startup completion, background idle, plug-in compilation, application update, or application first use.
7. The bytecode compiling device according to claim 5, characterized in that: The compiling unit performs bytecode compilation according to the current bytecode compilation scenario and the current CPU core information in the following manner: Adding the scenario parameters representing the current bytecode compilation scenario to the data packet parsing and management object, and passing them to the bytecode compilation execution thread through the data packet bytecode compilation optimization service; The scenario parameters characterizing the current bytecode compilation scenario are added to the startup parameters of the bytecode compilation execution thread, and the bytecode is compiled using the current CPU core information corresponding to the current bytecode.
8. The bytecode compiling device according to claim 5 or 7, characterized in that: The bytecode compiling device further comprises: An output unit, used to output a running log of bytecode compilation, wherein the running log includes the current bytecode compilation scenario and the current CPU core information; The adjustment unit is used to obtain CPU core adjustment information input by the user based on the operation log, and adjust the CPU core information corresponding to the current bytecode compilation scenario based on the CPU core adjustment information.
9. A bytecode compiling device, wherein: The bytecode compiling device comprises: a memory for storing instructions; and A processor, configured to call the instructions stored in the memory to execute the bytecode compilation method as described in any one of claims 1 to 4.
10. A computer-readable storage medium storing instructions, wherein when the instructions are executed by a processor, the bytecode compilation method according to any one of claims 1 to 4 is executed.
