CN115016885B - Virtual machine garbage recycling operation method and electronic equipment - Google Patents

Virtual machine garbage recycling operation method and electronic equipment Download PDF

Info

Publication number
CN115016885B
CN115016885B CN202111389659.7A CN202111389659A CN115016885B CN 115016885 B CN115016885 B CN 115016885B CN 202111389659 A CN202111389659 A CN 202111389659A CN 115016885 B CN115016885 B CN 115016885B
Authority
CN
China
Prior art keywords
daemon
core
binding
value
thread
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
CN202111389659.7A
Other languages
Chinese (zh)
Other versions
CN115016885A (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.)
Honor Device Co Ltd
Original Assignee
Honor Device 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 Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202111389659.7A priority Critical patent/CN115016885B/en
Publication of CN115016885A publication Critical patent/CN115016885A/en
Application granted granted Critical
Publication of CN115016885B publication Critical patent/CN115016885B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides a virtual machine garbage collection operation method and electronic equipment. The method comprises the following steps: the electronic equipment dynamically adjusts the running core of the GC daemon according to the frequent condition that the GC daemon carries out GC and the temperature value of the electronic equipment. Therefore, when the GC frequently happens, the power consumption of the running of the electronic equipment GC can be reduced, the heating phenomenon of the electronic equipment is lightened, and the phenomenon that a foreground application is blocked and frames are dropped due to the fact that CPU resources are preempted by daemon threads can be avoided as much as possible, so that the use experience of a user is improved.

Description

Virtual machine garbage recycling operation method and electronic equipment
Technical Field
The application relates to the technical field of intelligent terminals, in particular to a virtual machine garbage collection operation method and electronic equipment.
Background
GC (Garbage Collection ) refers to an automatic memory management mechanism. When some occupied memory is no longer needed, it should be freed to make room, and this storage resource management is called garbage collection.
During the running of the virtual machine, if the generated garbage reaches a certain amount of threshold, the daemon thread of the virtual machine starts garbage collection, that is, GC occurs. If GC occurs frequently, the load of the CPU (Central Processing Unit ) becomes high, the whole electronic device (such as a mobile phone) heats up, the power consumption increases, and the phenomenon that the foreground application is blocked and frames are dropped due to the fact that the CPU resource is preempted by the daemon thread may also occur. Thus, the user experience is poor.
Disclosure of Invention
In order to solve the technical problems, the embodiment of the application provides a virtual machine garbage collection operation method, electronic equipment and electronic equipment. According to the method, the electronic equipment dynamically adjusts the running core of the GC daemon according to the frequent condition that the GC daemon carries out GC and the temperature value of the electronic equipment, so that the power consumption of GC running is reduced when the GC frequently happens, the heating phenomenon of the electronic equipment is reduced, the phenomenon that a foreground application is blocked and frames are dropped due to the fact that CPU resources are preempted by the daemon is avoided as much as possible, and the use experience of a user is improved.
In a first aspect, an embodiment of the present application provides a virtual machine garbage collection operation method. The method comprises the following steps: when the GC daemon finishes the GC operation each time, the electronic equipment acquires related data of the GC operation and an equipment temperature value; the electronic equipment combines the related data of the GC running at this time to judge the frequent condition of the GC running; and the electronic equipment adjusts the operation core of the GC daemon thread according to the equipment temperature value and the GC operation frequent condition. Therefore, the dynamic adjustment of the running core of the GC daemon thread is realized, the power consumption of GC running can be reduced when the GC frequently happens, the heating phenomenon of the electronic equipment is lightened, and the phenomenon that a foreground application is blocked and frames are dropped due to the fact that CPU resources are preempted by the daemon thread can be avoided, so that the use experience of a user is improved.
For example, the GC-running related data may include: GC run start time and GC end time.
According to a first aspect, the electronic device adjusts an operation core of a GC daemon according to a device temperature value and GC operation frequency, including: when the equipment temperature value is larger than a preset temperature threshold value, the electronic equipment adjusts the GC daemon thread to run on a CPU core with the lowest processing energy efficiency ratio in the electronic equipment. The lower the processing energy efficiency ratio of the CPU core, the higher the power consumption thereof, and the more serious the heating phenomenon. When the equipment temperature value is higher, the running core of the GC daemon thread is adjusted to be on the CPU core with the lowest processing energy efficiency ratio in the electronic equipment, so that the power consumption of the electronic equipment can be effectively reduced, and the heating phenomenon of the electronic equipment is reduced.
By way of example, the CPU core with the lowest processing energy efficiency ratio in the electronic device may be a CPU corelet.
According to the first aspect, or any implementation manner of the first aspect, the electronic device adjusts an operation core of the GC daemon according to the device temperature value and the GC operation frequency, including: when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the GC is operated frequently, the electronic equipment adjusts the GC daemon thread from being operated on the first CPU core to be operated on the second CPU core; wherein, the processing energy efficiency ratio of the second CPU core is lower than that of the first CPU core; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the GC is not operated frequently, the electronic equipment adjusts the GC daemon thread from being operated on the first CPU core to be operated on the third CPU core; wherein the processing energy efficiency ratio of the third CPU core is higher than the processing energy efficiency ratio of the first CPU core. Therefore, when the equipment temperature value is low, if the GC is operated frequently, the operating core of the GC daemon thread is adjusted from the CPU core with higher processing energy efficiency to the CPU core with lower processing energy efficiency, so that the power consumption of the electronic equipment is reduced, and the heating phenomenon of the electronic equipment is lightened. When the temperature value of the equipment is lower, if the GC runs infrequently, the running core of the GC daemon thread is adjusted to be a CPU core with higher processing energy efficiency from a CPU core with lower processing energy efficiency, so that the running efficiency of the GC daemon thread is improved.
For example, when the first CPU core is a CPU middle core, the second CPU core may be a CPU small core. Further exemplary, when the first CPU core is a CPU corelet, the third CPU core may be a CPU corelet. Wherein, the processing energy efficiency ratio of the CPU small core, the CPU small core and the CPU middle core is sequentially increased.
According to the first aspect, or any implementation manner of the first aspect, the method further includes: the electronic equipment acquires the interrupt program time length of the GC running at this time; the method comprises the steps that a GC daemon time is used for indicating the time when the GC daemon thread sends interrupt requests to other threads except the GC daemon thread and the time when the GC daemon thread sends ending interrupt requests to the other threads; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the program interruption time is longer than the preset time threshold value, the electronic equipment does not bind the running cores of the GC daemon. The longer the interrupt program duration, the greater the influence of the running of the GC daemon on the running of other front-end programs. Therefore, when the program interruption time is too long in the GC running process, the electronic equipment does not limit the running cores of the GC daemon, and the problem that other programs cannot normally run due to the core binding operation of the GC daemon can be avoided.
According to a first aspect, or any implementation manner of the first aspect, the electronic device does not bind the running core of the GC daemon thread, including: if the operating core of the GC daemon is bound, the electronic equipment cancels the binding operation of the operating core of the GC daemon; if the running core of the GC daemon is not bound, the electronic device maintains the state that the running core of the GC daemon is not bound.
According to the first aspect, or any implementation manner of the first aspect, the electronic device adjusts an operation core of the GC daemon thread, including: the electronic device adjusts the binding core strength value of the GC daemon thread; the electronic equipment adjusts the running core of the GC daemon according to the binding core strategy corresponding to the adjusted binding core intensity value; wherein, different binding core intensity values correspond to different binding core strategies; the binding strategy at least comprises the following steps: the GC daemon thread is bound to run on the CPU corelet, and the running core of the GC daemon thread is not bound. Therefore, the electronic device adjusts the binding core strength value of the GC daemon to realize the adjustment of the running core of the GC daemon, for example, the running core of the GC daemon is adjusted to be a CPU small core, a CPU middle core or a CPU middle core, or the running core of the GC daemon is not limited, so that the power consumption of GC running is reduced when GC frequently happens, the heating phenomenon of the electronic device is reduced, the phenomenon that a foreground application is blocked and frames are dropped due to the fact that CPU resources are preempted by the daemon is avoided as much as possible, and the use experience of a user is improved.
According to the first aspect, or any implementation manner of the first aspect, the electronic device adjusts a binding core strength value of a GC daemon thread, including: the electronic device increases the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the second CPU core; the electronic device reduces the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the third CPU core; or the electronic device reduces the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the second CPU core; the electronic device increases the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the third CPU core; the processing energy efficiency ratio of the second CPU core is lower than that of the first CPU core, and the processing energy efficiency ratio of the third CPU core is higher than that of the first CPU core; the electronic device resets the binding core strength value of the GC daemon thread to adjust the running of the GC daemon thread on the CPU core with the lowest processing energy efficiency ratio in the electronic device, or does not bind the running core of the GC daemon thread.
For example, when the first CPU core is a CPU middle core, the second CPU core may be a CPU small core. Further exemplary, when the first CPU core is a CPU corelet, the third CPU core may be a CPU corelet. Wherein, the processing energy efficiency ratio of the CPU small core, the CPU small core and the CPU middle core is sequentially increased.
Illustratively, as the binding core strength value increases, the corresponding binding core policy instructs the running core of the GC daemon to be tuned to a CPU core with a higher processing energy efficiency ratio.
Further exemplary, as the binding core strength value decreases, the corresponding binding core policy instructs the running core of the GC daemon to be tuned to a CPU core with a higher processing energy efficiency ratio.
According to the first aspect, or any implementation manner of the first aspect, when the binding core strength values are 0, 1, 2, and 3, the binding core policies are in turn: binding the GC daemon thread to a CPU corelet for running; binding the GC daemon thread on a small core in the CPU for running; binding the GC daemon thread on a CPU core to run; the running cores of the GC daemon thread are not bound. The electronic device adjusting a binding core strength value of a GC daemon thread, comprising: when the equipment temperature value is larger than a preset temperature threshold value, resetting the binding core strength value of the GC daemon thread to 0 by the electronic equipment; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the GC is operated frequently, the electronic equipment reduces the binding core strength value of the GC daemon thread; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the GC is not operated frequently, the electronic equipment increases the binding core strength value of the GC daemon thread; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the program interruption time is longer than the preset time threshold value, the electronic equipment resets the binding core strength value of the GC daemon thread to 3.
For example, the electronic device may adjust the binding core strength value of the GC daemon thread according to the following procedure shown in fig. 6.
According to the first aspect, or any implementation manner of the first aspect, after the electronic device adjusts the binding core strength value of the GC daemon thread, the method further includes: the electronic equipment detects the legitimacy of the binding core intensity value of the regulated GC daemon thread; the validity refers to whether the binding core strength value belongs to one of preset values, if the binding core strength value belongs to one of the preset values, the binding core strength value is legal, otherwise, the binding core strength value is illegal; when the adjusted binding core strength value of the GC daemon thread is illegal, the electronic equipment increases or decreases the binding core strength value of the GC daemon thread, so that the binding core strength value of the GC daemon thread after being adjusted again is legal. Therefore, when the regulated binding core strength value of the GC daemon thread is illegal, the GC regulation module regulates the binding core strength value of the GC daemon thread again to be legal, so that the problem of failure in regulation of the running core of the GC daemon thread caused by illegal binding core strength value can be avoided.
According to the first aspect, or any implementation manner of the first aspect, the determining, by the electronic device, the GC frequent running condition in combination with the relevant data of the GC running at this time includes: the electronic equipment calculates GC operation interval duration in the current GC operation according to the operation start time of the current GC operation and the operation end time of the previous GC operation; the electronic equipment judges the frequent condition of GC operation according to the GC operation interval time in the current GC operation; or the electronic equipment judges the frequent condition of GC running according to the GC running interval duration when the GC is run for a plurality of times continuously; wherein the continuous multiple GC operations include the current GC operation.
According to the first aspect, or any implementation manner of the first aspect, the determining, by the electronic device, GC frequent running conditions according to GC running interval durations during multiple consecutive GC runs includes: in the continuous multiple GC operations, if the GC number of which the GC operation interval duration is lower than the preset interval threshold exceeds the preset number threshold, the electronic device judges that the GC operations are frequent. Therefore, the electronic equipment judges whether the GC is operated frequently or not according to the operation conditions of the GC for a plurality of times, and accuracy of judging whether the GC is operated frequently or not is improved.
According to a first aspect, or any implementation manner of the first aspect, an electronic device includes: the GC running module and the GC monitoring module; when the GC daemon finishes the GC operation each time, the electronic equipment acquires the related data of the GC operation, which comprises the following steps: the GC running module sends GC start time to the GC monitoring module; the GC running module runs a GC daemon thread; and the GC operation module sends GC ending time to the GC monitoring module when the GC daemon thread is operated.
According to the first aspect, or any implementation manner of the first aspect, the electronic device further includes: a GC regulatory module; the electronic device obtaining a device temperature value, comprising: the GC operation module reads the equipment temperature value and sends the equipment temperature value to the GC regulation and control module when the GC daemon thread is operated; or when the GC running module runs the GC daemon thread, the GC regulating and controlling module reads the temperature value of the equipment.
According to the first aspect, or any implementation manner of the first aspect, the electronic device obtains an interrupt program duration during the running of the GC, including: when the GC operation module operates the GC daemon thread, the GC operation module sends the interrupt program duration of the GC operation to the GC regulation module, so that the GC regulation module adjusts the operation core of the GC daemon thread according to the equipment temperature value and the interrupt program duration.
According to the first aspect, or any implementation manner of the first aspect, the electronic device determines a GC operation frequent condition in combination with data related to the GC operation, and adjusts an operation core of the GC daemon according to the device temperature value and the GC operation frequent condition, including: the GC monitoring module is used for judging the frequent GC operation condition by combining the related data of the current GC operation and sending the frequent GC operation condition to the GC control module; the GC regulation and control module adjusts the operation core of the GC daemon thread according to the equipment temperature value and the frequent GC operation condition.
According to the first aspect, or any implementation manner of the first aspect, the electronic device further includes: an ART virtual machine; before the electronic device acquires the relevant data of the GC operation at this time when the GC daemon finishes the GC operation each time, the method further comprises the following steps: the ART virtual machine starts a GC daemon thread; when the garbage memory generated by application operation reaches a preset memory threshold value, the ART virtual machine sends trigger information to the GC operation module; the trigger information is used for indicating the GC running module to run the GC daemon thread to perform GC operation.
According to the first aspect, or any implementation manner of the first aspect, after the ART virtual machine starts the GC daemon thread, the method further includes: the ART virtual machine sends the thread ID of the GC daemon thread to the GC regulation module; the electronic device adjusts the operation core of the GC daemon thread according to the device temperature value and the frequent GC operation condition, and comprises the following steps: the GC regulation and control module adjusts the operation core of the GC daemon thread according to the thread ID of the GC daemon thread, the equipment temperature value and the GC operation frequent condition.
For example, the present implementation may refer to the following step flow in the module interaction schematic shown in fig. 5.
According to the first aspect, or any implementation manner of the first aspect, the electronic device adjusts an operation core of the GC daemon thread according to the device temperature value and the GC operation frequency, including: the GC regulation and control module adjusts the binding core strength value of the GC daemon thread according to the equipment temperature value and the GC operation frequent condition; the GC regulation module sends the regulated binding core strength value to the GC operation module; the GC operation module adjusts the operation core of the GC daemon thread according to the thread ID of the GC daemon thread and the binding core strategy corresponding to the adjusted binding core strength value.
For example, the present implementation may refer to the following step flow in the module interaction schematic shown in fig. 7.
In a second aspect, an embodiment of the present application provides an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored on the memory, which when executed by the one or more processors, cause the electronic device to perform the virtual machine garbage collection operation method of any of the first aspect and the first aspect.
Any implementation manner of the second aspect and the second aspect corresponds to any implementation manner of the first aspect and the first aspect, respectively. The technical effects corresponding to the second aspect and any implementation manner of the second aspect may be referred to the technical effects corresponding to the first aspect and any implementation manner of the first aspect, which are not described herein.
In a third aspect, embodiments of the present application provide a computer-readable storage medium. The computer readable storage medium comprises a computer program which, when run on an electronic device, causes the electronic device to perform the virtual machine garbage collection operation method of any one of the first aspect and the first aspect.
Any implementation manner of the third aspect and any implementation manner of the third aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation manner of the third aspect may be referred to the technical effects corresponding to the first aspect and any implementation manner of the first aspect, which are not described herein.
In a fourth aspect, embodiments of the present application provide a computer program product comprising a computer program/instruction which, when executed by a processor, implements the virtual machine garbage collection operation method of any one of the first aspect and the first aspect.
Any implementation manner of the fourth aspect and any implementation manner of the fourth aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. Technical effects corresponding to any implementation manner of the fourth aspect may be referred to the technical effects corresponding to any implementation manner of the first aspect, and are not described herein.
Drawings
Fig. 1 is a schematic view of an exemplary application scenario;
FIG. 2 is a schematic diagram of an exemplary CPU operating scenario;
Fig. 3 is a schematic diagram of a hardware structure of an exemplary electronic device;
FIG. 4 is a schematic diagram of a software architecture of an exemplary electronic device;
fig. 5 is a schematic diagram of module interaction of an electronic device according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a core binding process of a GC daemon according to an embodiment of the present application;
fig. 7 is a schematic diagram of module interaction of an electronic device according to an embodiment of the present application;
fig. 8 is a flow chart of a virtual machine garbage collection operation method according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms first and second and the like in the description and in the claims of embodiments of the application, are used for distinguishing between different objects and not necessarily for describing a particular sequential order of objects. For example, the first target object and the second target object, etc., are used to distinguish between different target objects, and are not used to describe a particular order of target objects.
In embodiments of the application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "e.g." in an embodiment should not be taken as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, unless otherwise indicated, the meaning of "a plurality" means two or more. For example, the plurality of processing units refers to two or more processing units; the plurality of systems means two or more systems.
In an application scenario, referring to fig. 1, when a daemon thread (such as a HeatTaskDeamon thread) of a virtual machine frequently performs GC, a load of a CPU is increased, which further causes an increase in power consumption of an electronic device and heat generation of the whole machine. Meanwhile, when the daemon thread of the virtual machine frequently performs GC, the daemon thread of the virtual machine may run on the oversized core of the CPU, resulting in problems of increased CPU load and unreasonable allocation of CPU resources. Thus, the user experience is poor.
Referring to FIG. 2, during virtual machine operation, the HeatTaskDeamon thread begins garbage collection whenever the HeatSize reaches a threshold. If the HeatTaskDeamon thread runs GC, heapTaskDeamon frequently, it runs on a very large core (e.g., CPU7 in FIG. 2). The HeatTaskDeamon thread runs on the oversized core, so that the power consumption of the whole machine can be increased, and the HeatTaskDeamon thread preempts CPU resources of the foreground application, so that the CPU resources are unreasonably distributed, and further the phenomenon of the foreground application blocking frame loss is caused.
Fig. 3 is a schematic structural diagram of the electronic device 100. Alternatively, the electronic device 100 may be a terminal, which may also be referred to as a terminal device, and the terminal may be a cellular phone (cellular phone) or a tablet computer (pad), which is not limited by the present application. It should be noted that the schematic structural diagram of the electronic device 100 may be applicable to the electronic device performing GC in fig. 1, such as a mobile phone. It should be understood that the electronic device 100 shown in fig. 3 is only one example of an electronic device, and that the electronic device 100 may have more or fewer components than shown in the figures, may combine two or more components, or may have a different configuration of components. The various components shown in fig. 3 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
The electronic device 100 may include: processor 110, external memory interface 120, internal memory 121, universal serial bus (universal serial bus, USB) interface 130, charge management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headset interface 170D, sensor module 180, keys 190, motor 191, indicator 192, camera 193, display 194, and subscriber identity module (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor, a gyroscope sensor, a barometric sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller may be a neural hub and a command center of the electronic device 100, among others. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The USB interface 130 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 130 may be used to connect a charger to charge the electronic device 100, and may also be used to transfer data between the electronic device 100 and a peripheral device. And can also be used for connecting with a headset, and playing audio through the headset. The interface may also be used to connect other electronic devices, such as AR devices, etc.
The charge management module 140 is configured to receive a charge input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charge management module 140 may receive a charging input of a wired charger through the USB interface 130. In some wireless charging embodiments, the charge management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. The charging management module 140 may also supply power to the electronic device through the power management module 141 while charging the battery 142.
The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like.
The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like. The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc., applied to the electronic device 100. The wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., as applied to the electronic device 100.
In some embodiments, antenna 1 and mobile communication module 150 of electronic device 100 are coupled, and antenna 2 and wireless communication module 160 are coupled, such that electronic device 100 may communicate with a network and other devices through wireless communication techniques.
The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information. The display screen 194 is used to display images, videos, and the like. The display 194 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
The electronic device 100 may implement photographing functions through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like. The camera 193 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image onto the photosensitive element. The photosensitive element converts the optical signal into an electrical signal, which is then transferred to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, or the like format. In some embodiments, electronic device 100 may include 1 or N cameras 193, N being a positive integer greater than 1.
The digital signal processor is used for processing digital signals, and can process other digital signals besides digital image signals. For example, when the electronic device 100 selects a frequency bin, the digital signal processor is used to fourier transform the frequency bin energy, or the like.
Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record video in a variety of encoding formats, such as: dynamic picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
The internal memory 121 may be used to store computer executable program code including instructions. The processor 110 executes the instructions stored in the internal memory 121, thereby executing various functional applications and data processing of the electronic device 100, so that the electronic device 100 implements the virtual machine garbage collection operation method in the implementation of the present application. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device 100 (e.g., audio data, phonebook, etc.), and so on. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like.
The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playing, recording, etc. The audio module 170 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. The audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be disposed in the processor 110, or a portion of the functional modules of the audio module 170 may be disposed in the processor 110.
The pressure sensor is used for sensing a pressure signal and can convert the pressure signal into an electric signal. In some embodiments, the pressure sensor may be provided on the display screen 194. Pressure sensors are of many kinds, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The electronic device 100 may also calculate the location of the touch based on the detection signal of the pressure sensor. In some embodiments, touch operations that act on the same touch location, but at different touch operation strengths, may correspond to different operation instructions. For example: and executing an instruction for checking the short message when the touch operation with the touch operation intensity smaller than the first pressure threshold acts on the short message application icon. And executing an instruction for newly creating the short message when the touch operation with the touch operation intensity being greater than or equal to the first pressure threshold acts on the short message application icon.
Touch sensors, also known as "touch panels". The touch sensor may be disposed on the display screen 194, and the touch sensor and the display screen 194 form a touch screen, which is also referred to as a "touch screen". The touch sensor is used to detect a touch operation acting on or near it. The touch sensor may communicate the detected touch operation to the application processor to determine the touch event type. Visual output related to touch operations may be provided through the display 194. In other embodiments, the touch sensor may also be disposed on a surface of the electronic device 100 at a different location than the display 194.
The keys 190 include a power-on key (or power key), a volume key, etc. The electronic device 100 may receive key inputs, generating key signal inputs related to user settings and function controls of the electronic device 100.
The motor 191 may generate a vibration cue. The motor 191 may be used for incoming call vibration alerting as well as for touch vibration feedback. For example, touch operations acting on different applications (e.g., photographing, audio playing, etc.) may correspond to different vibration feedback effects.
The indicator 192 may be an indicator light, may be used to indicate a state of charge, a change in charge, a message indicating a missed call, a notification, etc.
The software system of the electronic device 100 may employ a layered architecture, an event driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In the embodiment of the application, taking an Android system with a layered architecture as an example, a software structure of the electronic device 100 is illustrated.
Fig. 4 is a software configuration block diagram of the electronic device 100 according to the embodiment of the present application.
The layered architecture of the electronic device 100 divides the software into several layers, each with a distinct role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers, from top to bottom, an application layer, an application framework layer, an Zhuoyun row (Android run) and system libraries, and a kernel layer, respectively.
The application layer may include a series of application packages.
As shown in FIG. 4, the application package may include pre-installed applications of the system, such as cameras, calendars, etc., as well as applications developed by third parties, such as video, etc.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions.
As shown in FIG. 4, the application framework layer may include a window manager, a view system, a temperature service, and the like.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a text message notification icon may include a view displaying text and a view displaying a picture.
And the temperature service is used for monitoring the temperature information of the electronic equipment in real time.
The system library and Runtime layer includes a system library and Android Runtime (Android run time). Android run time includes a core library, a virtual machine manager, and a virtual machine. Android run time is responsible for scheduling and management of the Android system.
The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The virtual machine manager is used for realizing the creation and management of the virtual machine.
The application layer and the application framework layer run in a virtual machine, such as an ART virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
As shown in fig. 4, the garbage collection function module in the ART virtual machine may include an operation module, a monitoring module, and a regulation module. The GC operation module is used for operating the GC, the monitoring module is used for monitoring whether the GC is operated frequently, and the regulation and control module is used for adjusting the operating core of the GC according to the GC operation condition.
The system library may include a plurality of functional modules. For example: surface manager (surface manager), media library (Media Libraries), etc.
The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc.
The kernel layer is a layer between hardware and software. The inner core layer at least comprises a display driver, a camera driver, an audio driver and a sensor driver.
It will be appreciated that the layers and components contained in the layers in the software structure shown in fig. 4 do not constitute a specific limitation on the electronic device 100. In other embodiments of the application, electronic device 100 may include more or fewer layers than shown and may include more or fewer components per layer, as the application is not limited.
It can be understood that, in order to implement the virtual machine garbage collection operation method in the present application, the electronic device includes corresponding hardware and/or software modules that perform each function. The present application can be implemented in hardware or a combination of hardware and computer software, in conjunction with the example algorithm steps described in connection with the embodiments disclosed herein. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application in conjunction with the embodiments, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application provides a virtual machine garbage collection operation method. Specifically, for each application, the electronic device counts the relevant data of its GC operation. The electronic device dynamically adjusts the operating core of the GC daemon according to the GC operating frequency and the device temperature value. Furthermore, when a GC phenomenon frequently occurs in a certain application program, the electronic device can adjust the operation core of the GC daemon thread corresponding to the application program, so as to reduce the operation power consumption of the GC daemon thread, reduce the heating phenomenon of the electronic device, and avoid the problem of unbalanced CPU resource allocation.
Taking a video application as an example, according to the condition that the video application generates GC, the running core of the GC daemon thread corresponding to the video application is adjusted. Furthermore, when the GC phenomenon frequently occurs in the video application, the running core of the GC daemon corresponding to the video application is adjusted, for example, the running core of the GC daemon is bound, so that the running power consumption of the corresponding GC daemon is reduced, and the heating phenomenon of the electronic equipment is reduced. When the GC phenomenon of the video application is not frequent, the operation cores of the GC daemon thread corresponding to the video application may not be bound, so as to improve the operation efficiency of the corresponding GC daemon thread.
It should be noted that when binding the running cores of the GC daemon, the GC daemon can only run on the bound CPU core. For example, if the running core of the GC daemon is bound to the CPU corelet, the GC daemon can only run on the CPU corelet. When the running cores of the GC daemon are not bound, the GC daemon can run on any CPU core, and can be a small CPU core or a large CPU core.
Fig. 5 is a schematic diagram showing interaction between the modules of the electronic device. Referring to fig. 5, the process of the virtual machine garbage collection operation method provided by the present application specifically includes:
S501, the virtual machine manager creates an ART virtual machine in response to the user clicking on the video application icon.
When a user clicks a video application icon on a page of the electronic device to open the video application, the virtual manager creates an ART virtual machine corresponding to the video application in Android run time.
It should be noted that, for each application, when the user clicks on an icon of the application to open the application, the virtual manager creates an ART virtual machine corresponding to the application. The virtual machine manager may be used to implement management of a plurality of ART virtual machines.
S502, starting an ART virtual machine program and starting a GC daemon thread.
After the ART virtual machine corresponding to the video application is created, a program corresponding to the ART virtual machine is started. Thereupon, the ART virtual machine starts a GC daemon thread, such as a HeatTaskDeamon thread.
The HeatTaskDeamon thread may also be referred to as a daemon thread of the virtual machine. During the running of the ART virtual machine, if the garbage memory generated by the video application reaches a preset memory threshold, the HeatTaskDeamon thread starts garbage collection operation, that is, the ART virtual machine generates GC.
S503, the ART virtual machine sends an ART virtual machine starting completion identification to the virtual machine manager.
And the ART virtual machine starting completion identification is used for indicating that the ART virtual machine is started to be completed. Illustratively, the ART virtual machine start-up completion identifier may include, but is not limited to, an ART virtual machine identity identifier and a start-up completion identifier. Wherein, the ART virtual machine identity can be used for distinguishing different ART virtual machines. Alternatively, the ART virtual machine identity may be an ART virtual machine number.
The ART virtual machine sends an ART virtual machine starting completion identification to the virtual machine manager so as to inform the virtual machine manager that the ART virtual machine is started completely, and the virtual machine manager can execute management operation on the ART virtual machine.
S504, the virtual machine manager sends an ART virtual machine body identifier to the video application.
After receiving the ART virtual machine starting completion identification, the virtual machine manager obtains an ART virtual machine body identification carried in the ART virtual machine starting completion identification. Further, the virtual machine manager may send the ART virtual machine body identifier to the corresponding application program according to the correspondence between the ART virtual machine and the application program, so that the application program may run on the corresponding ART virtual machine. In this embodiment, the virtual machine manager sends the ART virtual machine identity to the video application, so that the video application can run on the corresponding ART virtual machine.
S505, the video application runs on an ART virtual machine corresponding to the received ART virtual machine body identifier.
After the virtual machine manager provides the ART virtual machine identity to the video application, the video application determines a corresponding ART virtual machine according to the ART virtual machine identity and operates on the ART virtual machine. That is, the video application may process the service of the present application according to the identity of the ART virtual machine.
S506, the ART virtual machine sends the thread ID of the GC daemon thread to the GC regulatory module.
After the ART virtual machine starts the GC daemon thread, the thread ID of the GC daemon thread is sent to the GC regulatory module, so that the GC regulatory module can adjust the running core of the GC daemon thread according to the thread ID.
It should be noted that the GC regulation module, and the GC operation module and the GC monitoring module mentioned below can be understood as sub-modules of the garbage collection function module in the ART virtual machine. Accordingly, the operations performed by the GC operation module, the GC monitoring module, and the GC regulation module may be understood as operations performed by the garbage collection function module in the ART virtual machine.
S507, the ART virtual machine monitors the garbage memory generated by the video application operation.
During the running of the application, a garbage memory is inevitably generated. The ART virtual machine monitors the garbage memory generated by the application program running on the ART virtual machine, namely monitors the garbage memory generated by the running of the video application. Illustratively, the ART virtual machine monitors the garbage memory generated by the video application running while performing memory allocation. Further exemplary, the ART virtual machine monitors the spam memory generated by the video application running when the function system.
S508, the ART virtual machine determines that the garbage memory generated by the video application operation reaches a preset memory threshold.
After the ART virtual machine monitors the garbage memory generated by the video application operation, the monitored garbage memory is compared with a preset memory threshold value, and whether the garbage memory generated by the video application operation reaches the preset memory threshold value or not is judged.
S509, the ART virtual machine sends trigger information to the GC running module.
When the garbage memory generated by the video application operation reaches a memory threshold, the ART virtual machine sends trigger information to the GC operation module. The trigger information is used for indicating the GC running module to run the GC daemon thread to perform GC operation.
The ART virtual machine may trigger GC in the case of memory allocation, call function system. During the running process of the application program, the ART virtual machine constantly allocates memory for the process of the application program. When the allocated memory is no longer used, the memory becomes recyclable garbage. Once the number of the garbage memories is monitored to reach a preset memory threshold, the ART virtual machine triggers the GC.
Taking an application program as a video application as an example, in the running process of the video application, when a user frequently switches videos played by the video application or clicks an advertisement popup window popped by the video application, the video application can generate a large amount of junk memory. When the ART virtual machine monitors that the garbage memory generated by the operation of the video application reaches a preset memory threshold, the ART virtual machine triggers the GC. For example, when the ART virtual machine triggers the GC, a GC instruction is sent to the GC running module, so that the GC running module runs the GC daemon thread to implement the GC.
S510, the GC running module sends the GC start time to the GC monitoring module.
When the GC operation module receives trigger information, namely when the ART virtual machine triggers the GC, the GC operation module records the GC starting time of the GC operation and sends the GC starting time to the GC monitoring module.
S511, the GC running module runs the GC daemon thread and determines an interrupt duration when the GC daemon thread runs.
The GC running module runs the GC daemon thread to implement GC operations. When the GC daemon thread runs to perform GC operation, other threads in the electronic device except the GC daemon thread need to be interrupted to avoid that the GC operation affects the running of other threads. Therefore, the GC operation module counts the interrupt duration of the GC operation in the operation process of the GC daemon thread.
An interrupt program duration indicating a duration from a time point when the GC daemon thread transmits an interrupt request to the other threads except the GC daemon thread to a time point when the GC daemon thread transmits an end interrupt request to the other threads. The GC daemon thread sends interrupt requests to all other threads except the GC daemon thread, and the GC daemon thread is used for indicating the other threads to process thread interrupt; the GC daemon thread sends an end interrupt request to all other threads except the GC daemon thread for indicating the other threads to stop interrupt and resume normal operation.
Before the GC daemon runs to perform GC operations, the GC daemon will send interrupt requests to all other threads except it to instruct those threads to perform thread interrupt processing. After receiving the interrupt request sent by the GC daemon, the threads perform thread interrupt processing and send interrupt response to the GC daemon. And after the GC daemon thread receives interrupt responses fed back by all threads, starting GC operation, and sending an ending interrupt request to the threads when the GC operation is completed so as to indicate that the threads can resume normal operation.
When the GC daemon runs, the GC running module records the time when the GC daemon sends interrupt requests to other threads except the GC daemon and the time when the GC daemon sends interrupt ending requests to other threads, and the interrupt program duration can be calculated according to the two times. The longer the interrupt program duration, the greater the influence of the running of the GC daemon on the normal running of other threads.
S512, when the GC daemon thread completes the GC operation, the GC operation module sends the GC ending time to the GC monitoring module.
When the GC operation module finishes the GC operation, the GC ending time of the GC is recorded, and the GC ending time is sent to the GC monitoring module.
S513, the GC operation module sends the interrupt program duration to the GC regulatory module.
When the GC operation module completes the GC operation, the interrupt program time length in the GC operation can be counted, and the interrupt program time length is sent to the GC regulation module, so that the GC regulation module can determine the regulation strategy of the GC daemon thread operation core by combining the interrupt program time length. Optionally, the GC operating module may further send the interrupt program time length to the GC monitoring module, and transmit the interrupt program time length to the GC regulatory module through the GC monitoring module.
Optionally, the unified entry for the GC execution module to execute the GC is the function CollectGarageInternal (), in which all types of GC are executed. In this embodiment, the relevant data of GC operation may be pre-recorded in the function collelectgamageinternational () of the GC operation module, such as GC start time, GC end time, and interrupt program duration of each GC operation of the plug-in record.
S514, the GC monitoring module counts the running interval duration of the current GC according to the GC start time of the current GC and the GC end time of the previous GC, and judges whether the GC is frequently run or not.
After the GC monitoring module receives the GC start time and the GC end time sent by the GC running module every time the GC occurs, the GC start time and the GC end time are respectively stored. For example, the GC monitoring module stores the GC start time and the GC end time in the GC start time array and the GC end time array, respectively, so that the GC monitoring module can count the GC operation interval duration according to the values stored in the GC start time array and the GC end time array.
GC operation interval duration refers to the interval duration of two adjacent GC operations. The GC operation interval duration of the current GC operation may be determined by calculating a difference between the GC start time of the current GC operation and the GC end time of the previous GC operation.
The GC monitoring module may count GC operation interval durations of every two adjacent GC operations in the continuous multiple GC operations according to the received GC start time and GC end time of each GC operation.
As another optional implementation manner, the GC operation module may count GC operation interval durations of every two adjacent GC operations, and send the GC operation interval durations obtained by each statistics to the GC monitoring module. In this embodiment, the GC operation module may also store the GC start time and the GC end time of each occurrence of GC in the GC start time array and the GC end time array, respectively, so that the GC operation module may respectively count GC operation interval durations during each GC operation according to the values stored in the GC start time array and the GC end time array, and send the GC operation interval durations obtained by the statistics to the GC monitoring module. At this time, the GC monitoring module may store the GC interval duration received each time into the corresponding GC interval duration array.
The GC operation interval duration can be used for representing the frequent condition of the GC operation, and the shorter the GC operation interval duration is, the more frequent the GC operation is.
Optionally, the GC monitoring module may determine the GC frequent running condition according to the GC running interval duration during the current GC running. For example, when the GC operation interval duration in the current GC operation is lower than a preset interval threshold, the GC monitoring module determines that the GC operation is frequent; when the GC operation interval duration in the GC operation is not lower than a preset interval threshold, the GC monitoring module judges that the GC operation is not frequent.
Optionally, the GC monitoring module may determine the frequent GC operation according to the GC operation interval duration during the GC operation that is performed multiple times consecutively. Wherein, the continuous multiple GC operations include a current GC operation, which is the last GC operation in the continuous multiple GC operations.
As an alternative implementation manner, in the continuous multiple GC operations, if the GC number of times that the GC operation interval duration is less than the preset interval threshold exceeds the preset number of times threshold, the GC monitoring module may determine that the GC operation is frequent.
That is, if the GC monitoring module counts that, in N consecutive GC operations, the GC number of times that the GC operation interval duration with the previous GC operation is lower than the preset interval threshold exceeds M times, the GC monitoring module may determine that the current GC operation is frequent. If the GC monitoring module counts that the GC times of the interval duration between the GC monitoring module and the GC operation of the previous GC operation is less than the preset interval threshold value are not more than M times in the continuous N GC operations, the GC monitoring module can judge that the current GC operation is not frequent. Wherein N, M is a positive integer. The N value, the M value, and the preset interval threshold may be determined according to practical situations, and this embodiment is not particularly limited.
It should be noted that, in the continuous N GC operations, the last GC operation is the present GC operation. Also, in the consecutive N GC operations, M GC operations whose GC operation interval duration from the previous GC operation is less than the preset interval threshold may be discontinuous.
Illustratively, N is 8, M is 4, and the preset interval threshold is 100ms. That is, if the GC monitoring module counts that the number of GCs whose GC operation interval duration from the previous GC operation is less than 100ms exceeds 4 times in the consecutive 8 GC operations, the GC monitoring module may determine that the current GC operation is frequent. If the GC monitoring module counts that the GC number of times of GC operation interval duration lower than 100ms from the previous GC operation is not more than 4 times in 8 consecutive GC operations, the GC monitoring module may determine that the current GC operation is not frequent.
S515, the GC monitoring module sends an identification of whether the GC is running frequently to the GC regulatory module.
The identification of whether the GC is frequently operated or not, which is sent by the GC monitoring module to the GC regulation module, may indicate that the GC is frequently operated, or may indicate that the GC is not frequently operated. For example, when identified as "1", it indicates that the GC is running frequently; when identified as "0", it indicates that the GC is running infrequently.
After judging whether the current GC is frequently operated, the GC monitoring module sends an identification of whether the current GC is frequently operated to the GC adjusting and controlling module, so that the GC adjusting and controlling module can know whether the current GC is frequently operated according to the identification.
S516, the GC regulatory module reads the device temperature value from the temperature service.
The temperature service can monitor the temperature value of the electronic equipment in real time. Illustratively, a temperature sensor in the electronic device sends temperature data collected in real time to the sensor driver. The sensor driver sends the received temperature data to the temperature service, so that the temperature service can monitor the temperature value of the electronic equipment in real time.
Illustratively, the GC regulatory module may read the device temperature value in the temperature service through a get () function.
Further exemplary, the GC regulatory module sends a temperature reading request to the temperature service, and after the temperature service receives the temperature reading request, the GC regulatory module sends the current temperature value of the electronic device to the GC regulatory module, so that the GC regulatory module can determine the adjustment policy of the GC daemon thread running core in combination with the current temperature value of the electronic device. Wherein, the temperature reading request refers to a request for acquiring the current temperature value of the electronic device. And the GC regulation and control module immediately sends a temperature reading request to the temperature service after receiving the frequent identification of the GC sent by the GC monitoring module so as to acquire the current temperature value of the electronic equipment.
It should be noted that, S516 may be executed after S515 or S513, and the execution sequence of step "the GC adjustment module reads the device temperature value from the temperature service" is not limited in this embodiment, and may be adjusted according to the practical application.
As another alternative embodiment, the GC monitoring module reads the device temperature value from the temperature service after sending the frequent identification of the GC to the GC regulatory module, and sends the read device temperature value to the GC regulatory module.
As a further alternative embodiment, the GC operation module reads the device temperature value from the temperature service when the GC operation is finished, and directly sends the read device temperature value to the GC adjustment module, or forwards the read device temperature value to the GC adjustment module through the GC monitoring module.
Optionally, the GC regulatory module stores the temperature value of the electronic device each time the temperature value is received. For example, the GC regulatory module may store the temperature value received each time in a temperature array, and determine an adjustment policy for the GC daemon thread running core in combination with the temperature data stored most recently in the temperature array. For example, the GC regulatory module may update the current temperature value of the electronic device (i.e., the GC regulatory module only stores the latest received temperature value) using the temperature value each time the temperature value is received, and determine the adjustment policy of the GC daemon thread running core in combination with the updated current temperature value of the electronic device.
S517, the GC regulation and control module adjusts the running core of the GC daemon according to the equipment temperature value, the identification of whether the GC runs frequently and the interrupt program duration.
When frequent GC phenomenon occurs, GC daemon threads can be distributed to the oversized cores of the CPU, so that the load of the CPU becomes high, the whole machine heats, the foreground is blocked, and the power consumption is increased. It can be understood that the cores of the CPU of the electronic device (such as a mobile phone) can be divided into a small CPU core, a large CPU core, an oversized CPU core, and the like. The larger the core of the CPU, the higher its processing energy efficiency ratio, but its heat generation increases accordingly.
In this embodiment, the GC regulatory module adjusts the running core of the GC daemon according to the temperature value of the electronic device, the flag of whether the GC is running frequently, and the interrupt program duration, so that the GC daemon can run on an appropriate CPU core.
Optionally, when the temperature value of the electronic device is greater than a preset temperature threshold, the GC adjustment module may adjust the GC daemon to run on the running core with the lowest processing energy efficiency ratio in the electronic device. For example, the GC regulatory module may adjust the GC daemon to run on the CPU corelet.
Optionally, when the temperature value of the electronic device is less than or equal to a preset temperature threshold, if the GC is frequently operated, the GC adjustment module may adjust the GC daemon to operate on an operation core with a lower processing energy efficiency ratio, for example, adjust the GC daemon to operate on a second CPU core from operating on the first CPU core, where the processing energy efficiency ratio of the second CPU core is lower than the processing energy efficiency ratio of the first CPU core. When the temperature value of the electronic device is smaller than or equal to a preset temperature threshold, if the GC is not operated frequently, the GC adjustment module may adjust the GC daemon to operate on an operation core with a higher processing energy efficiency ratio, for example, adjust the GC daemon to operate on a third CPU core from operating on the first CPU core, where the processing energy efficiency ratio of the third CPU core is higher than the processing energy efficiency ratio of the first CPU core.
For example, when the temperature value of the electronic device is less than or equal to a preset temperature threshold, if the GC is frequently operated, the GC adjustment module may adjust the GC daemon from operating on the CPU core to operating on the CPU corelet, so as to reduce the operating power consumption of the GC daemon. When the temperature value of the electronic equipment is smaller than or equal to a preset temperature threshold value, if the GC is not operated frequently, the GC regulation and control module can adjust the GC daemon thread to run on the CPU core from the CPU core to the CPU core so as to improve the operating efficiency of the GC daemon thread.
Optionally, when the temperature value of the electronic device is smaller than or equal to a preset temperature threshold, if the time length of the interrupt program is longer than a preset time length threshold, the GC regulatory module may not bind the running core of the GC daemon thread, so as to avoid the problem that the time length of the interrupt program is too long due to the core binding operation of the GC daemon thread, and further avoid affecting other programs at the front end of the electronic device due to the core binding operation of the GC daemon thread. At this time, the GC daemon thread may run on any CPU core, which may be a CPU small core or a CPU middle core, or may be a CPU large core or a CPU oversized core.
In this way, the GC regulation and control module adjusts the running core of the GC daemon according to the temperature value of the electronic equipment, the mark of whether the GC runs frequently and the interrupt program duration, so that the GC daemon can run on a proper CPU core, the GC running power consumption can be reduced, the phenomenon that the GC daemon occupies a CPU big core or a CPU oversized core can be prevented, and the heating clamping phenomenon of the electronic equipment is further slowed down to a certain extent.
In this embodiment, the GC regulatory module may dynamically adjust the running core of the GC daemon in a stepwise manner according to the temperature value of the electronic device, the frequent identification of the GC, and the interrupt duration. Illustratively, the GC regulatory module may adjust the binding core strength value of the GC daemon thread, and adjust the running core of the GC daemon thread according to the binding core policy corresponding to the adjusted binding core strength value. Optionally, the initial value of the binding core strength value of the GC daemon thread is a default value.
Wherein, different binding core intensity values correspond to different binding core strategies. Illustratively, the binding core policy includes at least: binding the GC daemon to the CPU corelet, and not binding the running core of the GC daemon.
The GC control module adjusts the binding core strength value of the GC daemon thread, which can be that the GC control module increases the binding core strength value of the GC daemon thread to adjust the GC daemon thread to run on the second CPU core from running on the first CPU core, and decreases the binding core strength value of the GC daemon thread to adjust the GC daemon thread to run on the third CPU core from running on the first CPU core; or the GC regulation and control module can reduce the binding core strength value of the GC daemon thread so as to adjust the GC daemon thread to run on the second CPU core from running on the first CPU core, and increase the binding core strength value of the GC daemon thread so as to adjust the GC daemon thread to run on the third CPU core from running on the first CPU core; or resetting the binding core strength value of the GC daemon to adjust the running core with the lowest processing energy efficiency ratio of the GC daemon in the electronic equipment, or realizing the operation of not binding the running core of the GC daemon.
Illustratively, the greater the binding core strength value of the GC daemon, the higher the processing energy efficiency ratio of the running core of the GC daemon, and the corresponding device heating will increase. For example, when the binding core strength value is 0, the binding core policy may be to adjust the running core of the GC daemon to the CPU corelet (may also be referred to as binding the GC daemon to the CPU corelet); when the binding core strength value is 1, the binding core strategy can be to adjust the running core of the GC daemon to be a small core in the CPU; when the binding core strength value is 2, the binding core strategy can be to adjust the running core of the GC daemon to be a CPU middle core; when the binding core strength value is 3, the binding core policy is not limited to the running core of the GC daemon, namely, the binding core operation is not carried out on the GC daemon. When the binding core strength value is 3, the running core of the GC daemon thread can be determined according to the prior art, and may be a CPU big core or a CPU extra big core.
Further exemplary, the smaller the binding core strength value of the GC daemon, the higher the processing energy efficiency ratio of the running core of the GC daemon, and the corresponding device heating will increase. Here, the present embodiment will not be described in detail for the present example.
FIG. 6 is a schematic diagram of the adjustment flow of the GC daemon thread running core. Referring to fig. 6, according to the foregoing example (i.e., the greater the binding core strength value of the GC daemon, the higher the processing energy efficiency ratio of the running core of the GC daemon) the corresponding relationship between the binding core strength value and the binding core policy, the GC regulation module provided by the present application adjusts the flow of the running core of the GC daemon, and specifically includes:
S601, the GC regulation and control module obtains the binding core strength value of the GC daemon thread.
The binding core strength value in this step refers to the current binding core strength value of the GC daemon thread, that is, the binding core strength value of the GC daemon thread determined when the GC regulatory module previously regulates the running core of the GC daemon thread.
S602, the GC regulation module judges whether the current temperature value is greater than a temperature threshold, if so, S603 is executed, and if not, S604 is executed.
Wherein the current temperature of the electronic device is temperature service feedback. If the current temperature value of the electronic equipment is larger than a preset temperature threshold value (the heating phenomenon of the equipment is serious at the moment), the GC regulation and control module considers that the current load of the electronic equipment is high and the power consumption is high. By way of example, the preset temperature threshold may be 50 degrees.
In this embodiment, before the GC regulation module adjusts the GC daemon running core, it is first considered whether the heating phenomenon of the electronic device is serious. If the heating phenomenon of the electronic equipment is serious, the strategy of adjusting the running core of the GC daemon thread by the GC regulation module is in compliance with the reduction of the power consumption of the electronic equipment no matter how much the current binding core strength value of the GC daemon thread is, so that the heating phenomenon is lightened.
S603, the GC regulatory module sets the binding core strength value of the GC daemon thread to 0.
When the GC regulation and control module judges that the current temperature value of the electronic equipment is larger than the preset temperature threshold, the GC regulation and control module can directly update the binding core strength value of the GC daemon thread, and the binding core strength value is set to be 0. Therefore, the GC regulation and control module can bind the GC daemon thread on the CPU corelet, so that the power consumption of the electronic equipment is reduced, and the GC daemon thread is prevented from occupying CPU resources.
S604, the GC regulatory module judges whether the frequent identifier indicates that the GC is frequent, if so, the step S605 is executed, and if not, the step S606 is executed.
When the GC regulation and control module judges that the current temperature value of the electronic equipment is smaller than or equal to a preset temperature threshold value, the GC regulation and control module considers that the current load of the electronic equipment is not high and the power consumption is not high. At this time, the GC regulation module may determine whether the current GC operation is frequent according to the received GC frequent identifier, and determine an adjustment policy of the binding core strength value of the GC daemon thread according to the result of whether the current GC operation is frequent. If the GC is operated frequently at present, the GC regulation and control module can properly reduce the binding core strength value of the GC daemon thread, so that the GC daemon thread is operated on a CPU core with lower processing energy efficiency, thereby reducing equipment power consumption and relieving heating phenomenon; if the GC is not operated frequently at present, the GC regulation and control module can properly increase the binding core strength value of the GC daemon thread, so that the GC daemon thread is operated on a CPU core with higher processing energy efficiency, and the GC operation efficiency is improved.
S605, the GC regulatory module subtracts 1 from the binding core strength value of the GC daemon thread, and S607 is executed.
In this embodiment, if the GC is running frequently at present, the GC regulatory module may decrease the binding core strength value of the GC daemon thread by 1 based on the current value, so that the GC daemon thread may run on the CPU core with relatively low processing energy efficiency, thereby reducing power consumption of the device.
S606, the GC regulatory module adds 1 to the binding core strength value of the GC daemon thread, and S607 is executed.
In this embodiment, if the GC is not running frequently at present, the GC adjustment module may add 1 to the binding core strength value of the GC daemon thread on the basis of the current value, so that the GC daemon thread may run on the CPU core with relatively high processing energy efficiency, thereby improving GC running efficiency.
S607, the GC control module judges whether the duration of the interrupt program is greater than a duration threshold, if so, the step S608 is executed, and if not, the step S609 is executed.
In this embodiment, when the GC regulation module adjusts the GC daemon running core, it considers whether the normal running of other programs is affected by the core binding operation on the GC daemon, in addition to the device temperature value and whether the GC running is frequent. If the time length of the interrupt program in the GC running process is larger than a preset time length threshold, the GC regulation and control module considers that the kernel binding operation of the GC daemon can influence the normal running of other programs, and the phenomenon of the blocking frame loss of a foreground application is caused; if the duration of the interrupt program in the running process of the GC is smaller than or equal to a preset duration threshold, the GC control module can consider that the kernel binding operation of the GC daemon does not influence the normal running of other programs. The preset duration threshold may be, for example, 5ms.
S608, the GC regulatory module sets the binding core strength value of the GC daemon thread to 3.
If the GC control module judges that the interrupt program time length in the current GC running process is greater than a preset time length threshold, the GC control module can set the binding core strength value of the GC daemon thread to be 3 so as to cancel the binding core operation of the GC daemon thread. Thus, the problem that other programs cannot normally run due to the core binding operation of the GC daemon thread can be avoided.
S609, the GC regulatory module judges whether the binding core strength value of the GC daemon thread is legal, if not, the step S610 is executed, and if so, the step S611 is executed.
After the GC control module adjusts the binding core strength value of the GC daemon thread, the GC control module also judges the validity of the adjusted binding core strength value, namely judges whether the adjusted binding core strength value is a preset binding core strength value. For example, if the adjusted GC daemon has a binding core strength value of-1 or 4, the binding core strength value is illegal.
S610, the GC regulatory module adaptively adjusts the binding core strength value of the GC daemon.
When the GC regulation module determines that the adjusted binding core strength value is illegal, the GC regulation module may adaptively readjust the binding core strength value of the GC daemon thread, for example, may increase or decrease the binding core strength value of the GC daemon thread, so that the binding core strength value is one of preset binding core strength values, that is, is a legal binding core strength value. Optionally, when the GC regulation module adaptively readjusts the binding core strength value of the GC daemon thread, one legal binding core strength value adjacent to the illegal binding core strength value may be used as the readjusted binding core strength value. That is, the GC regulatory module may use a legal binding core strength value having a smallest difference from an illegal binding core strength value as the readjusted binding core strength value.
For example, when the adjusted binding core strength value of the GC daemon thread is-1, the GC regulatory module may adaptively readjust the binding core strength value of the GC daemon thread to a legal binding core strength value 0 adjacent to the illegal binding core strength value-1, that is, to a legal binding core strength value 0 having the smallest difference from the illegal binding core strength value-1.
For another example, when the adjusted binding core strength value of the GC daemon thread is 4, the GC regulatory module may adaptively readjust the binding core strength value of the GC daemon thread to a legal binding core strength value 3 adjacent to the illegal binding core strength value 4, that is, to a legal binding core strength value 3 having the smallest difference from the illegal binding core strength value 4.
Therefore, when the regulated binding core strength value of the GC daemon thread is illegal, the GC regulation module regulates the binding core strength value of the GC daemon thread again to be legal, so that the problem of failure in regulation of the running core of the GC daemon thread caused by illegal binding core strength value can be avoided.
S611, the GC regulation module adjusts the running core of the GC daemon according to the binding core strength value of the GC daemon.
After the GC regulation and control module adjusts the binding core intensity value of the GC daemon, the operation of binding or unbinding the core is executed according to the current binding core intensity value of the GC daemon. When the binding core strength value of the GC daemon thread is 3, the GC regulation and control module cancels the binding core operation of the GC daemon thread, namely, the binding of the running core of the GC daemon thread is not carried out; when the binding core strength value of the GC daemon thread is not 3, the GC regulation and control module binds the running core of the GC daemon thread according to the binding core strategy corresponding to the binding core strength value.
The GC regulation module can adjust the running core of the GC daemon thread according to the thread ID of the GC daemon thread and the binding core parameters corresponding to the binding core strategy. Illustratively, the binding core parameters may include, but are not limited to, CPU binding core code. Also exemplary, the binding core parameters may include, but are not limited to, the number of binding cores and the CPU binding core code. The CPU cores are different in size, and the corresponding number of the binding cores and the corresponding CPU binding core codes are different. The parameter types related to the binding core parameters can be determined according to the corresponding binding core functions, the number of binding cores and the CPU binding core codes can be specifically set according to the actual hardware condition of the electronic device, and the embodiment is not specifically limited to this. For example, the CPU bound core code corresponding to the CPU corelet is 1111 0000, the CPU bound core code corresponding to the CPU corelet is 1111 1110, and the CPU bound core code corresponding to the CPU corelet is 0000 1110.
Optionally, the GC regulatory module may implement binding of the GC daemon running core by adjusting CPU affinity of the GC daemon. Wherein the CPU affinity is capable of binding one or more processes to one or more processors for execution. The CPU affinity mask (or CPU binding kernel code) of a process determines on which CPU core or cores the process will run.
For example, the GC regulatory module may use a function sched_security (thread ID, number of bound cores, CPU bound core code) as a bound core function to implement adjustment of CPU affinity of the GC daemon thread, that is, implement binding of the GC daemon thread running core. For example, if the kernel binding policy is to adjust the running kernel of the GC daemon to be a CPU corelet, in the parameter of the function sched_security, the thread ID may be set to the thread ID of the GC daemon, the number of kernels may be set to the number of CPU corelets in the electronic device, and the CPU kernel binding code may be set to the CPU kernel binding code corresponding to the CPU corelet. The GC regulation and control module runs the function sched_security, so that the running core of the GC daemon thread can be adjusted to be a CPU small core.
It should be noted that the adjustment of the GC daemon thread running core is completed before the next GC occurrence. Further, the GC daemon thread runs on the modified CPU core when the next GC occurs.
When the garbage memory generated by the video application running reaches the memory threshold again, the ART virtual machine triggers the GC running again, and at this moment, S509-S517 can be executed again, so as to realize the dynamic adjustment of the GC daemon thread running core. Therefore, the running cores of the GC daemon thread can be dynamically and stepwise adjusted according to the information counted by monitoring, and the GC daemon thread can run on the CPU corelet due to frequent GC or overhigh equipment temperature. Moreover, as the device temperature decreases, the device load decreases, and the GC daemon thread is no longer limited by the binding core, thereby improving GC efficiency.
In order to verify the effectiveness of the virtual machine garbage collection operation method, the virtual machine garbage collection operation method shown in fig. 5 and 6 can be applied to a mobile phone, and power consumption changes before and after the mobile phone applies the virtual machine garbage collection operation method are analyzed. In the verification, the present invention selects the present headpiece, UC browser, microblog, panning, spelling, etc. as the application program of the test to run in the mobile phone, and analyzes the power consumption change condition of the mobile phone before and after the virtual machine garbage collection running method is applied, and the analysis result is shown in the table 1. Wherein, at the time of verification, each application program runs for 3 minutes before the virtual machine garbage collection operation method is applied by the mobile phone or after the virtual machine garbage collection operation method is applied by the mobile phone, and the user operates (e.g. slides) every 10s during each application program running. In order to improve the accuracy of the verification result, the test process is repeated twice, and the power consumption change of the mobile phone before and after the virtual machine garbage collection operation method is applied is analyzed according to the average value of the two test results.
TABLE 1
As shown in table 1, the power consumption of each application program is reduced after the virtual machine garbage collection operation method is applied by the mobile phone compared with the power consumption of each application program before the virtual machine garbage collection operation method is applied by the mobile phone. Especially, when the two application programs of the today's top bar and the UC browser are operated, the power consumption of the mobile phone after the virtual machine garbage collection operation method is applied is obviously reduced. The more frequent the GC occurs when the application is running, the more significant the power consumption reduction after the handset applies the virtual machine garbage collection running method.
Another interaction diagram of the modules of the electronic device is shown in fig. 7. Referring to fig. 7, the process of the virtual machine garbage collection operation method provided by the present application specifically includes:
s701, the virtual machine manager creates an ART virtual machine in response to the user clicking the video application icon.
S702, starting an ART virtual machine program and starting a GC daemon thread.
S703, the ART virtual machine sends an ART virtual machine starting completion identification to the virtual machine manager.
S704, the virtual machine manager sends an ART virtual machine body identifier to the video application.
S705, the video application runs on the ART virtual machine corresponding to the received ART virtual machine body identifier.
S706, the ART virtual machine monitors the garbage memory generated by the video application operation.
S707, the ART virtual machine determines that the garbage memory generated by the video application operation reaches a memory threshold.
S708, the ART virtual machine sends trigger information to the GC running module.
S709, the GC operation module transmits the GC start time to the GC monitoring module.
S710, the GC running module runs the GC daemon thread and determines an interrupt program duration when the GC daemon thread runs.
S711, when the GC daemon thread completes the GC operation, the GC operation module sends the GC ending time to the GC monitoring module.
S712, the GC operation module sends the interrupt program duration to the GC regulatory module.
S713, the GC monitoring module counts the running interval duration of the current GC according to the GC start time of the current GC and the GC end time of the previous GC, and judges whether the GC is frequently run.
S714, the GC monitoring module sends an identification of whether the GC is running frequently to the GC regulatory module.
S715, the GC regulatory module reads the device temperature value from the temperature service.
S716, the GC regulation and control module adjusts the binding core strength value of the GC daemon according to the equipment temperature value, the identification of whether the GC is operated frequently and the interrupt program duration.
S717, the GC regulatory module sends the binding core strength value of the GC daemon thread to the GC running module.
S718, the GC operation module adjusts the operation core of the GC daemon according to the binding core strength value of the GC daemon.
The flow shown in fig. 7 differs from the flow shown in fig. 6 in that the main body of the step of executing the "adjust operation core of GC daemon" is different.
In the flow shown in fig. 7, the GC regulation module adjusts the binding strength value of the GC daemon thread according to the temperature value of the electronic device, the flag of whether the GC is frequently operated, and the interrupt program duration, and sends the adjusted binding strength value of the GC daemon thread to the GC operation module. Furthermore, the GC operation module can adjust the operation core of the GC daemon according to the binding core strength value of the GC daemon. Thus, the GC operation module executes the operation of adjusting the operation core of the GC daemon in the current flow, and the GC daemon is operated by the GC operation module, so that the GC operation module does not need to send the thread ID of the GC daemon to the GC regulation module.
For steps not explained in detail in the flow shown in fig. 7, reference may be made to the explanation of the steps in the flow shown in fig. 6, and the details are not repeated here. The flow shown in fig. 7 is identical to the flow shown in fig. 6 in terms of technical effect, and will not be described in detail.
Fig. 8 is a schematic flow chart of a virtual machine garbage collection operation method according to an embodiment of the present application, and referring to fig. 8, the method specifically includes:
s801, when the garbage collection GC daemon thread finishes GC operation each time, the electronic equipment acquires relevant data of the current GC operation and the equipment temperature value.
Illustratively, the relevant data for GC operation includes: GC run start time and GC end time.
S802, the electronic equipment combines the related data of the GC running at this time to judge the frequent GC running condition.
The electronic device calculates the GC operation interval duration of the current GC operation according to the operation start time of the current GC operation and the operation end time of the previous GC operation.
Optionally, the electronic device judges the frequent GC operation according to the GC operation interval duration during the GC operation.
Optionally, the electronic device judges the frequent GC operation condition according to the GC operation interval duration when the GC is operated continuously for a plurality of times; wherein the continuous multiple GC runs include the current GC run.
For example, in the continuous multiple GC operations, if the GC number of which the GC operation interval duration is lower than the preset interval threshold exceeds the preset number threshold, the electronic device determines that the GC operation is frequent.
S803, the electronic device adjusts the operation core of the GC daemon thread according to the device temperature value and the GC operation frequent condition. For example, when the device temperature value is greater than the preset temperature threshold, the electronic device adjusts the GC daemon to run on the CPU core with the lowest processing energy efficiency ratio in the electronic device, for example, on the CPU corelet.
For example, when the device temperature value is less than or equal to a preset temperature threshold, if the GC is frequently run, the electronic device adjusts the GC daemon thread from running on the first CPU core to running on the second CPU core; wherein the processing energy efficiency ratio of the second CPU core is lower than the processing energy efficiency ratio of the first CPU core.
For example, when the device temperature value is less than or equal to a preset temperature threshold, if GC operation is not frequent, the electronic device adjusts the GC daemon thread from running on the first CPU core to running on the third CPU core; wherein the processing energy efficiency ratio of the third CPU core is higher than the processing energy efficiency ratio of the first CPU core.
On the basis of the technical scheme, the electronic equipment also acquires the interruption program duration of the GC running at this time; the method comprises the steps that a GC daemon time is used for indicating the time when the GC daemon thread sends interrupt requests to other threads except the GC daemon thread and the time when the GC daemon thread sends ending interrupt requests to the other threads; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, if the program interruption time is longer than the preset time threshold value, the electronic equipment does not bind the running cores of the GC daemon. Illustratively, if the running core of the GC daemon thread has been bound, the binding operation to the running core of the GC daemon thread is canceled; if the running core of the GC daemon is not bound, maintaining the state that the running core of the GC daemon is not bound.
Optionally, the electronic device adjusts the binding core strength value of the GC daemon thread, and adjusts the running core of the GC daemon thread according to the binding core policy corresponding to the adjusted binding core strength value; wherein, different binding core intensity values correspond to different binding core strategies; the binding core policy may include: the GC daemon thread is bound to run on the CPU corelet, and the running core of the GC daemon thread is not bound.
Illustratively, the electronic device increases the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the second CPU core; the electronic device reduces the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the third CPU core.
Illustratively, the electronic device reduces the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the second CPU core; the electronic device increases the binding core strength value of the GC daemon thread to adjust the GC daemon thread from running on the first CPU core to running on the third CPU core.
Illustratively, the electronic device resets the binding core strength value of the GC daemon to adjust the GC daemon to run on the CPU core with the lowest processing energy efficiency ratio in the electronic device, or does not bind the running core of the GC daemon.
As an exemplary embodiment, when the binding core strength values are 0, 1, 2, and 3, respectively, the binding core policies are in turn: binding the GC daemon thread to a CPU corelet for running; binding the GC daemon thread on a small core in the CPU for running; binding the GC daemon thread on a CPU core to run; the running cores of the GC daemon thread are not bound. Referring to fig. 6: resetting the binding core strength value of the GC daemon thread to 0 when the equipment temperature value is larger than a preset temperature threshold value by the electronic equipment; when the equipment temperature value is smaller than or equal to a preset temperature threshold value, the electronic equipment reduces the binding core strength value of the GC daemon thread if the GC is operated frequently, and increases the binding core strength value of the GC daemon thread if the GC is not operated frequently; when the equipment temperature value is smaller than or equal to a preset temperature threshold, if the program interruption time is longer than a preset time threshold, resetting the binding core strength value of the GC daemon thread to 3.
Illustratively, after the electronic device adjusts the binding core strength value of the GC daemon thread, the electronic device further detects validity of the adjusted binding core strength value of the GC daemon thread; the validity refers to whether the binding core strength value belongs to one of preset values, if the binding core strength value belongs to one of the preset values, the binding core strength value is legal, and if the binding core strength value does not belong to one of the preset values, the binding core strength value is illegal. When the adjusted binding core strength value of the GC daemon thread is illegal, the electronic equipment increases or decreases the binding core strength value of the GC daemon thread, so that the binding core strength value of the GC daemon thread after being adjusted again is legal.
The present process is not explained in detail in the foregoing embodiments, and is not described in detail herein.
The present embodiment also provides a computer storage medium, in which computer instructions are stored, which when executed on an electronic device, cause the electronic device to execute the related method steps to implement the virtual machine garbage collection operation method in the foregoing embodiment.
The present embodiment also provides a computer program product, which when run on a computer, causes the computer to perform the above-mentioned related steps to implement the virtual machine garbage collection operation method in the above-mentioned embodiments.
In addition, embodiments of the present application also provide an apparatus, which may be embodied as a chip, component or module, which may include a processor and a memory coupled to each other; the memory is used for storing computer execution instructions, and when the device runs, the processor can execute the computer execution instructions stored in the memory so that the chip executes the virtual machine garbage collection running method in the method embodiments.
The electronic device (such as a mobile phone), the computer storage medium, the computer program product or the chip provided in this embodiment are used to execute the corresponding method provided above, so that the beneficial effects thereof can be referred to the beneficial effects in the corresponding method provided above, and will not be described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.

Claims (18)

1. A virtual machine garbage collection operation method, which is characterized by being applied to electronic equipment, the method comprising:
when the garbage collection GC daemon finishes GC operation each time, acquiring related data and equipment temperature values of the GC operation; the data related to the GC operation includes: start time and end time of GC operation;
taking the difference value between the starting time of the GC operation and the ending time of the previous GC operation as the interval duration of the GC operation, and judging the frequent GC operation condition of the GC daemon in combination with the interval duration;
according to the equipment temperature value and the GC operation frequent condition, adjusting the operation core of the GC daemon thread;
according to the device temperature value and the GC operation frequent condition, adjusting the running core of the GC daemon thread, including:
acquiring a current binding core strength value of the GC daemon thread, wherein the current binding core strength value is a first value;
judging whether the equipment temperature value is larger than a preset temperature threshold value or not;
when the equipment temperature value is smaller than or equal to the temperature threshold value, continuing to judge whether the GC operation is indicated to be frequent when the GC operation is frequent, if so, adjusting the processing energy efficiency ratio of the thread binding operation core corresponding to the second value from the first value to a second value, otherwise, adjusting the processing energy efficiency ratio of the thread binding operation core corresponding to the third value from the first value to a third value, wherein the processing energy efficiency ratio of the thread binding operation core corresponding to the third value is higher than the processing energy efficiency ratio of the thread binding operation core corresponding to the first value;
After the binding core strength value of the GC daemon is regulated according to the frequent GC operation condition, judging whether the interrupt program duration in the current GC operation is greater than a preset duration threshold value, if so, resetting the binding core strength value of the GC daemon to a fourth value, wherein the binding core strategy corresponding to the fourth value is not binding the running core of the GC daemon; the interrupt program duration is used for indicating the time from the time when the GC daemon thread sends interrupt requests to other threads except the GC daemon thread to the time when the GC daemon thread sends ending interrupt requests to the other threads;
and adjusting the running core of the GC daemon thread according to the binding core strength value of the GC daemon thread and the corresponding relation between the binding core strength value and the binding core strategy.
2. The method of claim 1, wherein said adjusting the running core of the GC daemon according to the device temperature value and the GC operation frequency, further comprises:
and resetting the binding core strength value of the GC daemon thread to a fifth value when the equipment temperature value is larger than a preset temperature threshold, wherein the binding core strategy corresponding to the fifth value is to adjust the GC daemon thread to run on a CPU core of a central processing unit with the lowest processing energy efficiency ratio in the electronic equipment.
3. The method of claim 1, wherein said adjusting the running core of the GC daemon according to the device temperature value and the GC operation frequency, further comprises:
after the binding core strength value of the GC daemon thread is adjusted according to the frequent GC operation condition, judging whether the duration of the interrupt program in the current GC operation is greater than a preset duration threshold value, and if not, maintaining the binding core strength value of the GC daemon thread unchanged.
4. The method of claim 1, wherein the not binding the running core of the GC daemon comprises:
if the running core of the GC daemon is bound, canceling the binding operation of the running core of the GC daemon;
and if the running core of the GC daemon is not bound, maintaining the state that the running core of the GC daemon is not bound.
5. The method of any of claims 1-4, wherein adjusting the running core of the GC daemon according to the binding core strength value of the GC daemon and the correspondence of the binding core strength value to a binding core policy comprises:
different binding core strength values correspond to different binding core strategies;
The binding core strategy at least comprises the following steps: binding the GC daemon to a CPU corelet for operation, binding the GC daemon to the CPU corelet for operation, and not binding the operating core of the GC daemon.
6. The method of claim 5, wherein when the binding core strength values are 0, 1, 2, and 3, respectively, the binding core policies are in turn: binding the GC daemon thread to a CPU corelet for running; binding the GC daemon thread to a small core in a CPU for running; binding the GC daemon thread to a CPU core for running; the running cores of the GC daemon threads are not bound.
7. The method of any of claims 1-6, further comprising, after said adjusting the binding core strength value of the GC daemon thread:
detecting the validity of the regulated binding core strength value of the GC daemon thread; the validity refers to whether the binding core strength value belongs to one of preset values, if the binding core strength value belongs to one of the preset values, the binding core strength value is legal, otherwise, the binding core strength value is illegal;
And when the regulated binding core strength value of the GC daemon thread is illegal, increasing or reducing the binding core strength value of the GC daemon thread so as to ensure that the binding core strength value of the GC daemon thread after the regulation is legal.
8. The method of claim 1, wherein said determining GC operating frequency in combination with said interval duration comprises:
judging the frequent condition of GC operation according to the interval duration of the GC operation; or,
judging the frequent condition of GC operation according to the interval duration of the continuous GC operation for many times; wherein the plurality of consecutive GC operations includes the current GC operation.
9. The method according to claim 8, wherein the determining GC operation frequency according to the interval duration of the consecutive GC operations includes:
in the continuous multiple GC operations, if the GC operation number of which the interval duration is lower than the preset interval threshold exceeds the preset number threshold, it is determined that the GC operation is frequent.
10. The method according to any one of claims 1-9, wherein the electronic device comprises: the GC running module and the GC monitoring module;
the electronic device obtains relevant data of the GC operation when the GC daemon finishes the GC operation each time, and the method comprises the following steps:
The GC operation module sends the starting time of GC operation to the GC monitoring module;
the GC operation module executes GC operations based on the GC daemon thread;
and the GC operation module sends the ending time of the GC operation to the GC monitoring module when the GC operation is completed.
11. The method of claim 10, wherein the electronic device further comprises: a GC regulatory module;
the electronic device obtaining a device temperature value includes:
when the GC operation is completed, the GC operation module reads the equipment temperature value and sends the equipment temperature value to the GC regulation module; or,
and when the GC operation module completes the GC operation, the GC regulation and control module reads the equipment temperature value.
12. The method of claim 11, wherein the electronic device obtaining the duration of the interrupt routine at the current GC operation includes:
and when the GC operation is completed, the GC operation module sends the interrupt program duration of the GC operation to the GC regulation module, so that the GC regulation module adjusts the operation core of the GC daemon thread according to the equipment temperature value and the interrupt program duration.
13. The method of claim 11, wherein the electronic device uses a difference between a start time of the current GC operation and an end time of a previous GC operation as an interval duration of the current GC operation, and determines a GC operation frequent condition of the GC daemon in combination with the interval duration, and adjusts an operation core of the GC daemon according to the device temperature value and the GC operation frequent condition, including:
the GC monitoring module takes the difference value between the starting time of the current GC operation and the ending time of the previous GC operation as the interval duration of the current GC operation, judges and judges the frequent GC operation condition by combining the interval duration, and sends the frequent GC operation condition to the GC regulation module;
and the GC regulation and control module adjusts the operation core of the GC daemon according to the equipment temperature value and the GC operation frequent condition.
14. The method of claim 11, wherein the electronic device further comprises: an ART virtual machine;
before the electronic device acquires the relevant data of the GC operation when the GC daemon finishes the GC operation each time, the method further comprises the following steps:
when the garbage memory generated by application operation reaches a preset memory threshold value, the ART virtual machine sends trigger information to the GC operation module; the trigger information is used for indicating the GC operation module to perform GC operation based on the GC daemon thread.
15. The method as recited in claim 14, further comprising:
the ART virtual machine sends the thread ID of the GC daemon thread to the GC regulation module;
the electronic device adjusts the running core of the GC daemon according to the device temperature value and the GC operation frequent condition, including:
the GC regulation and control module adjusts the operation core of the GC daemon thread according to the thread ID of the GC daemon thread, the equipment temperature value and the GC operation frequent condition.
16. The method of claim 11, wherein the electronic device adjusting the running core of the GC daemon according to the device temperature value and the GC operation frequency, comprises:
the GC regulation and control module adjusts the binding core strength value of the GC daemon according to the equipment temperature value and the GC operation frequent condition;
the GC regulation module sends the regulated binding core strength value to the GC operation module;
the GC operation module adjusts the operation core of the GC daemon thread according to the thread ID of the GC daemon thread and the binding core strategy corresponding to the adjusted binding core strength value.
17. An electronic device, comprising: one or more processors; one or more memories; the one or more memories stores one or more programs that, when executed by the one or more processors, cause the electronic device to perform the virtual machine garbage collection operation method of any of claims 1-16.
18. A computer readable storage medium comprising a computer program, characterized in that the computer program, when run on an electronic device, causes the electronic device to perform the virtual machine garbage collection operation method of any of claims 1-16.
CN202111389659.7A 2021-11-19 2021-11-19 Virtual machine garbage recycling operation method and electronic equipment Active CN115016885B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111389659.7A CN115016885B (en) 2021-11-19 2021-11-19 Virtual machine garbage recycling operation method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111389659.7A CN115016885B (en) 2021-11-19 2021-11-19 Virtual machine garbage recycling operation method and electronic equipment

Publications (2)

Publication Number Publication Date
CN115016885A CN115016885A (en) 2022-09-06
CN115016885B true CN115016885B (en) 2023-11-24

Family

ID=83064773

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111389659.7A Active CN115016885B (en) 2021-11-19 2021-11-19 Virtual machine garbage recycling operation method and electronic equipment

Country Status (1)

Country Link
CN (1) CN115016885B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115543864A (en) * 2022-09-30 2022-12-30 荣耀终端有限公司 Memory garbage recycling method and electronic equipment
CN115617518A (en) * 2022-10-13 2023-01-17 维沃移动通信有限公司 Thread management method and device, electronic equipment and storage medium
CN116303110B (en) * 2022-11-22 2023-11-14 荣耀终端有限公司 Memory garbage recycling method and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004234546A (en) * 2003-01-31 2004-08-19 Sanyo Electric Co Ltd Program running method and device
WO2015051685A1 (en) * 2013-10-12 2015-04-16 华为技术有限公司 Task scheduling method, device and system
CN107332997A (en) * 2017-07-03 2017-11-07 奇酷互联网络科技(深圳)有限公司 Reduce method, device, mobile terminal and the storage medium of terminal heating
CN109947569A (en) * 2019-03-15 2019-06-28 Oppo广东移动通信有限公司 Bind method, apparatus, terminal and the storage medium of core
CN113220094A (en) * 2020-01-20 2021-08-06 Oppo广东移动通信有限公司 Scheduler optimization method, device, terminal and storage medium
CN113268438A (en) * 2021-05-19 2021-08-17 维沃移动通信有限公司 Memory recovery method and device and electronic equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2538503C (en) * 2005-03-14 2014-05-13 Attilla Danko Process scheduler employing adaptive partitioning of process threads
US11698812B2 (en) * 2019-08-29 2023-07-11 Intel Corporation System, apparatus and method for providing hardware state feedback to an operating system in a heterogeneous processor

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004234546A (en) * 2003-01-31 2004-08-19 Sanyo Electric Co Ltd Program running method and device
WO2015051685A1 (en) * 2013-10-12 2015-04-16 华为技术有限公司 Task scheduling method, device and system
CN107332997A (en) * 2017-07-03 2017-11-07 奇酷互联网络科技(深圳)有限公司 Reduce method, device, mobile terminal and the storage medium of terminal heating
CN109947569A (en) * 2019-03-15 2019-06-28 Oppo广东移动通信有限公司 Bind method, apparatus, terminal and the storage medium of core
CN113220094A (en) * 2020-01-20 2021-08-06 Oppo广东移动通信有限公司 Scheduler optimization method, device, terminal and storage medium
CN113268438A (en) * 2021-05-19 2021-08-17 维沃移动通信有限公司 Memory recovery method and device and electronic equipment

Also Published As

Publication number Publication date
CN115016885A (en) 2022-09-06

Similar Documents

Publication Publication Date Title
CN115016885B (en) Virtual machine garbage recycling operation method and electronic equipment
US11430358B2 (en) Frequency adjustment method and apparatus applied to terminal, and electronic device
US10037143B2 (en) Memory compression method of electronic device and apparatus thereof
US20130222629A1 (en) Methods, apparatuses, and computer program products for facilitating concurrent video recording and still image capture
WO2018082412A1 (en) Electronic equipment control method, device and electronic equipment
EP4199500A1 (en) Method for multiple applications to share camera, and electronic device
US10062405B2 (en) Electronic device and method for operating the same
US20140198233A1 (en) Method for compressing image data collected by camera and electronic device for supporting the method
CN110413383B (en) Event processing method, device, terminal and storage medium
CN116700601B (en) Memory optimization method, equipment and storage medium
CN111459410A (en) Memory space allocation method and device, electronic equipment and storage medium
CN114172596B (en) Channel noise detection method and related device
WO2022170866A1 (en) Data transmission method and apparatus, and storage medium
CN114630152A (en) Parameter transmission method and device for image processor and storage medium
CN110753188A (en) Terminal shooting method, terminal and readable storage medium
CN116684521B (en) Audio processing method, device and storage medium
CN117270670B (en) Power consumption control method and electronic equipment
CN112163985B (en) Image processing method, image processing device, storage medium and electronic equipment
CN116033209B (en) Screen projection method and electronic equipment
CN114630153B (en) Parameter transmission method and device for application processor and storage medium
CN117076072A (en) Container borrowing method and related device
CN117130458A (en) Data processing method, electronic device and storage medium
CN117254539A (en) Charging method and electronic equipment
CN114125738A (en) Data transmission control method and related device
CN116700982A (en) Multi-pressure management method and related device

Legal Events

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