CN107368347B - Method and device for filtering to-be-compiled code - Google Patents
Method and device for filtering to-be-compiled code Download PDFInfo
- Publication number
- CN107368347B CN107368347B CN201610317585.9A CN201610317585A CN107368347B CN 107368347 B CN107368347 B CN 107368347B CN 201610317585 A CN201610317585 A CN 201610317585A CN 107368347 B CN107368347 B CN 107368347B
- Authority
- CN
- China
- Prior art keywords
- compiled
- code
- code unit
- activity
- determining
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45516—Runtime code conversion or optimisation
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention provides a method and a device for filtering a code to be compiled, wherein the method comprises the following steps: before compiling each code unit to be compiled in the compiling queue, respectively determining an activity value of each code unit to be compiled in the compiling queue according to activity information of each code unit to be compiled in the compiling queue; and determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled, and deleting the suspected zombie code units from the compiling queue. The suspected zombie code units are not compiled, so that the proportion of the zombie code units in the virtual machine can be effectively reduced, the running expenditure of the virtual machine system is reduced, meanwhile, the compiling delay of the rest code units to be compiled is shortened, and the performance of the virtual machine system is improved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for filtering a code to be compiled.
Background
In computer applications, virtual machines are typically used. A Virtual Machine (VM) is a computer that is virtualized mainly by software or with a small amount of hardware, and the virtualized computer usually supports a set of its own instruction set, called a Virtual Machine instruction set. Virtual machines rely on a local physical machine through which execution engines simulate execution of a given sequence of virtual machine instructions or object programs on the local machine. The execution engine of the virtual machine may be implemented by an interpreter. Because the interpreter has the characteristics of high portability, low implementation cost, small memory occupation and the like, most of the execution engines of the virtual machines comprise the interpreter. The interpreter performs instruction fetching, instruction dispatching, operand fetching, and execution in units of one virtual machine instruction. But the performance of the simple interpretation execution is low, so that a dynamic compiling system is introduced into the virtual machine to improve the performance of the virtual machine. The compiler is the core of the dynamic compilation system. The compiler compiles a local CPU instruction sequence, i.e. a compiling cost method, integrally by using a group of continuous virtual machine instruction sequences as units, wherein the virtual machine instruction sequences comprise basic blocks, functions and methods, and then the compiled local method is directly executed by hardware. Since the compiler eliminates the processes of repeated instruction fetching and instruction dispatching, and simultaneously performs a large amount of effective optimization during translation, the performance of the compiler is often more than 10 times that of the interpreter. Since the compiler dynamically compiles during the program running process, it is also called Just-in-time compiler (JIT). Also, dynamic compilation is critical in determining virtual machine performance. Unlike the static compilation such as the traditional C/C + +, the dynamic compilation behavior occurs during the program running period, and additional compilation overhead is introduced. Studies have shown that the time distribution of program execution has a distinct local feature, i.e. the majority of the program execution time is concentrated on a small portion of code. In order to reduce the overhead generated by dynamic compilation as much as possible, dynamic compilation systems of modern virtual machines are usually designed and implemented according to the "selective compilation" theory.
In the prior art, code segments with high execution frequency and great influence on program performance are identified as codes to be compiled according to a selective compiling principle in the running process of a virtual machine. Specifically, the virtual machine determines a call counter and an internal loop counter for each code segment in the virtual machine, the call counter determines the number of times that the code segment is called, the internal loop counter determines the number of loop iterations in the code segment, and when the sum of the number of times determined by the call counter and the number of times determined by the internal loop counter reaches a preset threshold value, the code segment is determined as the code to be compiled. Then, adding the code to be compiled into a compiling queue for waiting for compiling; and compiling each code to be compiled in the compiling queue by the compiling thread of the virtual machine according to a certain compiling and scheduling strategy, and further generating a local code of each code to be compiled. Thereby completing the dynamic compilation of the code to be compiled in the virtual machine. After the to-be-compiled codes are dynamically compiled, the compiled to-be-compiled codes can all directly execute native codes generated after compiling.
However, in the prior art, when a to-be-compiled code to be compiled is determined, due to the changeability of program behavior, a non-to-be-compiled code is wrongly judged as the to-be-compiled code; meanwhile, after some codes to be compiled are compiled, the codes to be compiled are found not to be executed. The compiling of the codes to be compiled can increase the running overhead of the virtual machine system, so that the compiling delay of the codes to be compiled which really need to be compiled can be increased, and the performance of the virtual machine system is further reduced.
Disclosure of Invention
The invention provides a method and a device for filtering a code to be compiled, which are used for solving the problems that in the prior art, the compiling of the code to be compiled can increase the running expense of a virtual machine system, the compiling delay of the code to be compiled which really needs to be compiled is increased, and the performance of the virtual machine system is further reduced.
One aspect of the present invention provides a method for filtering a code to be compiled, including:
before compiling each code unit to be compiled in a compiling queue, respectively determining an activity value of each code unit to be compiled in the compiling queue according to activity information of each code unit to be compiled in the compiling queue;
and determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled, and deleting the suspected zombie code units from the compiling queue.
Another aspect of the present invention is to provide a filtering apparatus for a code to be compiled, including:
the determining module is used for respectively determining the activity values of the code units to be compiled in the compiling queue according to the activity information of the code units to be compiled in the compiling queue before compiling the code units to be compiled in the compiling queue;
and the deleting module is used for determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled and deleting the suspected zombie code units from the compiling queue.
The method comprises the steps of determining the activity value of each code unit to be compiled in a compiling queue before compiling each code unit to be compiled in the compiling queue, then determining a suspected zombie code unit in each code unit to be compiled according to the activity value of each code unit to be compiled, and deleting the suspected zombie code unit from the compiling queue. Because the suspected zombie code units are deleted from the compiling queue, the suspected zombie code units do not need to be compiled, and the suspected zombie code units are equivalent to the codes to be coded and filtered, so that the proportion of the zombie code units in the virtual machine can be effectively reduced, the running overhead of the virtual machine system is reduced, meanwhile, the compiling delay of the rest code units to be compiled is also shortened, and the performance of the virtual machine system is improved.
Drawings
FIG. 1 is a flowchart of a method for filtering a code to be compiled according to an embodiment of the present invention;
fig. 2 is a flowchart of a virtual machine system execution process to which a filtering method for a code to be compiled belongs according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for filtering a code to be compiled according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a filtering apparatus for a code to be compiled according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of a filtering apparatus for a code to be compiled according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart of a filtering method for a code to be compiled according to an embodiment of the present invention, as shown in fig. 1, the method of the embodiment includes:
In this embodiment, specifically, fig. 2 is a flowchart of a virtual machine system execution process to which the filtering method for a code to be compiled according to an embodiment of the present invention belongs, and as shown in fig. 2, after the virtual machine is started and initialized, a code segment in a program starts to be executed. For code fragments that are executed frequently, the virtualization is to compile dynamically. The compiled code segment is called a compiling unit, and can be a segment of the method, code in the whole method, or even a combination of code segments in a plurality of methods. After each code to be compiled is interpreted and executed, a call counter and an internal loop counter are respectively determined for each code segment, the call counter determines the number of times of the code segment being called, the internal loop counter determines the number of times of loop iteration of the code segment, and when the sum of the number of times determined by the call counter and the number of times determined by the internal loop counter reaches a preset threshold value, the code segment is determined as a code unit to be compiled.
And putting the determined code unit to be compiled into a compiling queue. Therefore, the compiling queue comprises at least one code unit to be compiled, and it can be known that the code unit to be compiled in the compiling queue can be a segment in the method, can also be a code in the whole method, and even can be a combination of code segments in a plurality of methods.
Before compiling each to-be-compiled code in the compiling queue, because each to-be-compiled code unit is executed or called in the virtual machine, respective active information of each to-be-compiled code unit can be determined, and the active information represents the execution or calling condition of the to-be-compiled code unit in the virtual machine or in the application program. Then, respectively determining the activity value of each code unit to be compiled in the compiling queue according to the activity information of each code unit to be compiled, so as to determine the activity of each code unit to be compiled in the compiling queue.
And step 102, determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled, and deleting the suspected zombie code units from the compiling queue.
In this embodiment, specifically, according to the activity value of each to-be-compiled code unit in the compiling queue determined in step 101, which inactive to-be-compiled code units in each to-be-compiled code unit in the compiling queue are marked, and which active to-be-compiled code units in each to-be-compiled code unit in the compiling queue can be determined. Therefore, the suspected zombie code units can be determined from the inactive code units to be compiled.
A zombie code unit is a compiled code unit that is not executed in some compiled code units after some code units to be compiled are compiled to obtain compiled code units (i.e., compiled code units). When a zombie code unit is a code of an entire method in an application, such a zombie code unit may be referred to as a zombie method; meanwhile, for any method in an application, a method that meets the following conditions is called a "zombie method": if and only if the method has already been compiled; and the number of times the method is compiled and executed is 0.
And then according to the activity value of each code unit to be compiled, determining a suspected zombie code unit in each code unit to be compiled, and deleting the suspected zombie code from the compiling queue.
And then, compiling and scheduling each code unit to be compiled in the compiling queue with the suspected zombie code units deleted in sequence, and then compiling the code units until no code unit to be compiled exists in the compiling queue.
Therefore, suspected zombie code units which are not executed after being compiled in the virtual machine, namely, the suspected zombie code units with low activity are deleted from the compiling queue, and the suspected zombie code units are not compiled.
The method comprises the steps of determining the activity value of each code unit to be compiled in a compiling queue before compiling each code unit to be compiled in the compiling queue, then determining a suspected zombie code unit in each code unit to be compiled according to the activity value of each code unit to be compiled, and deleting the suspected zombie code unit from the compiling queue. The suspected zombie code units are not compiled, so that the proportion of the zombie code units in the virtual machine can be effectively reduced, the running expenditure of the virtual machine system is reduced, meanwhile, the compiling delay of the rest code units to be compiled is shortened, and the performance of the virtual machine system is improved.
Fig. 3 is a flowchart of a filtering method for a code to be compiled according to a second embodiment of the present invention, where on the basis of the first embodiment, as shown in fig. 3, the method of the present embodiment, step 101, includes:
Wherein, step 1011 specifically includes:
determining the total execution times of the code units to be compiled aiming at each code unit to be compiled in a compiling queue, and determining the global active information of the code units to be compiled according to the total execution times of the code units to be compiled and a preset hot spot identification threshold value in a virtual machine, wherein the total execution times is the sum of the called times and the internal loop iteration times of the code units to be compiled in the virtual machine;
determining the interval execution times of the code unit to be compiled, and determining the local activity information of the code unit to be compiled according to the interval execution times of the code unit to be compiled, wherein the interval execution times are the execution times of the code unit to be compiled in a time period of a preset time length before the moment of determining the local activity information.
In this embodiment, specifically, after the virtual machine is started and initialized, the execution of the code segment in the program is started. For code fragments that are executed frequently, the virtualization is to compile dynamically. The compiled code segment is called a compiling unit, and can be a segment of the method, code in the whole method, or even a combination of code segments in a plurality of methods. After each code to be compiled is interpreted and executed, a call counter and an internal loop counter are respectively determined for each code segment, the call counter determines the number of times of the code segment being called, the internal loop counter determines the number of times of loop iteration of the code segment, and when the sum of the number of times determined by the call counter and the number of times determined by the internal loop counter reaches a preset threshold value, the code segment is determined as a code unit to be compiled.
Then, global active information and local active information of each code unit to be compiled in the compiling queue are obtained. Specifically, the compilation queue has a plurality of code units to be compiled. Firstly, for each unit to be compiled, calculation is started when the virtual machine is started, the sum of the called times and the internal loop iteration times of the code unit to be compiled in the virtual machine is determined between the starting time of the virtual machine and the time of starting calculation of the global active information, and then the total execution times execute (m) of the code unit to be compiled is determined. And m is a code unit to be compiled in the queue to be compiled.
Then, for each unit to be compiled, the global activity information global _ activity (m) of the unit to be compiled may be obtained by dividing the total execution time execute (m) by the preset hot spot identification threshold value HotThreshold in the virtual machine according to the total execution time execute (m) of the unit to be compiled and the preset hot spot identification threshold value HotThreshold in the virtual machine; the hot spot identification threshold HotThreshold in the preset virtual machine can be 1 ten thousand.
Then determining a preset time length delta t, wherein delta t is a time period; and the preset time length Δ t is a time period of which the time length before the time when the unit to be compiled starts to calculate the local activity information is Δ t. Similarly, for each to-be-compiled code unit, the sum of the execution times of the to-be-compiled code unit within the preset time length Δ t before the local activity information is calculated is determined, and then the execution times Δ execute (m) of the to-be-compiled code unit within the interval within the preset time difference length Δ t is counted, so that the execution times of the to-be-compiled code unit within the time period in which the time length before the time when the local activity information is determined is Δ t can be determined. The preset time duration Δ t may be 5 microseconds.
Then, for each code unit to be compiled, the number of times Δ execute (m) of the interval execution of the code unit to be compiled may be divided by the preset time duration Δ t, so as to obtain local _ activity (m) ═ Δ execute (m)/Δ t of the code unit to be compiled.
Wherein, step 1012 specifically includes:
for each code unit to be compiled, the activity value of the code unit to be compiled is active (m) ([ global _ active (m) +1] × [ local _ active (m) +1 ];
wherein m is a code unit to be compiled in the queue to be compiled, activity (m) is an activity value of the code unit to be compiled, global _ activity (m) is global activity information of the code unit to be compiled, and local _ activity (m) is local activity information of the code unit to be compiled.
Specifically, for each code unit to be compiled, global _ activity (m) and local _ activity (m) of the code unit to be compiled are calculated according to a preset formula, and an activity value activity (m) ([ global _ activity (m) +1] × [ local _ activity m + (1) ], where m is one code unit to be compiled in a queue to be compiled.
In this embodiment, specifically, each unit to be compiled has an activity value, and the activity values of the code units to be compiled are respectively compared with a preset activity threshold value ActiveThreshold; if the activity value of any code unit to be compiled in the compiling queue is smaller than a preset activity threshold value ActiveThreshold, determining that the code unit to be compiled with the activity value smaller than the preset activity threshold value ActiveThreshold is an inactive code unit to be compiled; if the activity value of any code unit to be compiled in the compiling queue is greater than or equal to the preset activity threshold value ActiveThreshold, it can be determined that the code unit to be compiled with the activity value greater than or equal to the preset activity threshold value ActiveThreshold is an active code unit to be compiled. Wherein the preset activity threshold value ActiveThreshold may be 32.
And step 1022, determining a suspected zombie code unit in the code units to be compiled which are determined to be inactive, and deleting the suspected zombie code unit from the compiling queue.
Wherein, step 1022 specifically includes:
if the code unit to be compiled in the compiling queue is marked as an active code unit to be compiled, determining that the counter value victim (m) of the code unit to be compiled marked as active is 0;
if the code unit to be compiled in the compiling queue is marked as an inactive code unit to be compiled, and the value of the local activity information of the code unit to be compiled that is determined to be inactive is equal to zero, determining that the respective counter value victim (m) of the code unit to be compiled that is marked as inactive is victim (m) + 1;
and determining the inactive code unit to be compiled with the counter value being greater than or equal to a preset counting threshold value as a suspected zombie code unit.
In this embodiment, specifically, in the to-be-compiled code units determined to be inactive in step 1021, the suspected zombie code units are identified, and then the suspected zombie code units are deleted from the compilation queue.
In particular, while inactive units of code to be compiled in the compilation queue are at a high risk of becoming zombie code, it is not advisable to immediately remove marked inactive units of code to be compiled from the compilation queue due to variability in program behavior in the virtual machine. Therefore, a code unit to be compiled in the compiling queue is deleted from the compiling queue only when the code unit to be compiled is in an inactive state for a long time. If a certain code unit to be compiled in the compiling queue is in an inactive state for a long time, the code unit is called a suspected zombie code unit. In order to identify suspected zombie code units, a counter named victim may be respectively designed for each code unit to be compiled in the compilation queue.
During the period of identifying the suspected zombie code units, updating the counters victim of the code units to be compiled in real time aiming at each code unit to be compiled, wherein the updating rule is as follows: before each compiling, if the code unit to be compiled in the compiling queue is marked as an active code unit to be compiled, the counter value victim (m) of the active code unit to be compiled is equal to 0, and then the counter value of the active code unit to be compiled is cleared; if the code unit to be compiled in the compiling queue is marked as an inactive code unit to be compiled, and the value of the local activity information of the code unit to be compiled marked as inactive is equal to zero, the counter value victim (m) of the inactive code unit to be compiled is victim (m) of +1, and at this time, the counter value of the inactive code unit to be compiled before the compiling is added by one 1. Before each compiling, the calculation process of the counter value of each code unit to be compiled needs to be executed; and then, performing accumulation calculation or zero clearing on the counter value of each code unit to be compiled, namely before each compiling, accumulating 1 in the counter value of the code unit to be compiled which is determined to be inactive, and performing zero clearing on the counter value of the code unit to be compiled which is determined to be active.
Setting a preset counting threshold value VictimThreshold for the counter value of the code unit to be compiled, and determining whether the counter value of the inactive code unit to be compiled before the compiling is greater than or equal to the preset counting threshold value VictimThreshold or not; and if the counter value of the inactive code unit to be compiled is greater than or equal to a preset counting threshold VictimThreshold, determining the code unit to be compiled with the counter value greater than or equal to the preset counting threshold VictimThreshold as a suspected zombie code unit. The preset count threshold VictimThreshold may be 10.
Then the suspected zombie code units can be deleted from the compilation queue; and then, compiling and scheduling each code unit to be compiled in the compiling queue with the suspected zombie code units deleted in sequence, and then compiling the code units until no code unit to be compiled exists in the compiling queue. When the code unit to be compiled does not exist in the compiling queue, the virtual machine can continuously wait for putting the code unit to be compiled into the compiling queue.
In the embodiment, before compiling each code unit to be compiled in a compiling queue, global active information and local active information of each code unit to be compiled in the compiling queue are acquired, and then the active value of each code unit to be compiled is respectively determined according to the global active information and the local active information of each code unit to be compiled; furthermore, the code unit to be compiled with the activity value smaller than the preset activity threshold value can be determined as an inactive code unit to be compiled, and the code unit to be compiled with the activity value larger than or equal to the preset activity threshold value is determined as an active code unit to be compiled; counting a counter value of each code unit to be compiled, and then determining the inactive code unit to be compiled with the counter value being greater than or equal to a preset counting threshold value as a suspected zombie code; the suspected zombie code units are removed from the compilation queue. The suspected zombie code units are not compiled, so that the proportion of the zombie code units in the virtual machine can be effectively reduced, the running expenditure of the virtual machine system is reduced, meanwhile, the compiling delay of the rest code units to be compiled is shortened, and the performance of the virtual machine system is improved.
Fig. 4 is a schematic structural diagram of a filtering apparatus for a code to be compiled according to a third embodiment of the present invention, and as shown in fig. 4, the filtering apparatus for a code to be compiled according to the present embodiment includes:
a determining module 31, configured to determine, before compiling each code unit to be compiled in the compiling queue, an activity value of each code unit to be compiled in the compiling queue according to the activity information of each code unit to be compiled in the compiling queue;
and the deleting module 32 is configured to determine a suspected zombie code unit in each code unit to be compiled according to the activity value of each code unit to be compiled, and delete the suspected zombie code unit from the compiling queue.
The filtering apparatus for a code to be compiled according to this embodiment can execute the filtering method for a code to be compiled according to the first embodiment of the present invention, and the implementation principles thereof are similar and will not be described herein again.
The method comprises the steps of determining the activity value of each code unit to be compiled in a compiling queue before compiling each code unit to be compiled in the compiling queue, then determining a suspected zombie code unit in each code unit to be compiled according to the activity value of each code unit to be compiled, and deleting the suspected zombie code unit from the compiling queue. The suspected zombie code units are not compiled, so that the proportion of the zombie code units in the virtual machine can be effectively reduced, the running expenditure of the virtual machine system is reduced, meanwhile, the compiling delay of the rest code units to be compiled is shortened, and the performance of the virtual machine system is improved.
Fig. 5 is a schematic structural diagram of a filtering apparatus for a code to be compiled according to a fourth embodiment of the present invention, and based on the third embodiment, as shown in fig. 5, the filtering apparatus for a code to be compiled according to the present embodiment, and the determining module 31 includes:
the obtaining sub-module 311 is configured to obtain global active information and local active information of each code unit to be compiled in the compiling queue before compiling each code unit to be compiled in the compiling queue;
the determining sub-module 312 is configured to determine an activity value of each code unit to be compiled according to the global activity information and the local activity information of each code unit to be compiled.
The obtaining sub-module 311 is specifically configured to:
before compiling each code unit to be compiled in a compiling queue, determining the total execution times of the code units to be compiled for each code unit to be compiled in the compiling queue, and determining the global active information of the code units to be compiled according to the total execution times of the code units to be compiled and a preset hot spot identification threshold value in a virtual machine, wherein the total execution times are the sum of the called times and the internal loop iteration times of the code units to be compiled in the virtual machine;
determining the interval execution times of the code unit to be compiled, and determining the local activity information of the code unit to be compiled according to the interval execution times of the code unit to be compiled, wherein the interval execution times are the execution times of the code unit to be compiled in a time period of a preset time length before the moment of determining the local activity information.
The determination sub-module 312 is specifically configured to:
for each code unit to be compiled, the activity value of the code unit to be compiled is active (m) ([ global _ active (m) +1] × [ local _ active (m) +1 ];
wherein m is a code unit to be compiled in the queue to be compiled, activity (m) is an activity value of the code unit to be compiled, global _ activity (m) is global activity information of the code unit to be compiled, and local _ activity (m) is local activity information of the code unit to be compiled.
A deletion module 32, comprising:
the first marking submodule 321 is configured to determine, in the activity values of the code units to be compiled, a code unit to be compiled whose activity value is smaller than a preset activity threshold value as an inactive code unit to be compiled;
and a deleting submodule 322, configured to determine a suspected zombie code unit in the code units to be compiled that are determined to be inactive, and delete the suspected zombie code unit from the compilation queue.
The deleting module 32 further includes:
and the second marking sub-module 323 is configured to, before the deleting sub-module 322 determines the suspected zombie code unit in the inactive code units to be compiled, determine, as an active code unit to be compiled, a code unit to be compiled of which the activity value is greater than or equal to a preset activity threshold value among the activity values of the code units to be compiled.
The delete sub-module 322 is specifically configured to:
if the code unit to be compiled in the compiling queue is marked as an active code unit to be compiled, determining that the counter value victim (m) of the code unit to be compiled marked as active is 0;
if the code unit to be compiled in the compiling queue is marked as an inactive code unit to be compiled, and the value of the local activity information of the code unit to be compiled that is determined to be inactive is equal to zero, determining that the respective counter value victim (m) of the code unit to be compiled that is marked as inactive is victim (m) + 1;
and determining the inactive code units to be compiled with the counter value being greater than or equal to a preset counting threshold value as suspected zombie code units, and deleting the suspected zombie code units from the compiling queue.
The filtering apparatus for a code to be compiled according to this embodiment can execute the filtering method for a code to be compiled according to the second embodiment of the present invention, and the implementation principles thereof are similar and will not be described herein again.
In the embodiment, before compiling each code unit to be compiled in a compiling queue, global active information and local active information of each code unit to be compiled in the compiling queue are acquired, and then the active value of each code unit to be compiled is respectively determined according to the global active information and the local active information of each code unit to be compiled; furthermore, the code unit to be compiled with the activity value smaller than the preset activity threshold value can be determined as an inactive code unit to be compiled, and the code unit to be compiled with the activity value larger than or equal to the preset activity threshold value is determined as an active code unit to be compiled; counting a counter value of each code unit to be compiled, and then determining the inactive code unit to be compiled with the counter value being greater than or equal to a preset counting threshold value as a suspected zombie code; the suspected zombie code units are removed from the compilation queue. The suspected zombie code units are not compiled, so that the proportion of the zombie code units in the virtual machine can be effectively reduced, the running expenditure of the virtual machine system is reduced, meanwhile, the compiling delay of the rest code units to be compiled is shortened, and the performance of the virtual machine system is improved.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (8)
1. A filtering method of a code to be compiled, which is applied to a dynamic compiling system, is characterized by comprising the following steps:
before compiling each code unit to be compiled in a compiling queue, respectively determining an activity value of each code unit to be compiled in the compiling queue according to activity information of each code unit to be compiled in the compiling queue;
determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled, and deleting the suspected zombie code units from the compiling queue; the zombie code units are compiled code units which are not executed in the compiled code units after a part of the code units to be compiled are compiled to obtain the compiled code units;
the determining the activity value of each code unit to be compiled in the compiling queue according to the activity information of each code unit to be compiled in the compiling queue includes: acquiring global active information and local active information of each code unit to be compiled in the compiling queue;
determining the activity value of each code unit to be compiled according to the global activity information and the local activity information of each code unit to be compiled; the acquiring global active information and local active information of each code unit to be compiled in the compiling queue includes:
determining the total execution times of the code units to be compiled for each code unit to be compiled in the compiling queue, and determining global active information of the code units to be compiled according to the total execution times of the code units to be compiled and a preset hot spot identification threshold value in the virtual machine, wherein the total execution times is the sum of the called times and the internal loop iteration times of the code units to be compiled in the virtual machine;
determining the interval execution times of the code unit to be compiled, and determining the local activity information of the code unit to be compiled according to the interval execution times of the code unit to be compiled, wherein the interval execution times are the execution times of the code unit to be compiled in a time period of a preset time length before the moment of determining the local activity information;
determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled, wherein the determining comprises the following steps:
determining the code unit to be compiled with the activity value smaller than a preset activity threshold value as an inactive code unit to be compiled in the activity values of the code units to be compiled;
and determining suspected zombie code units in the code units to be compiled which are determined to be inactive.
2. The method according to claim 1, wherein determining the activity value of each code unit to be compiled according to the global activity information and the local activity information of each code unit to be compiled comprises:
for each code unit to be compiled, the activity value of the code unit to be compiled is active (m) ([ global _ active (m) +1] × [ local _ active (m) +1 ];
wherein m is a code unit to be compiled in the queue to be compiled, activity (m) is an activity value of the code unit to be compiled, global _ activity (m) is global activity information of the code unit to be compiled, and local _ activity (m) is local activity information of the code unit to be compiled.
3. The method of claim 1, wherein determining suspected zombie code units in each code unit to be compiled according to the activity value of each code unit to be compiled, further comprises:
and determining the code unit to be compiled with the activity value larger than or equal to a preset activity threshold value as the active code unit to be compiled in the activity values of the code units to be compiled.
4. The method of claim 1, wherein determining suspected zombie code units in the code units to be compiled that are determined to be inactive comprises:
if the code unit to be compiled in the compiling queue is marked as an active code unit to be compiled, determining that the counter value victim (m) of the code unit to be compiled marked as active is 0;
if the code unit to be compiled in the compiling queue is marked as an inactive code unit to be compiled, and the value of the local activity information of the code unit to be compiled that is determined to be inactive is equal to zero, determining that the respective counter value victim (m) ═ victim (m) +1 of the code unit to be compiled that is marked as inactive;
and determining inactive code units to be compiled with the counter value being greater than or equal to a preset counting threshold value as suspected zombie code units, and deleting the suspected zombie code units from the compiling queue.
5. A filter device of a code to be compiled, which is applied to a dynamic compiling system, is characterized by comprising:
the determining module is used for respectively determining the activity values of the code units to be compiled in the compiling queue according to the activity information of the code units to be compiled in the compiling queue before compiling the code units to be compiled in the compiling queue;
the deleting module is used for determining suspected zombie code units in the code units to be compiled according to the activity values of the code units to be compiled and deleting the suspected zombie code units from the compiling queue; the zombie code units are compiled code units which are not executed in the compiled code units after a part of the code units to be compiled are compiled to obtain the compiled code units;
wherein the determining module comprises:
the obtaining submodule is used for obtaining global active information and local active information of each code unit to be compiled in the compiling queue before compiling each code unit to be compiled in the compiling queue;
the determining submodule is used for determining the activity value of each code unit to be compiled according to the global activity information and the local activity information of each code unit to be compiled;
the obtaining submodule is specifically configured to:
before compiling each code unit to be compiled in a compiling queue, determining the total execution times of the code units to be compiled for each code unit to be compiled in the compiling queue, and determining the global active information of the code units to be compiled according to the total execution times of the code units to be compiled and a preset hot spot identification threshold value in a virtual machine, wherein the total execution times is the sum of the called times and the internal loop iteration times of the code units to be compiled in the virtual machine;
determining the interval execution times of the code unit to be compiled, and determining the local activity information of the code unit to be compiled according to the interval execution times of the code unit to be compiled, wherein the interval execution times are the execution times of the code unit to be compiled in a time period of a preset time length before the moment of determining the local activity information;
wherein the deleting module comprises:
the first marking submodule is used for determining the code unit to be compiled with the activity value smaller than a preset activity threshold value as an inactive code unit to be compiled in the activity values of all the code units to be compiled;
and the deleting submodule is used for determining a suspected zombie code unit in the code units to be compiled which are determined to be inactive and deleting the suspected zombie code unit from the compiling queue.
6. The apparatus of claim 5, wherein the determination submodule is specifically configured to:
for each code unit to be compiled, the activity value of the code unit to be compiled is active (m) ([ global _ active (m) +1] × [ local _ active (m) +1 ];
wherein m is a code unit to be compiled in the queue to be compiled, activity (m) is an activity value of the code unit to be compiled, global _ activity (m) is global activity information of the code unit to be compiled, and local _ activity (m) is local activity information of the code unit to be compiled.
7. The apparatus of claim 5, wherein the deletion module further comprises:
and the second marking submodule is used for determining the code unit to be compiled with the activity value larger than or equal to the preset activity threshold value as the active code unit to be compiled in the activity values of the code units to be compiled.
8. The apparatus according to claim 5, wherein the delete submodule is specifically configured to:
if the code unit to be compiled in the compiling queue is marked as an active code unit to be compiled, determining that the counter value victim (m) of the code unit to be compiled marked as active is 0;
if the code unit to be compiled in the compiling queue is marked as an inactive code unit to be compiled, and the value of the local activity information of the code unit to be compiled that is determined to be inactive is equal to zero, determining that the respective counter value victim (m) ═ victim (m) +1 of the code unit to be compiled that is marked as inactive;
and determining inactive code units to be compiled with the counter value being greater than or equal to a preset counting threshold value as suspected zombie code units, and deleting the suspected zombie code units from the compiling queue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610317585.9A CN107368347B (en) | 2016-05-12 | 2016-05-12 | Method and device for filtering to-be-compiled code |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610317585.9A CN107368347B (en) | 2016-05-12 | 2016-05-12 | Method and device for filtering to-be-compiled code |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107368347A CN107368347A (en) | 2017-11-21 |
CN107368347B true CN107368347B (en) | 2020-08-04 |
Family
ID=60304447
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610317585.9A Active CN107368347B (en) | 2016-05-12 | 2016-05-12 | Method and device for filtering to-be-compiled code |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107368347B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105893104A (en) * | 2016-03-28 | 2016-08-24 | 乐视控股(北京)有限公司 | Code compiling method and device |
CN104854642B (en) * | 2012-12-17 | 2017-12-05 | 英艾克斯图股份有限公司 | For the method and apparatus using physical features mark manufacture article |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10102042B2 (en) * | 2014-11-26 | 2018-10-16 | Ca, Inc. | Prioritizing and distributing workloads between storage resource classes |
-
2016
- 2016-05-12 CN CN201610317585.9A patent/CN107368347B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104854642B (en) * | 2012-12-17 | 2017-12-05 | 英艾克斯图股份有限公司 | For the method and apparatus using physical features mark manufacture article |
CN105893104A (en) * | 2016-03-28 | 2016-08-24 | 乐视控股(北京)有限公司 | Code compiling method and device |
Non-Patent Citations (1)
Title |
---|
"嵌入式交叉汇编器的设计与优化";第06期;《中国优秀硕士学位论文全文数据库 信息科技辑》;20130615(第06期);第2.1.3、2.2.2、3.1.1节,第4章 * |
Also Published As
Publication number | Publication date |
---|---|
CN107368347A (en) | 2017-11-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR102112081B1 (en) | Method and device for identifying high-use intermediate code in a language virtual machine | |
CN108829610B (en) | Memory management method and device in neural network forward computing process | |
US9417935B2 (en) | Many-core process scheduling to maximize cache usage | |
US10102373B2 (en) | Method and apparatus for capturing operation in a container-based virtualization system | |
CN109272109B (en) | Instruction scheduling method and device of neural network model | |
US9128747B2 (en) | Methods and systems for optimizing the performance of software applications at runtime | |
US10585669B2 (en) | Reducing stalling in a simultaneous multithreading processor by inserting thread switches for instructions likely to stall | |
CN110609689A (en) | Application installation and operation method and device | |
CN106874022B (en) | A kind of hot patch injection method and device | |
CN108536514B (en) | Hot spot method identification method and device | |
CN105988855B (en) | Just-In-Time parameter optimization method and device | |
CN107368347B (en) | Method and device for filtering to-be-compiled code | |
US9690584B2 (en) | Systems and methods for register allocation | |
US20160196156A1 (en) | Simulation apparatus, simulation method, and computer product | |
US20160011889A1 (en) | Simulation method and storage medium | |
KR102147355B1 (en) | Method and apparatus for converting programs | |
CN106325963B (en) | Self-adaptive dynamic compiling and scheduling method and device | |
CN107220166B (en) | A kind of statistical method and device of CPU usage | |
CN107817972B (en) | Cache code processing method and device, storage medium and electronic equipment | |
KR20210025677A (en) | Branch target buffer with initial return prediction | |
CN105786586B (en) | Hotspot approach recognition methods and device | |
EP3134815B1 (en) | Memory efficient thread-level speculation | |
CN108920722B (en) | Parameter configuration method and device and computer storage medium | |
CN112685334A (en) | Method, device and storage medium for block caching of data | |
CN105718298B (en) | On-the-flier compiler method and 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 | ||
CP01 | Change in the name or title of a patent holder | ||
CP01 | Change in the name or title of a patent holder |
Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Patentee after: Loongson Zhongke Technology Co.,Ltd. Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Patentee before: LOONGSON TECHNOLOGY Corp.,Ltd. |