CN112162851B - dex pre-compiling method, device, computer equipment and storage medium - Google Patents

dex pre-compiling method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN112162851B
CN112162851B CN202010960603.1A CN202010960603A CN112162851B CN 112162851 B CN112162851 B CN 112162851B CN 202010960603 A CN202010960603 A CN 202010960603A CN 112162851 B CN112162851 B CN 112162851B
Authority
CN
China
Prior art keywords
self
control group
application program
target
cpu occupancy
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010960603.1A
Other languages
Chinese (zh)
Other versions
CN112162851A (en
Inventor
李军
潘腾蛟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN202010960603.1A priority Critical patent/CN112162851B/en
Publication of CN112162851A publication Critical patent/CN112162851A/en
Application granted granted Critical
Publication of CN112162851B publication Critical patent/CN112162851B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The application discloses a dex pre-compiling method and device, computer equipment and a storage medium, and belongs to the technical field of computers. The method comprises the steps that in the process of pre-compiling a dex file of a target application program, the current CPU occupancy rate and the current frame rate are detected; if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate; and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group. According to the embodiment of the application, the operation resources occupied by the compiling process are dynamically adjusted according to the current CPU occupancy rate and the frame loss state, and the problem of blocking of the application program in the foreground running state is solved.

Description

dex pre-compiling method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a dex pre-compiling method and apparatus, a computer device, and a storage medium.
Background
In order to improve the performance of the Android system, after the Android version 4.4, the Android system runs an application program by using an Android Runtime (ART) virtual machine, and specifically, the ART virtual machine runs the application program by running an oat file.
In the prior art, the process of acquiring an oat file is as follows: and after the application program is installed, a dex file is generated and is an executable file of the android system, and a dex2oat compiling tool is called to pre-compile the dex file to obtain an oat file.
However, in the above method, since the process of calling the dex2 at compiling tool to pre-compile the dex file needs to occupy more computing resources, the application program in the foreground running state may be stuck in the running process.
Disclosure of Invention
Based on this, the embodiment of the application provides a dex pre-compiling method and apparatus, a computer device, and a storage medium, which can solve the problem of deadlock of an application program in a foreground running state.
In a first aspect, a dex precompiling method is provided, where the method includes:
detecting the current CPU occupancy rate and the current frame rate in the process of pre-compiling the dex file of the target application program;
if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate;
and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group.
In a second aspect, there is provided a dex pre-coding apparatus, the apparatus comprising:
the detection module is used for detecting the current CPU occupancy rate and the current frame rate in the process of precompiling the dex file of the target application program;
the group determination module is used for determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate;
and the binding module is used for binding the first self-control group and the precompiled compiling process and adjusting the calculation resources occupied by the compiling process by using the first self-control group.
In a third aspect, a computer device is provided, comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, implements the dex precompilation method according to the first aspect.
In a fourth aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the dex precompilation method as described in the first aspect above.
The beneficial effects that technical scheme that this application embodiment brought include at least:
in the process of pre-compiling the dex file of the target application program, detecting the current CPU occupancy rate and the current frame rate; if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate; and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group. In the method, under the condition that the current CPU occupancy rate is high and the jamming occurs, a first self-control group is determined according to the current CPU occupancy rate, then the calculation resources occupied by the compiling process are adjusted by utilizing a first self-control weight, the purpose of dynamically adjusting the calculation resources occupied by the compiling process according to the current CPU occupancy rate and the jamming condition is achieved, and the jamming problem of the application program in the foreground running state is solved.
Drawings
FIG. 1 is a block diagram of a computer device according to an embodiment of the present application;
fig. 2 is a flowchart of a dex pre-compiling method according to an embodiment of the present application;
FIG. 3 is a block diagram of a computer device according to an embodiment of the present application;
fig. 4 is a flowchart of another dex precompilation method according to an embodiment of the present application;
FIG. 5 is a flowchart of another dex pre-compiling method according to an embodiment of the present application;
fig. 6 is a flowchart of a method for detecting an operating state of a target application according to an embodiment of the present application;
fig. 7 is a flowchart of a dex precompilation method in an OTA upgrade state according to an embodiment of the present application;
fig. 8 is a block diagram of a dex pre-compiling apparatus according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
In order to improve the performance of the Android system, after the 4.4 version of the Android, the Android system adopts an Android Runtime (ART) virtual machine to run an application program, wherein the ART virtual machine runs the application program by reading an oat file.
In the prior art, after an application program is installed, a dex file is generated and is an executable file of an android system, a dex2oat compiling tool is called to establish a compiling process, and the dex file is precompiled (also called dex optimization) based on the compiling process, so that an oat file is obtained. The ART virtual machine runs the oat file, so that the running process of the application program can be smoother. Generally, the system allocates a fixed amount of computing resources to the compilation process to ensure that the compilation process runs at a certain rate.
However, the process of calling the dex2 at compiling tool to pre-compile the dex file needs to occupy more computing resources, and if the compiling process still occupies more computing resources under the condition that the overall system computing resources are in shortage, the application program in the foreground running state is blocked in the running process, which causes inconvenience to the use process of the user.
In view of the above, the embodiment of the present application provides a dex pre-compiling method, which detects a current CPU occupancy rate and a current frame rate during a process of pre-compiling a dex file of a target application program; if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate; and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group. In the method, under the conditions that the current CPU occupancy rate is high and the jamming occurs, a first self-control group is determined according to the current CPU occupancy rate, then the calculation resources occupied by the compiling process are adjusted by utilizing a first self-control weight, the purpose of dynamically adjusting the calculation resources occupied by the compiling process according to the current CPU occupancy rate and the jamming condition is achieved, the calculation resources occupied by the compiling process are dynamically adjusted according to the current CPU occupancy rate and the frame dropping state, and the problem of the jamming occurring to the application program in the foreground running state is solved.
In the following, a brief description will be given of an implementation environment related to the dex precompilation method provided in the embodiment of the present application.
In one embodiment of the present application, as shown in fig. 1, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 1. The computer device includes a processor and a memory connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The computer program is executed by a processor to implement a dex precompilation method.
Those skilled in the art will appreciate that the architecture shown in fig. 1 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
Please refer to fig. 2, which illustrates a flowchart of a dex precompilation method according to an embodiment of the present application, where the dex precompilation method may include the following steps:
step 201, in the process of precompiling the dex file of the target application program, the computer device detects the current CPU occupancy rate and the current frame rate.
The target application program is an application program which is currently subjected to dex file precompilation. The CPU occupancy rate represents the CPU resource occupied by the running application program, the high CPU occupancy rate represents the high operation load of the current computer equipment, and the low CPU occupancy rate represents the low operation load of the current computer equipment. Frame rate (english) is the frequency (or rate) at which bitmap images, called units of frames, appear continuously on the display of a computer device.
In an alternative implementation, the process of precompiling the dex file of the target application program by the computer device may include the following steps: when detecting that the target application program is opened for the first time after installation, the computer equipment calls a dex2oat compiling tool to establish a compiling process, reads a dex file of the target application program based on the compiling process, and performs pre-compiling on the dex file to obtain the oat file.
In another alternative implementation, the process of precompiling the dex file of the target application program by the computer device may include the following: in the process of calling the ART virtual machine to test the oat file of the running application program, if an error occurs, the computer equipment calls a dex2oat compiling tool to perform recompilation on the dex file of the error-occurring application program.
In the pre-compiling process, the computer device may detect a current CPU occupancy rate and a current frame rate, where the current CPU occupancy rate may be used to reflect a current load condition of the computer device, and the current frame rate may be used to reflect whether an operation process of the application program in a foreground operation state is smooth. Specifically, as shown in fig. 3, in the embodiment of the present application, a CPU monitor, a frame rate monitor, and a dex2oat controller are disposed in a computer device, and the computer device may invoke the CPU monitor to monitor the current usage rate of the CPU, and determine the usage rate of the CPU as the CPU occupancy rate. At the same time, the computer device may invoke the frame rate monitor to monitor the current frame rate of the computer device. The computer device may then invoke the dex2oat manager to determine an operating policy for dex2oat based on the current CPU occupancy and current frame rate.
Step 202, if the current CPU occupancy rate is greater than the first threshold and the current frame rate is less than the preset frame rate, the computer device determines the first self-control group from the target self-control group pool according to the current CPU occupancy rate.
In the embodiment of the application, after the computer device obtains the current CPU occupancy rate, the computer device may call the dex2oat manager to compare the current CPU occupancy rate with a first threshold, indicate that the current CPU load is high if the current CPU occupancy rate is greater than the first threshold, and indicate that the current CPU load is small if the current CPU occupancy rate is less than the first threshold.
The computer device may further call the dex2oat manager to compare the current frame rate with a preset frame rate after acquiring the current frame rate, where the preset frame rate is a preset frame rate of the computer device, and the preset frame rate is used for displaying an image on the display to enable a user to perceive a smooth visual image. If the current frame rate is less than the preset frame rate, it indicates that the frame drop condition occurs in the application program currently in the foreground running state, and under the condition, the visual picture perceived by the user is blocked.
In the embodiment of the present application, the current CPU occupancy is greater than the first threshold, and the current frame rate is less than the preset frame rate, which indicates that: in the case that the current CPU load is high and the application program in the foreground operating state is stuck due to the high current CPU load, as shown in fig. 3, the computer device may invoke a dex2 at manager to control the compilation process to enter the self-control group mode, that is, the computer device may invoke the dex2 at manager to determine the first self-control group from the target self-control group pool according to the current CPU occupancy rate.
The self-control group (english: cgroup) provides a set of mechanism for controlling the use of the compiling process to the computing resources, cgroup can be used for scheduling the computing resources or controlling the upper limit of the use of the computing resources, and one cgroup can control a plurality of different computing resources, such as CPU resources, storage resources and the like.
In this embodiment of the present application, a target self-control group pool is stored in a computer device, where the target self-control group pool is a set of multiple cgroups, and in this embodiment of the present application, the computer device may create a directory in a file system corresponding to the target self-control group pool, so as to create the cgroups, and then set an upper limit of use of schedulable computing resources or schedulable computing resources of the created cgroups by writing contents to an attribute file in the directory.
In the embodiment of the application, different cgroups correspond to different schedulable computing resources or correspond to the upper usage limits of schedulable computing resources of different levels, that is, different cgroups correspond to different computation resource scheduling capabilities, the higher the computation resource scheduling capability is, the more schedulable resources are, and the smaller the computation resource scheduling capability is, the less schedulable resources are.
In the embodiment of the present application, a plurality of cgroups included in the target self-control group pool respectively correspond to different CPU occupancy rates. Optionally, the computer device may store a correspondence list between a plurality of cgroups and different CPU occupancy rates, and the computer device may search the first self-control group corresponding to the current CPU occupancy rate from the correspondence list according to the current CPU occupancy rate.
It should be noted that, in the embodiment of the present application, in the correspondence list between multiple cgroups and different CPU occupancy rates, the CPU occupancy rate is negatively related to the operation resource scheduling capability of the self-control group.
Step 203, the computer device binds the first self-control group with the pre-compiled compiling process, and adjusts the operation resources occupied by the compiling process by using the first self-control group.
Alternatively, computational resources may include, but are not limited to, CPU resources and memory resources.
In the embodiment of the application, the configuration file of each self-control group includes a task attribute file, and the task attribute file is used for recording the process identifier of the process currently bound with the self-control group. The process of binding the first self-control group and the pre-compiled compilation process by the computer device may refer to: the computer equipment can obtain the process identifier of the precompiled compiling process, and then the process identifier is written into the task attribute file of the first self-control group, so that the compiling process is bound to the first self-control group, and the resource information which can be used by the compiling process is controlled by the first self-control group. The operation resources occupied by the compiling process are adjusted through the first self-control group, so that the operation resources occupied by the compiling process can be reduced, more operation resources can be provided for foreground application, and the problem of the application program in a foreground running state is solved.
The dex pre-compiling method provided by the embodiment of the application detects the current CPU occupancy rate and the current frame rate in the process of pre-compiling the dex file of the target application program; if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate; and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group. In the method, under the condition that the current CPU occupancy rate is high and the jamming occurs, a first self-control group is determined according to the current CPU occupancy rate, then the calculation resources occupied by the compiling process are adjusted by utilizing a first self-control weight, the purpose of dynamically adjusting the calculation resources occupied by the compiling process according to the current CPU occupancy rate and the jamming condition is achieved, and the jamming problem of the application program in the foreground running state is solved.
In an embodiment of the present application, in the case of not going out of the jam, if the budget resources occupied by the compiling process are still adjusted in a self-control group manner, the complexity of resource allocation may be increased, and based on this, the dex precompilation method provided in the embodiment of the present application further includes the following contents:
and if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is equal to the preset frame rate, the computer equipment controls the compiling process to enter a CPU enhancement mode.
The CPU enhancement (english CPU Boost) mode is a mode for automatically overclocking to improve the CPU performance based on an automatic overclocking technology under the condition that the dominant frequency is not enough. Under the CPU enhancement mode, the computer equipment can automatically adjust the opening and closing of the multi-core according to the current calculation amount of the CPU so as to allocate resources to the running process and exert the maximum performance of the CPU under the condition of ensuring that the total power consumption of the processor is not changed.
In the embodiment of the present application, if the current CPU occupancy is greater than the first threshold and the current frame rate is equal to the preset frame rate, this indicates that: the application program with high CPU load but in foreground running state is not blocked. In this case, as shown in fig. 3, the computer device may call the dex2oat manager to control the compilation process to enter a CPU enhanced (english CPU Boost) mode.
In the embodiment of the application, under the condition that the application program in the foreground running state is not blocked, the compiling process is controlled to enter the CPU enhanced mode, so that the control on the compiling process can be reduced, and the complexity of resource allocation when a dex2oat compiling tool is called is reduced.
In an embodiment of the present application, as shown in fig. 4, the dex precompilation method may further include the following steps:
step 401, if the current CPU occupancy rate is less than the second threshold, the computer device determines the second self-control group from the target self-control group pool according to the current CPU occupancy rate.
Wherein the second threshold is less than or equal to the first threshold.
In the embodiment of the application, the fact that the current CPU occupancy rate is smaller than the second threshold value indicates that the current CPU load is smaller. In this case, the operation resources allocated to the compiling process can be increased in order to improve the work efficiency of the compiling process. The process of determining the second self-control group from the target self-control group pool by the computer device according to the current CPU occupancy rate may refer to the disclosure in step 202.
Step 402, the computer device binds the second self-control group with the pre-compiled compilation process, and adjusts the operation resources occupied by the compilation process by using the second self-control group.
In this embodiment of the application, the process of binding the second self-control group and the pre-compiled compilation process by the computer device may refer to: the computer equipment can obtain the process identification of the pre-compiled compiling process, and then the process identification is written into the task attribute file of the second self-control group, so that the compiling process is bound to the second self-control group, and the resource information which can be used by the compiling process is controlled by the second self-control group.
In the embodiment of the application, under the condition that the current CPU occupancy rate is small, the second self-control group is determined from the target self-control group pool in a self-control group mode according to the current CPU occupancy rate, and more operation resources can be allocated to the compiling process by adjusting the operation resources occupied by the compiling process by using the second self-control group, so that the efficiency of the compiling process is improved.
In an embodiment of the present application, the first self-control group is determined only according to the current CPU occupancy rate, and the influence of the running state of the target application program on the precompilation process is ignored, and to solve this problem, as shown in fig. 5, the dex precompilation method provided in the embodiment of the present application may further include the following steps:
step 501, the computer device detects whether the target application program is in a foreground running state, and obtains a detection result.
The detection result may include two types, one type is that the target application program is in a foreground running state, and the other type is that the target application program is in a background running state.
The process of detecting whether the target application program is in the foreground running state by the computer device to obtain the detection result may be as shown in fig. 6:
step 601, the computer equipment acquires the top package name of the foreground running task stack.
Wherein, the package name refers to the unique identification of the application program. The package name at the top of the stack refers to the package name at the top of the stack in which the task stack is operated in the foreground.
In the embodiment of the application, when an application is in a foreground running state, the packet name of the application is automatically written into a foreground running task stack. Since a user may start multiple applications at the same time, in this case, packet names of multiple applications may exist in the foreground running task stack. And the package name at the top of the stack is the package name of the application program currently in the foreground running state.
Step 602, the computer device determines whether the package name at the top of the stack is consistent with the package name of the target application program, and if so, determines that the target application program is in a foreground operating state; and if not, determining that the target application program is in a background running state.
In this embodiment of the application, after the computer device obtains the package name at the top of the stack, it may compare whether the package name at the top of the stack is consistent with the package name of the target application, and if the package name at the top of the stack is consistent with the package name of the target application, it indicates that the application currently in the foreground running state and the target application are the same application, so it is determined that the target application is in the foreground running state. If the package name at the top of the stack is inconsistent with the package name of the target application program, it is indicated that the application program in the foreground running state is not the target application program, and therefore the target application program is determined to be in the background running state.
Step 502, the computer device determines the target self-control group pool according to the detection result.
In the embodiment of the application, if the detection result is that the target application program is in the foreground running state, the self-control group pool corresponding to the foreground running state is used as the target self-control group pool; and if the detection result is that the target application program is in the background running state, taking the self-control group pool corresponding to the background running state as the target self-control group pool.
The resource scheduling capability of the plurality of self-control groups included in the self-control group pool corresponding to the foreground running state is high, and the resource scheduling capability of the plurality of self-control groups included in the self-control group pool corresponding to the background running state is low.
Optionally, all or part of the plurality of self-control groups included in the self-control group pool corresponding to the foreground operating state may be the same as the plurality of self-control groups included in the self-control group pool corresponding to the background operating state.
For example, the self-control group pool corresponding to the foreground running state includes 5 self-control groups, resource scheduling capabilities of the 5 self-control groups are arranged in sequence from high to low, and the self-control group pool corresponding to the background running state may only include the first 3 self-control groups in the 5 self-control group applications. That is, when the self-control group pool corresponding to the foreground operation state is the target self-control group pool, the resource scheduling capability of the selectable self-control group is high, and when the self-control group pool corresponding to the background operation state is the target self-control group pool, the resource scheduling capability of the selectable self-control group is low.
Step 503, the computer device determines a first self-control group from the target self-control group pool according to the current CPU occupancy rate.
In the embodiment of the application, the computer device determines the first self-control group from the target self-control group pool according to the current CPU occupancy rate on the basis of the running state of the target application program.
In the embodiment of the application, the self-control group pool corresponding to the foreground running state and the self-control group pool corresponding to the background running state are set, so that the current running state factor of the target application program is taken into consideration, and the first self-control group which meets the requirements better can be determined.
In practical applications, an operating system in a computer device may be updated and upgraded, and after the system is upgraded, when some application programs are opened for the first time, the problem of application program stalling may occur, and for this situation, the embodiment of the present application provides a dex pre-compilation method, as shown in fig. 7, the method includes the following steps:
step 701, after detecting system upgrade, the computer device calls the virtual machine at the android running time to run the installed application program.
In the embodiment of the application, the computer device may perform system upgrade according to an OTA (Over the Air Technology) -based Technology, where OTA upgrade refers to a Technology in which a mobile phone terminal downloads an upgrade package on a remote server through a wireless network to upgrade a system or an application.
In the embodiment of the present application, after the OTA upgrade, as shown in fig. 3, the computer device may call the OTA monitor to monitor the first start-up after the current OTA upgrade, and call the ART virtual machine to sequentially run the oat files of the installed application programs in the background when the OTA is started up after the upgrade, so as to detect the compatibility of each application program with the upgraded system.
Step 702, if an error occurs while running the target application program, the computer device pre-compiles the dex file of the target application program.
In the process of running the target application program, if an error occurs, the computer equipment performs recompilation on the dex file of the target application program. The recompilation process may refer to the disclosure of steps 201-203.
In the embodiment of the application, after the system is upgraded, the ART virtual machine is actively called to run the oat files of the application programs in the background, and the dex files of the target application programs are recompiled under the condition of error reporting. In this way, optimization can be done before the user uses the target application, thereby ensuring that OTA upgrades do not affect the user's use.
It should be understood that although the various steps in the flowcharts of fig. 2-7 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not limited to being performed in the exact order illustrated and, unless explicitly stated herein, may be performed in other orders. Moreover, at least some of the steps in fig. 2-7 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
Referring to fig. 8, a block diagram of a dex pre-compiling apparatus 800 according to an embodiment of the present application is shown, where the dex pre-compiling apparatus 800 can be configured in a computer device in the implementation environment shown in fig. 1. As shown in fig. 8, the dex pre-coding apparatus 800 may include: a detection module 801, a group determination module 802, and a binding module 803.
The detection module 801 is configured to detect a current CPU occupancy rate and a current frame rate in a process of precompiling a dex file of a target application program;
a group determining module 802, configured to determine, if the current CPU occupancy is greater than a first threshold and the current frame rate is less than a preset frame rate, a first self-control group from the target self-control group pool according to the current CPU occupancy;
the binding module 803 is configured to bind the first self-control group with the pre-compiled compiling process, and adjust the operation resource occupied by the compiling process by using the first self-control group.
In one embodiment of the present application, the group determination module 802 is further configured to:
and if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is equal to the preset frame rate, controlling the compiling process to enter a CPU enhancement mode.
In one embodiment of the present application, the group determination module 802 is further configured to:
if the current CPU occupancy rate is smaller than a second threshold value, determining a second self-control group from the target self-control group pool according to the current CPU occupancy rate, wherein the second threshold value is smaller than or equal to the first threshold value;
and binding the second self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the second self-control group.
In one embodiment of the present application, the group determination module 802 is further configured to:
detecting whether the target application program is in a foreground running state or not to obtain a detection result;
and determining the target self-control group pool according to the detection result.
In one embodiment of the present application, the group determination module 802 is further configured to:
if the detection result is that the target application program is in a foreground running state, taking the self-control group pool corresponding to the foreground running state as a target self-control group pool;
and if the detection result is that the target application program is in the background running state, taking the self-control group pool corresponding to the background running state as the target self-control group pool.
In one embodiment of the present application, the detection module 801 is configured to:
after detecting the system upgrade, calling the virtual machine at the android running time to run the installed application program;
and if an error is reported when the target application program is operated, pre-compiling the dex file of the target application program.
In one embodiment of the present application, the group determination module 802 is further configured to:
acquiring a stack top packet name of a foreground running task stack;
judging whether the package name at the top of the stack is consistent with the package name of the target application program, and if so, determining that the target application program is in a foreground running state;
and if not, determining that the target application program is in a background running state.
For specific limitations of the dex precompiling device, reference may be made to the above limitations of the dex precompiling method, which are not described herein again. The modules in the dex pre-compiling apparatus can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute the operations of the modules.
In one embodiment of the present application, there is provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the following steps when executing the computer program:
in the process of precompiling a dex file of a target application program, detecting the current CPU occupancy rate and the current frame rate;
if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate;
and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group.
In one embodiment of the application, the processor when executing the computer program further performs the steps of:
and if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is equal to the preset frame rate, controlling the compiling process to enter a CPU enhancement mode.
In one embodiment of the application, the processor when executing the computer program further performs the steps of:
if the current CPU occupancy rate is less than a second threshold value, determining a second self-control group from the target self-control group pool according to the current CPU occupancy rate, wherein the second threshold value is less than or equal to the first threshold value;
and binding the second self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the second self-control group.
In one embodiment of the application, the processor when executing the computer program further performs the steps of:
detecting whether the target application program is in a foreground running state or not to obtain a detection result;
and determining the target self-control group pool according to the detection result.
In one embodiment of the application, the processor when executing the computer program further performs the steps of:
if the detection result is that the target application program is in a foreground running state, taking a self-control group pool corresponding to the foreground running state as a target self-control group pool;
and if the detection result is that the target application program is in the background running state, taking the self-control group pool corresponding to the background running state as the target self-control group pool.
In one embodiment of the application, the processor when executing the computer program further performs the steps of:
after detecting the system upgrade, calling the virtual machine at the android running time to run the installed application program;
and if an error occurs when the target application program is operated, pre-compiling the dex file of the target application program.
In one embodiment of the application, the processor when executing the computer program further performs the steps of:
acquiring a stack top packet name of a foreground operating task stack;
judging whether the package name at the top of the stack is consistent with the package name of the target application program, and if so, determining that the target application program is in a foreground running state;
and if not, determining that the target application program is in a background running state.
The implementation principle and technical effect of the computer device provided by the embodiment of the present application are similar to those of the method embodiment described above, and are not described herein again.
In an embodiment of the application, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of:
detecting the current CPU occupancy rate and the current frame rate in the process of pre-compiling the dex file of the target application program;
if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from the target self-control group pool according to the current CPU occupancy rate;
and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group.
In one embodiment of the application, the computer program when executed by the processor further performs the steps of:
and if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is equal to the preset frame rate, controlling the compiling process to enter a CPU enhancement mode.
In one embodiment of the application, the computer program when executed by the processor further performs the steps of:
if the current CPU occupancy rate is smaller than a second threshold value, determining a second self-control group from the target self-control group pool according to the current CPU occupancy rate, wherein the second threshold value is smaller than or equal to the first threshold value;
and binding the second self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the second self-control group.
In one embodiment of the application, the computer program when executed by the processor further performs the steps of:
detecting whether a target application program is in a foreground running state or not to obtain a detection result;
and determining the target self-control group pool according to the detection result.
In one embodiment of the application, the computer program when executed by the processor further performs the steps of:
if the detection result is that the target application program is in a foreground running state, taking a self-control group pool corresponding to the foreground running state as a target self-control group pool;
and if the detection result is that the target application program is in the background running state, taking the self-control group pool corresponding to the background running state as the target self-control group pool.
In one embodiment of the application, the computer program when executed by the processor further performs the steps of:
after the system upgrade is detected, calling the virtual machine at the android running time to run the installed application program;
and if an error is reported when the target application program is operated, pre-compiling the dex file of the target application program.
In one embodiment of the application, the computer program when executed by the processor further performs the steps of:
acquiring a stack top packet name of a foreground running task stack;
judging whether the package name at the top of the stack is consistent with the package name of the target application program, and if so, determining that the target application program is in a foreground running state;
and if not, determining that the target application program is in a background running state.
The implementation principle and technical effect of the computer-readable storage medium provided by this embodiment are similar to those of the above-described method embodiment, and are not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above may be implemented by hardware instructions of a computer program, which may be stored in a non-volatile computer-readable storage medium, and when executed, may include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), rambus (Rambus) direct RAM (RDRAM), direct Rambus Dynamic RAM (DRDRAM), and Rambus Dynamic RAM (RDRAM), among others.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the claims. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A dex precompilation method, the method comprising:
detecting the current CPU occupancy rate and the current frame rate in the process of pre-compiling the dex file of the target application program;
if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate, determining a first self-control group from a target self-control group pool according to the current CPU occupancy rate; the target self-control group pool is a set of a plurality of self-control groups, and the self-control groups are used for controlling different operation resources; the operation resources at least comprise CPU resources and storage resources;
and binding the first self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the first self-control group.
2. The method of claim 1, further comprising:
and if the current CPU occupancy rate is greater than the first threshold value and the current frame rate is equal to the preset frame rate, controlling the compiling process to enter a CPU enhancement mode.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
if the current CPU occupancy rate is smaller than a second threshold value, determining a second self-control group from the target self-control group pool according to the current CPU occupancy rate, wherein the second threshold value is smaller than or equal to the first threshold value;
and binding the second self-control group with the pre-compiled compiling process, and adjusting the operation resources occupied by the compiling process by using the second self-control group.
4. The method of claim 1, wherein before determining a first self-control group from a target self-control group pool based on the current CPU occupancy, the method further comprises:
detecting whether the target application program is in a foreground running state or not to obtain a detection result;
and determining the target self-control group pool according to the detection result.
5. The method of claim 4, wherein said determining the target self-control group pool according to the detection result comprises:
if the detection result is that the target application program is in a foreground running state, taking a self-control group pool corresponding to the foreground running state as the target self-control group pool;
and if the detection result is that the target application program is in a background running state, taking a self-control group pool corresponding to the background running state as the target self-control group pool.
6. The method according to claim 1, characterized in that it comprises:
after detecting the system upgrade, calling the virtual machine at the android running time to run the installed application program;
and if an error is reported when the target application program is operated, pre-compiling the dex file of the target application program.
7. The method of claim 4, wherein the detecting whether the target application is in a foreground running state comprises:
acquiring a stack top packet name of a foreground operating task stack;
judging whether the package name at the top of the stack is consistent with the package name of the target application program, and if so, determining that the target application program is in a foreground running state;
and if not, determining that the target application program is in a background running state.
8. A dex precoding apparatus, comprising:
the detection module is used for detecting the current CPU occupancy rate and the current frame rate in the process of precompiling the dex file of the target application program;
the group determination module is used for determining a first self-control group from a target self-control group pool according to the current CPU occupancy rate if the current CPU occupancy rate is greater than a first threshold value and the current frame rate is less than a preset frame rate; the target self-control group pool is a set of a plurality of self-control groups, and the self-control groups are used for controlling different operation resources; the operation resources at least comprise CPU resources and storage resources;
and the binding module is used for binding the first self-control group and the precompiled compiling process and adjusting the calculation resources occupied by the compiling process by using the first self-control group.
9. A computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, implements the method of any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN202010960603.1A 2020-09-14 2020-09-14 dex pre-compiling method, device, computer equipment and storage medium Active CN112162851B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010960603.1A CN112162851B (en) 2020-09-14 2020-09-14 dex pre-compiling method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010960603.1A CN112162851B (en) 2020-09-14 2020-09-14 dex pre-compiling method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112162851A CN112162851A (en) 2021-01-01
CN112162851B true CN112162851B (en) 2022-12-13

Family

ID=73858018

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010960603.1A Active CN112162851B (en) 2020-09-14 2020-09-14 dex pre-compiling method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112162851B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948074B (en) * 2021-02-01 2023-08-18 驭新智行科技(宁波)有限公司 CPU resource scheduling method of dex2oat process and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105740075A (en) * 2016-01-27 2016-07-06 浪潮(北京)电子信息产业有限公司 CPU (Central Processing Unit) scheduling method and system
CN107168749A (en) * 2017-05-31 2017-09-15 腾讯科技(深圳)有限公司 A kind of Compilation Method, device, equipment and computer-readable recording medium
CN108268425A (en) * 2016-12-30 2018-07-10 英特尔公司 Programmable matrix handles engine
CN108279976A (en) * 2017-12-26 2018-07-13 努比亚技术有限公司 A kind of compiling resource regulating method, computer and computer readable storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006127302A (en) * 2004-10-29 2006-05-18 Internatl Business Mach Corp <Ibm> Information processor, compiler and compiler program
CN104978235A (en) * 2015-06-30 2015-10-14 柏斯红 Operating frequency prediction based load balancing method
CN107392619B (en) * 2017-07-31 2020-12-29 众安信息技术服务有限公司 Intelligent contract processing method and device
CN110018904A (en) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 Information processing method, device, computer equipment and computer readable storage medium
CN110865881A (en) * 2018-08-27 2020-03-06 中移(苏州)软件技术有限公司 Resource scheduling method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105740075A (en) * 2016-01-27 2016-07-06 浪潮(北京)电子信息产业有限公司 CPU (Central Processing Unit) scheduling method and system
CN108268425A (en) * 2016-12-30 2018-07-10 英特尔公司 Programmable matrix handles engine
CN107168749A (en) * 2017-05-31 2017-09-15 腾讯科技(深圳)有限公司 A kind of Compilation Method, device, equipment and computer-readable recording medium
CN108279976A (en) * 2017-12-26 2018-07-13 努比亚技术有限公司 A kind of compiling resource regulating method, computer and computer readable storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"liteos CPU占用率";233333;《https://cloud.tencent.com/developer/article/1448439》;20190619;第1-8页 *
"TransMap:Transformation Based Remapping and Parallelism for High Utilization and Energy Efficiency in CGRAs";Syed M.A.H. Jafri;《IEEE Transactions on Computers》;20161130;第65卷(第11期);第3456-3469页 *
"基于GPU加速的移动端LDPC译码方法与实现";苏炜跃;《中国优秀硕士学位论文全文数据库 信息科技辑》;20190115(第01期);第I136-310页 *

Also Published As

Publication number Publication date
CN112162851A (en) 2021-01-01

Similar Documents

Publication Publication Date Title
US8566826B2 (en) System and method for synchronizing transient resource usage between virtual machines in a hypervisor environment
US10101910B1 (en) Adaptive maximum limit for out-of-memory-protected web browser processes on systems using a low memory manager
JP6370218B2 (en) MEMORY MANAGEMENT METHOD, COMPUTER SYSTEM, COMPUTER PROGRAM, AND STORAGE MEDIUM
CN111104208B (en) Process scheduling management method, device, computer equipment and storage medium
US10289446B1 (en) Preserving web browser child processes by substituting a parent process with a stub process
US20120317331A1 (en) Using cooperative greedy ballooning to reduce second level paging activity
CN110704177B (en) Computing task processing method and device, computer equipment and storage medium
CN110018859B (en) Equipment starting method and device, computer equipment and storage medium
JP2014520346A (en) Computer-implemented method and computer system
JP2014523022A (en) Computer-implemented method and computer system
CN112486642B (en) Resource scheduling method, device, electronic equipment and computer readable storage medium
US20170364449A1 (en) Process running method and apparatus
CN112162851B (en) dex pre-compiling method, device, computer equipment and storage medium
CN111338779A (en) Resource allocation method, device, computer equipment and storage medium
CN112667380A (en) Multiprocessor task scheduling method, device and storage medium
CN108984244A (en) Browser page rendering method, electronic device and computer readable storage medium
US10248321B1 (en) Simulating multiple lower importance levels by actively feeding processes to a low-memory manager
CN108984270B (en) Memory allocation method and device for virtual machine
US11561843B2 (en) Automated performance tuning using workload profiling in a distributed computing environment
CN117056080A (en) Distribution method and device of computing resources, computer equipment and storage medium
KR101950485B1 (en) Task Management Method for Providing Real-time Performance to Android
CN106201664B (en) Have the data processing method and system of application information perception
KR101950484B1 (en) Task Management Device for Providing Real-time Performance to Android
CN113282363A (en) Method and device for optimizing hybrid APP
US10324752B2 (en) Response times based on application states

Legal Events

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