Memory area tuning method, device, storage medium and processor
By determining the maximum number of bytes in the old generation area in the JVM layer and the number of bytes occupied after Minor GC, and adjusting the frequency of Full GC and the expansion of the old generation area, the problem of cumbersome and complicated JVM tuning process is solved, the cost is reduced and the improvement is improved. improve system performance.
Patent Information
- Application Number
- CN202111633643.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-12-28
AI Technical Summary
In the existing technology, the JVM tuning process is cumbersome and complicated, has high time and operation and maintenance costs, and is prone to errors, leading to problems such as online memory overflow.
By determining the maximum number of bytes that can be stored in the old generation area in the JVM layer of the Java virtual machine, and determining the frequency of Full GC operations based on this number and the number of bytes occupied after the Minor GC operation, it is decided whether to expand the old generation area, simplifying Parameter tuning process automatically adjusts relevant parameters.
It simplifies the JVM tuning process, reduces the labor cost of parameter tuning, avoids tuning errors caused by errors, and improves system performance.
Smart Images

Figure CN114281483B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a memory area tuning method, device, storage medium and processor. Background Art
[0002] With the increasing number of WEB application software in the computer industry, the number of user visits to major platforms is also increasing day by day. The impact of JVM tuning on system performance has gradually been taken seriously by technical personnel. The JVM tuning in related technologies is cumbersome and complicated. It is generally done by modifying the JVM parameters little by little through repeated stress testing (stress testing). Such tuning will greatly increase the time cost and operation and maintenance cost of technical personnel, increase the difficulty of tuning, and lead to tuning errors due to mistakes, online memory overflow and other problems. Therefore, the JAVA environment now urgently needs a solution that can quickly determine the optimal JVM tuning parameters based on server-related parameters.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a memory area tuning method, device, storage medium and processor to at least solve the technical problems in the related art that the adjustment process of adjusting JVM related parameters based on the stress testing method is cumbersome and complicated, the time and operation and maintenance costs are high, and errors are prone to occur.
[0005] According to one aspect of an embodiment of the present application, a memory area tuning method is provided, including: determining the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, wherein the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area; determining the first number of bytes occupied by the old generation area after executing the Minor GC operation; determining the frequency of executing the Full GC operation on the memory area according to the maximum number of bytes and the first number of bytes; and determining whether to expand the old generation area according to the frequency.
[0006] Optionally, determining the first number of bytes occupied by the old generation area after performing a Minor GC operation includes: determining a first memory size corresponding to the Eden area; determining a second memory size occupied by the Eden area after accessing the Eden area; determining a target number of accesses to the Eden area based on the first memory size and the second memory size; performing a Minor GC operation on the Eden area after reaching the target number of accesses, wherein the Minor GC operation is used to indicate that objects in the Eden area are moved to the old generation area; determining a first growth value of the memory occupied in the old generation area when objects in the Eden area are moved to the old generation area; and determining the first growth value to be the first number of bytes occupied by the old generation area.
[0007] Optionally, determining a first growth value of memory occupied in the old generation area when moving objects in the Eden area to the old generation area includes: obtaining a second growth value of memory occupied in the old generation area after executing the Minor GC operation a first predetermined number of times; and obtaining a first growth value based on a ratio of the second growth value to the first predetermined number of times.
[0008] Optionally, determining the second memory size occupied by the Eden garden area after accessing the Eden garden area includes: determining a third growth value of the memory occupied by the Eden garden area after a second predetermined number of visits to the Eden garden area; and determining the second memory size occupied by the Eden garden area based on a ratio of the third growth value to the second predetermined number of visits.
[0009] Optionally, determining the second memory size occupied by the Eden garden area after accessing the Eden garden area further includes: obtaining a fourth growth value of the memory occupied by the Eden garden area after any two consecutive visits to the Eden garden area within a historical period; and determining the fourth growth value to be the second memory size.
[0010] Optionally, after determining the frequency of performing Full GC operations on the memory area according to the maximum number of bytes and the first number of bytes, the method also includes: determining the cycle of performing Full GC operations on the old generation area within a predetermined time period according to the frequency; calculating the first minimum energy value of the processing resources consumed after performing Full GC in each cycle according to the Landauer principle; and determining the delay of the processing resource in the process of processing data according to at least the first minimum energy value and the processing performance parameters of the processing resource, wherein the processing performance parameters at least include the size of the processing resource memory.
[0011] Optionally, the delay of the processing resource in the process of processing data is determined at least based on the first minimum energy value and the processing performance parameters of the processing resource, including: calculating the second minimum energy value of the processing resources consumed after executing Minor GC within the cycle according to the Landauer principle; determining the delay of the processing resource in the process of processing data according to the first minimum energy value, the second minimum energy value and the processing performance parameters of the processing resource.
[0012] Optionally, determining whether to expand the old generation area according to the frequency includes: when the frequency is greater than a preset threshold, determining to expand the old generation area; when the frequency is less than the preset threshold, determining not to expand the old generation area.
[0013] According to another aspect of an embodiment of the present application, a memory area tuning device is also provided, including: a first determination module, used to determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, wherein the memory area of the JVM layer includes: an Eden area, a survivor area, and an old generation area; a second determination module, used to determine the first number of bytes occupied by the old generation area after executing a Minor GC operation; a third determination module, used to determine the frequency of executing a Full GC operation on the memory area based on the maximum number of bytes and the first number of bytes; and a fourth determination module, used to determine whether to expand the old generation area based on the frequency.
[0014] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, the non-volatile storage medium including a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any one of the memory area tuning methods.
[0015] According to another aspect of an embodiment of the present application, a processor is further provided, and the processor is used to run a program, wherein any memory area tuning method is executed when the program is running.
[0016] In an embodiment of the present application, a method of analyzing the garbage collection process of the JVM layer is adopted, by determining the maximum number of bytes that can be stored in the old generation area in the JVM layer of the Java virtual machine, wherein the memory areas of the JVM layer include: the Eden area, the survivor area, and the old generation area; determining the first number of bytes occupied by the old generation area after executing the Minor GC operation; determining the frequency of executing the Full GC operation on the memory area according to the maximum number of bytes and the first number of bytes; determining whether to expand the old generation area according to the frequency, thereby achieving the purpose of determining whether to expand the capacity based on the frequency of executing the Full GC operation, thereby achieving the technical effect of simplifying the parameter tuning process, automatically determining whether to adjust the relevant parameters, and saving the labor cost of parameter tuning, thereby solving the technical problems in the related technology of adjusting the JVM related parameters based on the stress testing method, which is cumbersome and complicated, has high time and operation and maintenance costs, and is prone to errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 is a schematic diagram of an optional memory area tuning method according to an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of an optional JVM tuning process according to an embodiment of the present application;
[0020] Figure 3 It is a structural schematic diagram of an optional memory area tuning device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] According to an embodiment of the present application, an embodiment of a memory area tuning method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0024] Figure 1 The memory area tuning method according to the embodiment of the present application is as follows: Figure 1 As shown, the method comprises the following steps:
[0025] Step S102, determining the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, wherein the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area;
[0026] Step S104, determining the first number of bytes occupied by the old generation area after the Minor GC operation is performed;
[0027] Step S106, determining a frequency of performing a Full GC operation on the memory area according to the maximum number of bytes and the first number of bytes;
[0028] Step S108, determining whether to expand the old generation area according to the frequency.
[0029] In the memory area tuning method, the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer is determined, wherein the memory areas of the JVM layer include: the Eden area, the survivor area, and the old generation area; the first number of bytes occupied by the old generation area after the Minor GC operation is performed is determined; the frequency of performing FullGC operations on the memory area is determined according to the maximum number of bytes and the first number of bytes; and whether to expand the old generation area is determined according to the frequency, thereby achieving the purpose of determining whether to expand the capacity based on the frequency of performing Full GC operations, thereby achieving the technical effect of simplifying the parameter tuning process, automatically determining whether to adjust related parameters, and saving the labor cost of parameter tuning, thereby solving the technical problems in the related technology of adjusting JVM related parameters based on the stress testing method, which is cumbersome and complicated, has high time and operation and maintenance costs, and is prone to errors.
[0030] It should be noted that the maximum number of bytes that can be stored in the old generation area in the above JVM layer can be determined by the Bekenstein limit formula. Among them, the Bekenstein limit formula can be: maximum number of bytes = (JVM memory size * E) / hcln2. It should be noted that the role of the Bekenstein limit is the maximum number of bytes that can be stored under given space and energy, where E is energy (usually the operating energy of an 8-core system is about 125W), h is the reduced Pockram constant, and c is the speed of light.
[0031] Exemplarily, the above memory area tuning method can be implemented by the following steps, specifically:
[0032] 1. Start the running program and use Java Mission Control to view the memory size used by the Garden of Eden, the survivor area, and the old generation when the program is just started.
[0033] 2. Use a Java thread to quickly access the project for a predetermined number of times in succession (record the predetermined number of times), and then check the memory space used by the Garden of Eden, the survivor area, and the old generation; (for example, the first memory size corresponding to the Garden of Eden, and the memory size that can be stored in the old generation area).
[0034] 3. Calculate the memory added by visiting the Garden of Eden of the JVM once (that is, determine the second memory size occupied by the Garden of Eden after visiting the Garden of Eden).
[0035] 4. After calculating the number of times, Minor GC is called once (i.e., the target number of accesses to the Garden of Eden is determined according to the first memory size and the second memory size; and Minor GC is performed on the Garden of Eden after the target number of accesses is reached).
[0036] 5. Calculate the increased occupied size of the old generation memory after a Minor GC, and how long it will take to reclaim the old generation; (that is, determine the first byte number occupied by the old generation area after the Minor GC operation, and then determine the frequency of performing Full GC operations on the memory area based on the maximum number of bytes and the first number of bytes).
[0037] 6. Use the Landauer principle to calculate the minimum energy required for JVM to recycle Minor GC and Full GC;
[0038] 7. Check the basic parameters of the operating system such as memory, bandwidth, CPU, etc., and calculate the maximum number of bytes that can be stored in each space according to the Bekenstein limit;
[0039] 8. Calculate the recycling frequency of JVM's Minor GC;
[0040] 9. Through the above calculation, we can determine how long it will take for the system to perform a Minor GC and how long it will take for a Full GC under the expected concurrency, and use the Landauer principle to calculate when a Full GC occurs to calculate whether the current application meets the worst latency requirement of the application. It is understandable that the total energy consumed by the previous Minor GC can also be combined to calculate whether the current application meets the worst latency requirement of the application.
[0041] In some embodiments of the present application, determining the first number of bytes occupied by the old generation area after executing a Minor GC operation can be achieved in the following manner, specifically: determining a first memory size corresponding to the Eden area; determining a second memory size occupied by the Eden area after accessing the Eden area; determining a target number of accesses to the Eden area based on the first memory size and the second memory size; performing a Minor GC operation on the Eden area after reaching the target number of accesses, wherein the Minor GC operation is used to indicate that objects in the Eden area are moved to the old generation area; determining a first growth value of the memory occupied by the old generation area when objects in the Eden area are moved to the old generation area; and determining the first growth value to be the first number of bytes occupied by the old generation area.
[0042] It should be noted that determining the first growth value of the memory occupied in the old generation area when moving objects in the Eden area to the old generation area includes: obtaining the second growth value of the memory occupied in the old generation area after executing the Minor GC operation a first predetermined number of times; and obtaining the first growth value based on the ratio of the second growth value to the first predetermined number of times.
[0043] Exemplarily, determining the second memory size occupied by the Eden garden area after accessing the Eden garden area can be performed through the following steps: determining a third growth value of the memory occupied by the Eden garden area after a second predetermined number of visits to the Eden garden area; and determining the second memory size occupied by the Eden garden area based on the ratio of the third growth value to the second predetermined number of visits.
[0044] Exemplarily, determining the second memory size occupied by the Eden garden area after visiting the Eden garden area can also be achieved through the following steps: obtaining the fourth growth value of the memory occupied by the Eden garden area after any two consecutive visits to the Eden garden area within a historical period; and determining the fourth growth value as the second memory size.
[0045] In some embodiments of the present application, after determining the frequency of performing Full GC operations on the memory area based on the maximum number of bytes and the first number of bytes, the cycle of performing Full GC operations on the old generation area within a predetermined time period can also be determined based on the frequency; the first minimum energy value of the processing resources consumed after performing Full GC in each cycle is calculated based on the Landauer principle; and the delay of the processing resource in the process of processing data is determined based on at least the first minimum energy value and the processing performance parameters of the processing resource, wherein the processing performance parameters at least include the size of the processing resource memory.
[0046] It should be noted that the expression corresponding to the above Landauer principle can be KTln2. It can be understood that the Landauer principle can be used to determine the minimum energy required to erase a byte, where K is the Boltzmann constant and T is the temperature of the computer device (25°C at room temperature, or 298K at the Kelvin temperature scale).
[0047] In some optional embodiments of the present application, the delay of the processing resource in the process of processing data is determined based on at least the first minimum energy value and the processing performance parameters of the processing resource, including: calculating the second minimum energy value of the processing resources consumed after executing MinorGC within the cycle according to the Landauer principle; determining the delay of the processing resource in the process of processing data according to the first minimum energy value, the second minimum energy value and the processing performance parameters of the processing resource.
[0048] It is easy to notice that whether to expand the old generation area is determined according to the frequency, including: when the frequency is greater than a preset threshold, determining to expand the old generation area; when the frequency is less than the preset threshold, determining not to expand the old generation area.
[0049] Figure 2 is a schematic diagram of an optional JVM tuning process in an embodiment of the present application, such as Figure 2 As shown, the process mainly includes:
[0050] 1. First, you need to run the program. You can use Java Mission Control to view the memory size used by Eden, Survivor, and Old Generation when the program is just started. For example, the first memory size of Eden.
[0051] 2. Use Java threads to quickly access the project 50-100 times in succession (i.e. the predetermined number of times), and then check the memory space used by the Garden of Eden, the survivor area, and the old generation. It is easy to notice that the purpose of accessing the project multiple times is to make the subsequent average more accurate.
[0052] 3. After subtracting the sizes of the two visits to the Garden of Eden, the memory added by the JVM during one visit (unit: M) can be calculated. That is, the second memory size occupied by the Garden of Eden after the visit to the Garden of Eden is determined.
[0053] 4. The size of the Garden of Eden / the memory added by each access = the number of accesses that will result in a Minor GC. (That is, the target number of accesses that can be made to the Garden of Eden is determined based on the first memory size and the second memory size, and the Minor GC operation is performed on the Garden of Eden after the target number of accesses is reached).
[0054] 5. Calculate the promotion size of the old generation by observing the call of Minor GC, (the promotion size of the old generation = the value of the memory growth of the old generation after 1 Minor GC). (That is, determine the first growth value of the memory occupied by the old generation area when moving objects in the Eden area to the old generation area, and determine the first growth value as the first number of bytes occupied by the old generation area).
[0055] 6. Set the change value of the number of bytes in each memory area of the JMV layer in a certain application environment, for example, the change value of the number of bytes in each memory area within a predetermined period in a data concurrency scenario.
[0056] 7. Use the Landauer principle to calculate the minimum energy required for the JVM to recycle and call Minor GC and Full GC, and calculate the maximum number of bytes that can be stored in each space according to the Bekenstein limit (it should be noted that at least the maximum number of bytes that can be stored in the old generation area should be determined here).
[0057] 8. The frequency of Minor GC recovery of JVM is calculated based on the number of bytes calculated in the predetermined time period under concurrency. (Under normal circumstances, when the memory of Eden Garden is full, Minor GC recovery will begin. Before recovery, it will first determine whether the free continuous row space of the old generation is greater than the total space to be recovered in the new generation. If it is greater, Minor GC will be performed; if it is not greater, Full GC will be performed. If Full GC is performed frequently, it will affect the system performance. It is understandable that since Full GC affects the system performance, the frequency of Full GC should be minimized).
[0058] 9. The above calculation can determine how long it will take for the system to perform a Minor GC and how long it will take for the system to perform a Full GC. The Landauer principle can be used to calculate the total energy consumed by the previous Minor GC after the Full GC occurs, to calculate whether the current application meets the worst latency requirement of the application.
[0059] 10. If the frequency of Full GC calls is too high, you can reduce the frequency of Full GC by increasing the old generation memory after calculation. You can also use the CMS garbage collector for garbage collection.
[0060] Figure 3 A memory area tuning device according to an embodiment of the present application is provided. Figure 3 As shown, the device comprises:
[0061] The first determination module 40 is used to determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, wherein the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area;
[0062] A second determining module 42 is used to determine the first number of bytes occupied by the old generation area after the Minor GC operation is performed;
[0063] A third determination module 44 is used to determine the frequency of performing the FullGC operation on the memory area according to the maximum number of bytes and the first number of bytes;
[0064] The fourth determination module 46 is used to determine whether to expand the old generation area according to the frequency.
[0065] In the memory area tuning device, the first determination module 40 is used to determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, wherein the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area; the second determination module 42 is used to determine the first number of bytes occupied by the old generation area after the Minor GC operation is performed; the third determination module 44 is used to determine the frequency of performing Full GC operations on the memory area according to the maximum number of bytes and the first number of bytes; the fourth determination module 46 is used to determine whether to expand the old generation area according to the frequency, thereby achieving the purpose of determining whether to expand the capacity based on the frequency of performing Full GC operations, thereby achieving the technical effect of simplifying the parameter tuning process, automatically determining whether to adjust related parameters, and saving the labor cost of parameter tuning, thereby solving the technical problems in the related technology that the adjustment process of adjusting JVM related parameters based on the stress testing method is cumbersome and complicated, the time and operation and maintenance costs are high, and errors are prone to occur.
[0066] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, the non-volatile storage medium including a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any one of the memory area tuning methods.
[0067] According to another aspect of an embodiment of the present application, a processor is further provided, and the processor is used to run a program, wherein any memory area tuning method is executed when the program is running.
[0068] Specifically, the above storage medium is used to store program instructions for executing the following functions to achieve the following functions:
[0069] Determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, where the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area; determine the first number of bytes occupied by the old generation area after the Minor GC operation is performed; determine the frequency of performing Full GC operations on the memory area based on the maximum number of bytes and the first number of bytes; determine whether to expand the old generation area based on the frequency.
[0070] Specifically, the processor is used to call the program instructions in the memory to implement the following functions:
[0071] Determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, where the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area; determine the first number of bytes occupied by the old generation area after the Minor GC operation is performed; determine the frequency of performing Full GC operations on the memory area based on the maximum number of bytes and the first number of bytes; determine whether to expand the old generation area based on the frequency.
[0072] In an embodiment of the present application, a method of analyzing the garbage collection process of the JVM layer is adopted, by determining the maximum number of bytes that can be stored in the old generation area in the JVM layer of the Java virtual machine, wherein the memory areas of the JVM layer include: the Eden area, the survivor area, and the old generation area; determining the first number of bytes occupied by the old generation area after executing the Minor GC operation; determining the frequency of executing the Full GC operation on the memory area according to the maximum number of bytes and the first number of bytes; determining whether to expand the old generation area according to the frequency, thereby achieving the purpose of determining whether to expand the capacity based on the frequency of executing the Full GC operation, thereby achieving the technical effect of simplifying the parameter tuning process, automatically determining whether to adjust the relevant parameters, and saving the labor cost of parameter tuning, thereby solving the technical problems in the related technology of adjusting the JVM related parameters based on the stress testing method, which is cumbersome and complicated, has high time and operation and maintenance costs, and is prone to errors.
[0073] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0074] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0075] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0076] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0077] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0078] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0079] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A memory area tuning method, It is characterized in that include: Determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, where the memory areas of the JVM layer include: Eden area, survivor area, and old generation area; Determine the first byte number occupied by the old generation area after executing the Minor GC operation; Determining a frequency of performing a Full GC operation on the memory area according to the maximum number of bytes and the first number of bytes; After determining the frequency of performing Full GC operations on the memory area according to the maximum number of bytes and the first number of bytes, the method further includes: determining a cycle of performing Full GC operations on the old generation area within a predetermined time period according to the frequency; calculating a first minimum energy value of processing resources consumed after performing Full GC in each cycle according to the Landauer principle; determining the latency of the processing resource in the process of processing data according to at least the first minimum energy value and a processing performance parameter of the processing resource, wherein the processing performance parameter at least includes the size of the memory of the processing resource; Determine whether to expand the old generation area according to the frequency.
2. The method according to claim 1, It is characterized in that Determining the first number of bytes occupied by the old generation area after the Minor GC operation is performed includes: Determine a first memory size corresponding to the Eden area; Determine a second memory size occupied by the Eden garden after accessing the Eden garden; Determining a target number of accesses to the Garden of Eden according to the first memory size and the second memory size; After reaching the target access number, the Minor GC operation is performed on the Eden area, wherein the Minor GC operation is used to instruct to move objects in the Eden area to the old generation area; Determine a first growth value of the memory occupied by the old generation area when the object in the Eden area is moved to the old generation area; The first growth value is determined to be a first number of bytes occupied by the old generation area.
3. The method according to claim 2, It is characterized in that Determining a first growth value of the memory occupied by the old generation area when the object in the Eden area is moved to the old generation area includes: Obtaining a second growth value of the old generation area occupied after the Minor GC operation is executed a first predetermined number of times; The first increase value is obtained according to a ratio of the second increase value to the first predetermined number of times.
4. The method according to claim 2, It is characterized in that Determining the second memory size occupied by the Eden garden after accessing the Eden garden includes: Determining a third growth value of the memory occupied by the Eden garden after a second predetermined number of visits to the Eden garden; The second memory size occupied by the Eden area is determined according to the ratio of the third growth value to the second predetermined number of times.
5. The method according to claim 2, It is characterized in that Determining the second memory size occupied by the Eden garden after accessing the Eden garden further includes: Obtaining a fourth growth value of the memory occupied by the Eden garden after any two consecutive visits to the Eden garden within a historical period; The fourth growth value is determined to be the second memory size.
6. The method according to claim 1, It is characterized in that Determining the delay of the processing resource in the process of processing data at least according to the first minimum energy value and a processing performance parameter of the processing resource, comprises: Calculating a second minimum energy value of the processing resources consumed after executing the Minor GC within the period according to the Landauer principle; The delay of the processing resource in the process of processing data is determined according to the first minimum energy value, the second minimum energy value and the processing performance parameter of the processing resource.
7. The method according to claim 1, It is characterized in that Determining whether to expand the old generation area according to the frequency includes: When the frequency is greater than a preset threshold, determining to expand the capacity of the old generation area; When the frequency is less than a preset threshold, it is determined not to expand the capacity of the old generation area.
8. A memory area tuning device, It is characterized in that include: The first determination module is used to determine the maximum number of bytes that can be stored in the old generation area in the Java virtual machine JVM layer, wherein the memory area of the JVM layer includes: the Eden area, the survivor area, and the old generation area; A second determination module is used to determine the first number of bytes occupied by the old generation area after the Minor GC operation is performed; a third determining module, configured to determine a frequency of performing a Full GC operation on the memory area according to the maximum number of bytes and the first number of bytes; A fourth determination module, used to determine whether to expand the old generation area according to the frequency; The memory area tuning device is further used to determine the frequency of performing Full GC operations on the memory area according to the maximum number of bytes and the first number of bytes, and then determine the cycle of performing Full GC operations on the old generation area within a predetermined time length according to the frequency; calculate the first minimum energy value of the processing resources consumed after performing Full GC in each cycle according to the Landauer principle; and determine the delay of the processing resource in the process of processing data according to at least the first minimum energy value and the processing performance parameters of the processing resource, wherein the processing performance parameters at least include the size of the memory of the processing resource.
9. A non-volatile storage medium, It is characterized in that The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the memory area tuning method described in any one of claims 1 to 7.
10. A processor, It is characterized in that The processor is used to run a program, wherein the program executes the memory area tuning method described in any one of claims 1 to 7 when running.
Citation Information
Patent Citations
Virtual machine garbage collection tuning method, device, electronic device and storage medium
CN109117242A
