[go: up one dir, main page]

CN102023896A - Dispatcher of Java virtual machine-based concurrent garbage collector - Google Patents

Dispatcher of Java virtual machine-based concurrent garbage collector Download PDF

Info

Publication number
CN102023896A
CN102023896A CN 201010595927 CN201010595927A CN102023896A CN 102023896 A CN102023896 A CN 102023896A CN 201010595927 CN201010595927 CN 201010595927 CN 201010595927 A CN201010595927 A CN 201010595927A CN 102023896 A CN102023896 A CN 102023896A
Authority
CN
China
Prior art keywords
scheduler
time
memory
garbage collection
refuse collection
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.)
Pending
Application number
CN 201010595927
Other languages
Chinese (zh)
Inventor
杨珉
张源
周寻
王迪
臧斌宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fudan University
Original Assignee
Fudan University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fudan University filed Critical Fudan University
Priority to CN 201010595927 priority Critical patent/CN102023896A/en
Publication of CN102023896A publication Critical patent/CN102023896A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Memory System (AREA)

Abstract

发明属于Java虚拟机垃圾回收技术领域,具体为一种基于Java虚拟机的并发垃圾回集器的调度器。本发明调度器主要通过动态地对当前应用程序的运行情况进行分析,让垃圾收集过程能在合适的时间点触发。调度器在应用程序每次申请内存时都使用一个简单的时间推算方法来判断是否需要触发垃圾收集。调度器同时也处理系统内存资源耗尽的情况。本发明作为并发垃圾收集统一框架的一部分,提供了一种低开销高性能的垃圾收集调度器,优化了垃圾收集的触发点,既提高了垃圾收集器的运行效率,也大大降低了系统资源耗尽发生的可能性。

Figure 201010595927

The invention belongs to the technical field of Java virtual machine garbage collection, and specifically relates to a scheduler of a Java virtual machine-based concurrent garbage collector. The scheduler of the present invention mainly enables the garbage collection process to be triggered at an appropriate time point by dynamically analyzing the running conditions of the current application program. The scheduler uses a simple time reckoning method to determine whether garbage collection needs to be triggered every time the application requests memory. The scheduler also handles the exhaustion of system memory resources. As a part of the unified framework of concurrent garbage collection, the present invention provides a low-overhead high-performance garbage collection scheduler, optimizes the trigger point of garbage collection, not only improves the operating efficiency of the garbage collector, but also greatly reduces the consumption of system resources to the extent possible.

Figure 201010595927

Description

基于Java虚拟机的并发垃圾收集器的调度器 Scheduler of Concurrent Garbage Collector Based on Java Virtual Machine

技术领域technical field

本发明属于Java虚拟机垃圾回收技术领域,具体涉及一种基于Java虚拟机的并发垃圾回集器的调度器。The invention belongs to the technical field of Java virtual machine garbage collection, and in particular relates to a scheduler of a Java virtual machine-based concurrent garbage collector.

背景技术   Background technique

随着Java等高级编程语言的兴起,如何合理的利用内存成为了为各高级语言提供环境支持时最关键的考虑因素之一。作为内存利用的主要手段,垃圾收集技术在系统安全和资源管理方面扮演着越来越重要的角色。With the rise of high-level programming languages such as Java, how to make reasonable use of memory has become one of the most critical considerations when providing environmental support for various high-level languages. As the main means of memory utilization, garbage collection technology plays an increasingly important role in system security and resource management.

随着现代应用程序使用内存量增大、对象数量增多,以及消减“停止世界”垃圾收集所造成的停顿严重影响了应用程序的响应时间,并发的垃圾收集(Concurrent GC)出现了。该技术使垃圾收集器可以在应用程序线程执行的情况下进行垃圾收集,即垃圾收集器和应用程序线程是并行执行的。通过测试,并发垃圾收集技术较之“停止世界”垃圾收集有明显的运行效率提升,所以这个概念开始为越来越多的人所接受。Concurrent garbage collection (Concurrent GC) has emerged as modern applications use increased amounts of memory, the number of objects increases, and the pauses caused by reducing the "stop the world" garbage collection seriously affect the response time of the application. This technology enables the garbage collector to perform garbage collection while the application thread is executing, that is, the garbage collector and the application thread are executed in parallel. Through tests, the concurrent garbage collection technology has significantly improved operating efficiency compared with the "stop the world" garbage collection, so this concept has begun to be accepted by more and more people.

然而对于并发垃圾收集器何时被触发就成了一个问题:因为如果垃圾收集发生在系统内存还很空余的时候,就没有充分利用系统内存资源并且造成垃圾收集的频率过高,反而会影响应用程序性能;如果发生在系统内存已经比较紧张的时候,那系统堆内存就很可能在并发垃圾收集完成前被耗尽,这样就迫使垃圾收集器进行“耗尽处理”,需要被迫把应用程序停下来,这样无疑就增加了应用程序的停顿时间。尤其对于内存需求量大的程序,并发垃圾收集的调度方式对其运行的稳定性和效率都会有显著的影响。所以如何恰如其分的找出这个GC触发的时间点变得十分关键。当然,对于常规的垃圾收集技术(如“停止世界”垃圾收集),好的调度方式也能明显改善垃圾回收器的运行效率。However, when the concurrent garbage collector is triggered becomes a problem: because if the garbage collection occurs when the system memory is still free, the system memory resources will not be fully utilized and the frequency of garbage collection will be too high, which will affect the application instead. Program performance; if it occurs when the system memory is already relatively tight, the system heap memory is likely to be exhausted before the concurrent garbage collection is completed, which forces the garbage collector to perform "exhaustion processing", and the application needs to be forced to Stopping, which undoubtedly increases the pause time of the application. Especially for programs with large memory requirements, the scheduling method of concurrent garbage collection will have a significant impact on the stability and efficiency of its operation. So how to properly find out the time point of this GC trigger becomes very critical. Of course, for conventional garbage collection techniques (such as "stop the world" garbage collection), a good scheduling method can also significantly improve the operating efficiency of the garbage collector.

发明内容Contents of the invention

本发明的目的在于设计一种能使并发垃圾收集器在合适的时间点被触发,以便提升垃圾收集器乃至整个程序运行效率的,关于并发垃圾收集器的调度器,并使用调度器对垃圾收集线程进行动态调度,从而更有效的利用系统资源。The purpose of the present invention is to design a scheduler about the concurrent garbage collector that can trigger the concurrent garbage collector at an appropriate time point in order to improve the operating efficiency of the garbage collector and even the entire program, and use the scheduler to collect garbage Threads are dynamically scheduled to make more efficient use of system resources.

本发明主要通过动态地对当前应用程序的运行情况进行分析,让垃圾收集过程能在合适的时间点触发。在垃圾收集器的实现中,我们把当前堆内存空间占用量,应用程序分配内存速度等因素都记录下来,以计算的方式估计出垃圾收集器的合适触发点。The present invention mainly enables the garbage collection process to be triggered at an appropriate time point by dynamically analyzing the running conditions of the current application program. In the implementation of the garbage collector, we record factors such as the current heap memory space occupancy and the memory allocation speed of the application, and estimate the appropriate trigger point of the garbage collector by calculation.

首先定义理想的GC触发时间点,即在垃圾收集器的跟踪处理全部完成后,清理处理尚未开始前系统的内存资源正好完全耗尽。但是显然的,由于并发垃圾收集器是和应用程序同时执行的,程序运行的不确定性决定了并发垃圾收集器达到理想GC触发点是不可能的,不过我们还是可以通过评估的方式使调度器选定的GC触发点尽量的接近这一理想点。First, define the ideal GC trigger time point, that is, after the garbage collector's tracking process is completed, the system's memory resources are completely exhausted before the cleanup process starts. But obviously, since the concurrent garbage collector is executed at the same time as the application program, the uncertainty of program operation determines that it is impossible for the concurrent garbage collector to reach the ideal GC trigger point, but we can still make the scheduler The selected GC trigger point is as close to this ideal point as possible.

在本发明中,调度器需要记录的系统的信息主要包括堆的总体大小M0、当前堆(Heap)内的内存消耗情况M1、当前应用程序的内存消耗的平均速率V1,以及当前垃圾收集器跟踪处理的平均速率V2。而最理想的情况是当垃圾收集的跟踪处理需要的时间t1和应用程序最后耗尽系统内存资源的时间t2相同。根据上述条件,我们可以得到以下三个等式:In the present invention, the system information that the scheduler needs to record mainly includes the overall size M 0 of the heap, the memory consumption situation M 1 in the current heap (Heap), the average rate V 1 of the memory consumption of the current application program, and the current garbage The average rate V2 of processing is tracked by the collector. The most ideal situation is when the time t 1 required for the tracking process of garbage collection is the same as the time t 2 when the application program finally exhausts the system memory resources. According to the above conditions, we can get the following three equations:

t1 = t2;                                ①t 1 = t 2 ; ①

t1 = M1/V2;                         ②t 1 = M 1 /V 2 ; ②

t2 = (M0 – M1)/V1;;         ③t 2 = (M 0 – M 1 )/V 1 ;; ③

根据以上三个等式,我们就可以计算出最佳的GC触发点,即每当系统的内存消耗到M2时,[M2 = M0*V2/(V1 + V2)],就应该触发垃圾收集器进行工作,因为这样在垃圾收集的跟踪处理结束时,系统的内存正好被耗尽,即得到完全的使用。也就是说,在理论上讲这样能尽可能的逼近最优的GC触发点。然而在实际运行时,由于并发程序的不确定性,这样的设置很可能会让系统内存资源在GC跟踪处理尚未结束时就耗尽。这时一旦系统资源耗尽,垃圾收集器就要被迫停止应用程序来处理,这样反而会使应用程序的运行效率减低。调度器用一个内存使用上线M*来代替堆的总大小M0来解决这个问题。经过实际的测试,我们的调度器用堆总大小的90%来做内存使用上线,According to the above three equations, we can calculate the best GC trigger point, that is, whenever the system memory consumption reaches M 2 , [M 2 = M 0 *V 2 /(V 1 + V 2 )], The garbage collector should be triggered to work, because at the end of the garbage collection tracking process, the system's memory is just exhausted, that is, fully used. In other words, in theory, this can approach the optimal GC trigger point as much as possible. However, in actual operation, due to the uncertainty of concurrent programs, such a setting is likely to cause system memory resources to be exhausted before the GC tracking process ends. At this time, once the system resources are exhausted, the garbage collector will be forced to stop the application program for processing, which will reduce the operating efficiency of the application program. The scheduler solves this problem by replacing the total size of the heap M with a memory usage limit of M * . After actual testing, our scheduler uses 90% of the total heap size for memory usage,

M* = 0.9 * M0                                ④M * = 0.9 * M 0

所以,调度器最终的最佳GC触发点是Therefore, the final optimal GC trigger point for the scheduler is

M=0.9*M0*V2/(V1 + V2)。          ⑤M + =0.9*M 0 *V 2 /(V 1 +V 2 ). ⑤

但是系统真的实时都检验上述数据会对性能造成显著的影响。所以本发明中的调度器只在每次系统要求申请新的内存时才会进行上述检验,这样就能很好的减少了实时检验带来的性能影响。当然,这样的处理同样可以满足垃圾收集器的正确性。因为只有当应用程序申请系统内存时,系统的堆内存才会增大,其他事件不会造成系统堆内存变化。But the system really checks the above data in real time, which will have a significant impact on performance. Therefore, the scheduler in the present invention will only perform the above inspection every time the system requests to apply for new memory, so that the performance impact brought by the real-time inspection can be well reduced. Of course, such processing can also satisfy the correctness of the garbage collector. Because only when the application applies for system memory, the system heap memory will increase, and other events will not cause the system heap memory to change.

另一方面,为了在不丢失准确性的前提下尽量减小对应用程序运行的影响,调度器在应用程序每次申请内存时都使用一个简单的时间推算方法来判断是否需要触发垃圾收集。On the other hand, in order to minimize the impact on the running of the application without losing accuracy, the scheduler uses a simple time calculation method to determine whether garbage collection needs to be triggered every time the application requests memory.

最后,虽然调度器可以大大降低系统资源耗尽的可能性,但是考虑到并发垃圾收集器的GC线程是和应用程序同时运行的,由并发垃圾收集的跟踪和标记等操作所需时间的不确定性,系统资源还是有耗尽的可能。所以调度器同时也需要处理系统内存资源耗尽的情况,调度器同样也给出了处理资源耗尽的处理方案。Finally, although the scheduler can greatly reduce the possibility of system resource exhaustion, considering that the GC thread of the concurrent garbage collector runs at the same time as the application, the time required for operations such as tracking and marking of concurrent garbage collection is uncertain However, system resources may still be exhausted. Therefore, the scheduler also needs to deal with the exhaustion of system memory resources, and the scheduler also provides a solution to deal with resource exhaustion.

本发明的有益效果是:本发明作为并发垃圾收集统一框架的一部分(状态⑥),提供了一种低开销高性能的垃圾收集调度器,优化了垃圾收集的触发点,既提高了垃圾收集器的运行效率,也大大降低了系统资源耗尽发生的可能性。同时,该调度器也处理了并发垃圾收集时系统资源耗尽的情况。The beneficial effects of the present invention are: as a part of the unified framework of concurrent garbage collection (state ⑥), the present invention provides a low-overhead high-performance garbage collection scheduler, optimizes the trigger point of garbage collection, and improves the efficiency of the garbage collector. It also greatly reduces the possibility of system resource exhaustion. At the same time, the scheduler also handles the exhaustion of system resources during concurrent garbage collection.

附图说明Description of drawings

图1所示为并发垃圾收集的状态转换。Figure 1 shows the state transitions for concurrent garbage collection.

图2所示为二分逼近法的实现过程。Figure 2 shows the implementation process of the bisection approximation method.

具体实施方式Detailed ways

本发明的基本思想是通过动态收集系统实时信息,并通过进行计算出综合评估值的方式来评估出更为准确GC触发点。这里将对调度器需要收集的信息和如何综合评估计算进行详细的讨论。The basic idea of the present invention is to evaluate a more accurate GC trigger point by dynamically collecting system real-time information and calculating a comprehensive evaluation value. Here we will discuss in detail the information that the scheduler needs to collect and how to evaluate the calculation comprehensively.

1)首先定义理想的GC触发点,即在垃圾收集器的跟踪处理全部完成后,清理处理尚未开始前系统的内存资源正好完全耗尽。但是显然的,由于并发垃圾收集器是和应用程序同时执行的,程序运行的不确定性决定了并发垃圾收集器达到理想GC触发点是不可能的,不过我们还是可以通过评估的方式使调度器选定的GC触发点尽量的接近这一理想点。1) First define the ideal GC trigger point, that is, after the garbage collector's tracking process is completed, the system's memory resources are completely exhausted before the cleanup process starts. But obviously, since the concurrent garbage collector is executed at the same time as the application program, the uncertainty of program operation determines that it is impossible for the concurrent garbage collector to reach the ideal GC trigger point, but we can still make the scheduler The selected GC trigger point is as close to this ideal point as possible.

在本发明中,调度器需要记录的系统的信息主要包括堆的总体大小M0、当前堆(Heap)内的内存消耗情况M1、当前应用程序的内存消耗的平均速率V1,以及当前垃圾收集器跟踪处理的平均速率V2。而最理想的情况是当垃圾收集的跟踪处理需要的时间t1和应用程序最后耗尽系统内存资源的时间t2相同。根据上述条件,我们可以得到以下三个等式:In the present invention, the system information that the scheduler needs to record mainly includes the overall size M 0 of the heap, the memory consumption situation M 1 in the current heap (Heap), the average rate V 1 of the memory consumption of the current application program, and the current garbage The average rate V2 of processing is tracked by the collector. The most ideal situation is when the time t 1 required for the tracking process of garbage collection is the same as the time t 2 when the application program finally exhausts the system memory resources. According to the above conditions, we can get the following three equations:

t1 = t2;                                ①t 1 = t 2 ; ①

t1 = M1/V2;                         ②t 1 = M 1 /V 2 ; ②

t2 = (M0 – M1)/V1;          ③t 2 = (M 0 – M 1 )/V 1 ; ③

根据以上三个等式,我们就可以计算出最佳的GC触发点,即每当系统的内存消耗到M2时,[M2 = M0*V2/(V1 + V2)],就应该触发垃圾收集器进行工作,因为这样在垃圾收集的跟踪处理结束时,系统的内存正好被耗尽,即得到完全的使用。也就是说,在理论上讲这样能尽可能的逼近最优的GC触发点。然而在实际运行时,由于并发程序的不确定性,这样的设置很可能会让系统内存资源在GC跟踪处理尚未结束时就耗尽。这时一旦系统资源耗尽,垃圾收集器就要被迫停止应用程序来处理,这样反而会使应用程序的运行效率减低。调度器用一个内存使用上线M*来代替堆的总大小M0来解决这个问题。经过实际的测试,我们的调度器用堆总大小的90%来做内存使用上线,According to the above three equations, we can calculate the best GC trigger point, that is, whenever the system memory consumption reaches M 2 , [M 2 = M 0 *V 2 /(V 1 + V 2 )], The garbage collector should be triggered to work, because at the end of the garbage collection tracking process, the system's memory is just exhausted, that is, fully used. In other words, in theory, this can approach the optimal GC trigger point as much as possible. However, in actual operation, due to the uncertainty of concurrent programs, such a setting is likely to cause system memory resources to be exhausted before the GC tracking process ends. At this time, once the system resources are exhausted, the garbage collector will be forced to stop the application program for processing, which will reduce the operating efficiency of the application program. The scheduler solves this problem by replacing the total size of the heap M with a memory usage limit of M * . After actual testing, our scheduler uses 90% of the total heap size for memory usage,

M* = 0.9 * M0                                ④M * = 0.9 * M 0

所以,调度器最终的最佳GC触发点是Therefore, the final optimal GC trigger point for the scheduler is

M=0.9*M0*V2/(V1 + V2)。          ⑤M + =0.9*M 0 *V 2 /(V 1 +V 2 ). ⑤

但是系统真的实时都检验上述数据会对性能造成显著的影响。所以本发明中的调度器只在每次系统要求申请新的内存时才会进行上述检验,这样就能很好的减少了实时检验带来的性能影响。当然,这样的处理同样可以满足垃圾收集器的正确性。因为只有当应用程序申请系统内存时,系统的堆内存才会增大,其他事件不会造成系统堆内存变化。But the system really checks the above data in real time, which will have a significant impact on performance. Therefore, the scheduler in the present invention will only perform the above inspection every time the system requests to apply for new memory, so that the performance impact brought by the real-time inspection can be well reduced. Of course, such processing can also satisfy the correctness of the garbage collector. Because only when the application applies for system memory, the system heap memory will increase, and other events will not cause the system heap memory to change.

2)为了进一步提高应用程序的运行效率,我们对调度器做了进一步的优化。不难看出,其实在每次应用程序请求内存时都检验是否要求进行垃圾收集还是有相当的冗余判断,例如在一次垃圾收集刚结束时,系统剩余内存应该很充裕,这时候的检验操作就是冗余的。而跟踪扫描整个堆内存的情况的开销是不能忽略的,针对这种情况,调度器以一个简单的时间推算来代替堆内存的扫描,从而大大减小了开销。2) In order to further improve the operating efficiency of the application, we have further optimized the scheduler. It is not difficult to see that it is quite redundant to check whether garbage collection is required every time an application requests memory. For example, when a garbage collection has just ended, the remaining memory in the system should be sufficient. The check operation at this time is redundant. The overhead of tracking and scanning the entire heap memory cannot be ignored. In this case, the scheduler replaces the scanning of the heap memory with a simple time calculation, thereby greatly reducing the overhead.

这个时间推算的基本思想是利用之前收集的当前系统内存使用量和应用程序消耗内存的速率来打制的推算出下一次需要进行垃圾收集的时间。如在一次垃圾收集结束时(假设当前时间是t0),根据垃圾收集结束时堆内存的剩余情况M和应用程序消耗内存的平均速率V,那么我们就能推算出下一次发生GC的时间大致为t1The basic idea of this time calculation is to use the previously collected current system memory usage and the rate at which the application consumes memory to calculate the time when the next garbage collection needs to be performed. For example, at the end of a garbage collection (assuming the current time is t 0 ), according to the remaining situation M of the heap memory at the end of the garbage collection and the average rate V of memory consumed by the application, then we can calculate the approximate time when the next GC occurs for t 1 ,

而t1 = t0 + M/V                                 ⑥And t 1 = t 0 + M/V

调度器认为在t0到t1这个时间端间的内存申请都是合法的,不对其进行对检验。这样调度器就大大减少了冗余的检验次数,从而进一步提高应用程序的运行效率。The scheduler considers that the memory application between t 0 and t 1 is legal, and does not check it. In this way, the scheduler greatly reduces the number of redundant checks, thereby further improving the operating efficiency of the application.

和1)中需要确定内存使用上限同样的,如果真的简单的用式⑥中计算的t1来作为下一次的垃圾收集时间触发点,很可能在垃圾收集结束之前系统的内存已经耗尽了。这样就要求垃圾收集器额外地处理系统耗尽的情况,反而影响了应用程序的运行效率。所以在实际实现时,调度器会采取一些保守策略来慢慢的逼近下次垃圾回收的时间点。这样的保守算法有很多,核心思想都是以多进行几次对扫描为代价,来避免系统内存资源的耗尽。这里介绍下实现较为简单也较为直观的二分逼近法。As in 1), it is necessary to determine the upper limit of memory usage. If you simply use t 1 calculated in formula ⑥ as the trigger point of the next garbage collection time, it is likely that the system memory will be exhausted before the garbage collection ends. . This requires the garbage collector to additionally handle the system exhaustion situation, which in turn affects the operating efficiency of the application. Therefore, in actual implementation, the scheduler will adopt some conservative strategies to slowly approach the time point of the next garbage collection. There are many such conservative algorithms, and the core idea is to avoid exhaustion of system memory resources at the cost of several more scans. Here we introduce the simpler and more intuitive binary approximation method.

二分逼近法的原理图见图2,调度器现在就用这种方法来逼近GC触发点。像上述情况中一样,调度器还是在每次垃圾收集结束时,重新检测堆内存的情况,记录下垃圾收集结束后堆内存的剩余情况M0和应用程序消耗内存的平均速率V0。不同于前者的是为了防止出现应用程序大量消耗内存资源而使系统提前资源耗尽的情况发生,调度器采用二分接近的,The schematic diagram of the binary approximation method is shown in Figure 2. The scheduler now uses this method to approach the GC trigger point. As in the above case, the scheduler re-detects the heap memory situation at the end of each garbage collection, and records the remaining situation M 0 of the heap memory after the garbage collection and the average rate V 0 of memory consumption by the application. What is different from the former is that in order to prevent the system from running out of resources in advance due to the large consumption of memory resources by the application program, the scheduler adopts a binary approach,

即第一次选取的t1 为:That is, t 1 ' selected for the first time is:

t1 = t0 + M0/2V0                      ⑦t 1 ' = t 0 + M 0 /2V 0

而第二次选取的t2 为:And the t 2 ' selected for the second time is:

t2 = t1  + M1/2V1。                   ⑧t 2 ' = t 1 ' + M 1 /2V 1 . ⑧

不难从式⑦和式⑧看出,调度器在有以下的迭代方式(式⑨)来逼近最终的GC触发点,而只有当当前t n+1 时刻的内存消耗量超过了1)中介绍的内存上线值时,迭代就终止,开始进行垃圾收集工作。这样的做法较好的避免了在进行垃圾收集之前或之中系统发生资源耗尽的情况,因为调度器在每个GC触发点理论时间进行到一半处就进行检验,这样有利于避免应用程序在某一时间段中大量消耗内存带来的影响。It is not difficult to see from Equation ⑦ and Equation ⑧ that the scheduler has the following iterative method (Equation ⑨) to approach the final GC trigger point, and only when the memory consumption at the current t n+1 ' time exceeds 1) When the introduced memory comes online, the iteration terminates and garbage collection begins. This approach better avoids resource exhaustion in the system before or during garbage collection, because the scheduler checks halfway through the theoretical time of each GC trigger point, which is beneficial to avoid the application The impact of a large amount of memory consumption in a certain period of time.

tn+1 = tn  + Mn/2Vn。         ⑨t n+1 ' = t n ' + M n /2V n . ⑨

 (注:在以上各式中,M0表示t0时刻堆的大小,V0表示t0时刻内存消耗的平均速率,以此类推,Mn表示tn时刻堆的大小,Vn表示tn时刻内存消耗的平均速率。)(Note: In the above formulas, M 0 represents the size of the heap at time t 0 , V 0 represents the average rate of memory consumption at time t 0 , and so on, M n represents the size of the heap at time t n , V n represents t n Average rate of memory consumption over time.)

如图2中所示,在某一次垃圾结束时刻t0,调度器用式⑨计算出t1时刻,之后忽略t0到t1时间段中对堆内存的申请的检验。当到达t1时刻时,首先检验是否已经超过了需要进行垃圾收集的堆内存使用上限,若还没有超过,继续用式⑨迭代计算t2,t3等;若已经超过,如图中的t4时刻,这样就停止迭代过程,开始进行垃圾收集工作。As shown in Figure 2, at a certain garbage end time t 0 , the scheduler uses formula ⑨ to calculate time t 1 , and then ignores the inspection of the heap memory application during the time period from t 0 to t 1 . When time t 1 is reached, first check whether the upper limit of heap memory usage that needs to be garbage collected has been exceeded. If not, continue to iteratively calculate t 2 , t 3 , etc. with formula ⑨; if it has been exceeded, t in the figure At 4 moments, the iterative process is stopped and garbage collection begins.

经过实验测得,一般用二分法来逼近GC触发点需要进行5~8次迭代,也就是说只要进行5~8次对堆内存的整体扫描。而用原先的每次分配内存时就进行检验,两次垃圾收集过程之间的扫描对内存次数可能就是上百甚至上千次。所以调度器以时间推算来减少冗余扫描对应用程序的运行效率有很大的积极意义。According to experiments, it usually takes 5 to 8 iterations to approach the GC trigger point using the dichotomy method, that is to say, only 5 to 8 overall scans of the heap memory are required. However, with the original inspection every time memory is allocated, the number of scans to memory between two garbage collection processes may be hundreds or even thousands of times. Therefore, the scheduler uses time calculation to reduce redundant scanning, which has great positive significance for the operating efficiency of the application.

3)这一部分将要介绍调度器对系统内存资源耗尽的回复策略。上述2)中提到的时间推算方法虽然对应用程序的运行效率,但是因为省略了很多对申请内存的验证,所以对于内存消耗量很不稳定的应用程序来说在提升运行效率的同时这样的处理又增加了系统内存资源耗尽的可能性。所以这里对系统内存资源耗尽的处理的好坏就变的更加重要了。对于一个成熟的并行垃圾回收器而言,系统内存资源耗尽处理,本身就是一个重要的单独模块,而我们实现的调度器把系统资源耗尽处理集成到调度器中,使并发垃圾收集器的触发与灾难处理都由调度器来完成。下面就简单的说说系统资源耗尽处理的实现思想。3) This part will introduce the scheduler's response strategy to the exhaustion of system memory resources. Although the time calculation method mentioned in the above 2) improves the operating efficiency of the application, because it omits a lot of verification of the application memory, it can improve the operating efficiency for applications with unstable memory consumption. Processing in turn increases the possibility of exhausting system memory resources. Therefore, it becomes more important to deal with the exhaustion of system memory resources here. For a mature parallel garbage collector, the exhaustion of system memory resources is itself an important separate module, and the scheduler we implemented integrates the exhaustion of system resources into the scheduler, making the concurrent garbage collector Both triggering and disaster handling are done by the scheduler. Let's briefly talk about the realization idea of system resource exhaustion processing.

按照系统资源耗尽发生的时刻段,可以把耗尽情况分成3种:According to the time period when system resource exhaustion occurs, the exhaustion situation can be divided into three types:

a) 发生在应用程序运行中,垃圾收集线程没有启动。a) Occurs when the application is running, and the garbage collection thread is not started.

b) 发生在垃圾收集线程启动后的跟踪阶段。b) Occurs during the tracing phase after the garbage collection thread starts.

c) 发生在垃圾收集线程启动后的收集清理阶段。c) Occurs in the collection cleanup phase after the garbage collection thread starts.

从应用程序的运行效率最大化的角度考虑,调度器利用并发垃圾收集的特点,对这三种情况分别进行了处理。From the perspective of maximizing the operating efficiency of the application, the scheduler uses the characteristics of concurrent garbage collection to handle these three situations respectively.

a) 对于第一种情况,因为垃圾收集线程还没有启动,没有可以利用的信息,所以只能把所有的线程都停下来,做一次“停止世界”的垃圾收集过程。之后再让程序继续运行。a) For the first case, because the garbage collection thread has not started yet, there is no available information, so all the threads can only be stopped and a "stop the world" garbage collection process is performed. Then let the program continue running.

b) 当系统资源耗尽出现在垃圾收集线程启动后的跟踪阶段,那么并发垃圾收集阶段的跟踪信息时可以复用的。调度器的做法是停掉其他应用程序的线程,让垃圾收集线程把跟踪阶段完成,先得到对象跟踪信息。之后用这个对象跟踪信息做一次“停止世界”的垃圾收集过程来释放内存。这样就省去了一次跟踪处理。b) When the exhaustion of system resources occurs in the tracking phase after the garbage collection thread starts, the tracking information in the concurrent garbage collection phase can be reused. The scheduler's approach is to stop the threads of other applications, let the garbage collection thread complete the tracking phase, and get the object tracking information first. Then use this object tracking information to do a "stop the world" garbage collection process to free the memory. This saves one tracking process.

c) 对于系统资源耗尽出现在垃圾收集线程启动后的收集清理阶段,处理就更为简单了。因为之前的跟踪和清理过程都还是适用的,调度只要停掉其他应用程序的线程,让垃圾收集线程把收集清理阶段完成就可以了。c) It is easier to deal with system resource exhaustion in the collection and cleanup phase after the garbage collection thread starts. Because the previous tracking and cleaning processes are still applicable, scheduling only needs to stop the threads of other applications and let the garbage collection thread complete the collection and cleaning phase.

Claims (3)

1. scheduler based on the concurrent garbage collector of Java Virtual Machine, the information that it is characterized in that the scheduler records system comprises the size of population M of heap 0, the memory consumption situation M in the current heap 1, current application program the mean speed V of memory consumption 1, and current garbage collector is followed the tracks of the mean speed V that handles 2And the time t that needs is handled in the tracking of refuse collection 1Exhaust the time t of system memory resource at last with application program 2Identical, promptly obtain following three equatioies:
t 1?=?t 2
t 1?=?M 1/V 2
t 2?=?(M 0?–?M 1)/V 1
So the final best GC triggered time point of scheduler is:
M +?=0.9*M 0*V 2/(V 1?+?V 2)。
2. the scheduler of the concurrent garbage collector based on Java Virtual Machine according to claim 1 is characterized in that described scheduler adopts two fens approximatiosses to approach GC triggered time point, i.e. the time t that chooses for the first time 1 'For:
t 1 =?t 0?+?M 0/2V 0
And the time t that chooses for the second time 2 'For:
t 2 =?t 1 ?+?M 1/2V 1
And calculate by following formula:
t n+1 =?t n ?+?M n/2V n
Above various in, M 0Expression t 0The size of moment heap, V 0Expression t 0The mean speed of moment memory consumption, by that analogy, M nExpression t nThe size of moment heap, V nExpression t nThe mean speed of moment memory consumption;
At certain the rubbish t finish time 0, 9. scheduler calculates t with formula 1Constantly, ignore t afterwards 0To t 1In time period to the check of the application of heap memory; When arriving t 1In the time of constantly, at first whether check has surpassed the heap memory SC service ceiling that need carry out refuse collection, if also do not surpass, continues with 9. iterative computation t of formula 2, t 3If surpass, just stop iterative process, begin to carry out refuse collection work.
3. the scheduler of the concurrent garbage collector based on Java Virtual Machine according to claim 2 is characterized in that described scheduler also comprises system resource is exhausted processing: exhaust the moment section of generation according to system resource, the resource exhaustion situation is divided into 3 kinds:
A) it is in service to occur in application program, and the refuse collection thread is not activated;
B) tracking phase after occurring in the refuse collection thread and starting;
C) the collection clean-up phase after occurring in the refuse collection thread and starting;
Scheduler utilizes the characteristics of concurrent refuse collection, and these three kinds of situations are carried out following processing respectively:
A) for first kind of situation, only all threads are all stopped, do once the garbage collection process of " stopping the world ", allow program continue operation afterwards again;
B) exhaust tracking phase after appearing at the refuse collection thread and starting when system resource, the trace information in so concurrent refuse collection stage gives multiplexing; Scheduler is cut off the thread of other application programs, allows the refuse collection thread that tracking phase is finished, and obtains the object trace information earlier; The garbage collection process of doing once " stopping the world " with this object trace information comes releasing memory afterwards;
C) exhaust the collection clean-up phase that appears at after the refuse collection thread starts for system resource, scheduler is cut off the thread of other application programs, allows the refuse collection thread finish collecting clean-up phase.
CN 201010595927 2010-12-20 2010-12-20 Dispatcher of Java virtual machine-based concurrent garbage collector Pending CN102023896A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201010595927 CN102023896A (en) 2010-12-20 2010-12-20 Dispatcher of Java virtual machine-based concurrent garbage collector

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201010595927 CN102023896A (en) 2010-12-20 2010-12-20 Dispatcher of Java virtual machine-based concurrent garbage collector

Publications (1)

Publication Number Publication Date
CN102023896A true CN102023896A (en) 2011-04-20

Family

ID=43865218

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201010595927 Pending CN102023896A (en) 2010-12-20 2010-12-20 Dispatcher of Java virtual machine-based concurrent garbage collector

Country Status (1)

Country Link
CN (1) CN102023896A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9880745B2 (en) 2016-06-21 2018-01-30 International Business Machines Corporation Reducing concurrency of garbage collection operations
CN108121602A (en) * 2017-12-14 2018-06-05 捷开通讯(深圳)有限公司 A kind of method, electronic equipment and the storage medium of definite garbage collection trigger point
CN110291508A (en) * 2017-02-01 2019-09-27 微软技术许可有限责任公司 garbage collector
CN110325969A (en) * 2017-02-01 2019-10-11 微软技术许可有限责任公司 Multistage garbage collector

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1790270A (en) * 2005-12-14 2006-06-21 浙江大学 Java virtual machine implementation method supporting multi-process
US7380039B2 (en) * 2003-12-30 2008-05-27 3Tera, Inc. Apparatus, method and system for aggregrating computing resources
CN101751335A (en) * 2008-11-28 2010-06-23 国际商业机器公司 Method, device and cluster system for collecting rubbish of scheduling virtual machine

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7380039B2 (en) * 2003-12-30 2008-05-27 3Tera, Inc. Apparatus, method and system for aggregrating computing resources
CN1790270A (en) * 2005-12-14 2006-06-21 浙江大学 Java virtual machine implementation method supporting multi-process
CN101751335A (en) * 2008-11-28 2010-06-23 国际商业机器公司 Method, device and cluster system for collecting rubbish of scheduling virtual machine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《复旦大学》 20091231 周寻 基于多核环境下的高效并发性垃圾收集器 第5页至第40页 1-3 , *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9880745B2 (en) 2016-06-21 2018-01-30 International Business Machines Corporation Reducing concurrency of garbage collection operations
US10108346B2 (en) 2016-06-21 2018-10-23 International Business Machines Corporation Reducing concurrency of garbage collection operations
US10691343B2 (en) 2016-06-21 2020-06-23 International Business Machines Corporation Reducing concurrency of garbage collection operations
CN110291508A (en) * 2017-02-01 2019-09-27 微软技术许可有限责任公司 garbage collector
CN110325969A (en) * 2017-02-01 2019-10-11 微软技术许可有限责任公司 Multistage garbage collector
CN110325969B (en) * 2017-02-01 2023-06-02 微软技术许可有限责任公司 Multi-stage garbage collector
CN108121602A (en) * 2017-12-14 2018-06-05 捷开通讯(深圳)有限公司 A kind of method, electronic equipment and the storage medium of definite garbage collection trigger point

Similar Documents

Publication Publication Date Title
CN102023891A (en) Concurrent garbage collector frame based on Java virtual machine
CN110825518B (en) Microservice-oriented nanosecond-level power resource allocation method and system
CN102955560B (en) Application program processing method and device
CN103049332B (en) Virtual CPU scheduling method
CN110930291B (en) GPU video memory management control method and related device
CN103425536B (en) A kind of test resource management method of Based on Distributed system performance testing
CN107766123A (en) A JVM Tuning Method
CN1447224A (en) Method of optimizing use of memory in computer applied program
CN102023896A (en) Dispatcher of Java virtual machine-based concurrent garbage collector
CN1949185A (en) Parallel adjusting and performance analyzing method of supporting multi-language multi-platform under isomerized environment
CN112052073A (en) Script performance analysis method and device, readable storage medium and electronic device
CN108647137A (en) A kind of transaction capabilities prediction technique, device, medium, equipment and system
Tan et al. Embedded operating system energy analysis and macro-modeling
Zhang et al. A Spark Scheduling Strategy for Heterogeneous Cluster.
JPWO2021076378A5 (en)
CN104063245A (en) Memory analysis and optimization method and system based on garbage collection
CN106294163A (en) A kind of code branch covering rate detection method of lightweight
CN102110052A (en) Parallel acceleration method for dynamic analysis of program behavior
Wu et al. Turbostream: Towards low-latency data stream processing
CN102752374B (en) System and method for storing and accessing power utilization efficacy data
CN119248499A (en) Task processing load analysis method and device
CN116974994B (en) High-efficiency file collaboration system based on clusters
CN102769532A (en) Network Management Server and Its Method for Exporting Query Results into Excel Files
CN103647823A (en) Storage resource scheduling method in cloud computing operating system
CN202906977U (en) A storage access system of electric energy using efficiency data

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20110420