• 沒有找到結果。

We now give the experimental results and discuss on them. We will first clarify the impact of different coalescing strategies on size-ordered segregated list allocator. Second, we will show how well NHT improve object allocation performance, using different coalescing strategies. Then, we will prove our former assumption that with the power of NHT, immediate coalescing strategy comes back to flavor via empirically results. In the end, we will use experiment to find the number of free lists of size-ordered segregated list allocator resulting in the best performance using NHT. We will only show the results of _205_raytrace in this chapter because it is representative, and the results of other benchmarks are presented in the appendix.

4.3.1

Impact of Different Coalescing Strategies

Three important coalescing strategies, never coalescing, deferred coalescing, and immediate coalescing strategy, have been described in chapter 2. Generally speaking, never coalescing has the fastest allocation speed, but results in most serious fragmentation. Deferred coalescing strategy is believed to have lower fragmentation than never coalescing strategy and it still has fast allocation speed. Immediate coalescing strategy has poor allocation performance but on the other hand, it has the lowest fragmentation.

From Figure 4-1, we can see that immediate coalescing strategy has the worst allocation performance among the three strategies, and deferred coalescing has comparable allocation performance to never coalescing strategy. The allocation performance of deferred coalescing and never coalescing strategy are 2.5 time the allocation performance of immediate coalescing until the heap becomes too small. When heap size is less than about 2 times minimum heap

size, the allocation performance of deferred coalescing and never coalescing degrade sharply.

This is because garbage collection is invoked excessively, and each last allocation before triggering the garbage collection is an unsatisfied allocation request, indicating that the allocator must traverse up to the last free list. On the other hand, the allocation performance of immediate coalescing strategy does not have much degradation.

Considering the influence of coalescing strategy on time spent on garbage collection, we can see from Figure 4-2 that immediate coalescing constantly result in far shorter garbage collection time, especially when heap size becomes too small. Never coalescing and deferred coalescing strategy bring unacceptable long garbage collection time because of excessive invocation of garbage collection.

Another interesting trend observed from Figure 4-2 in the figure is that within some range of heap size, the garbage collection performance does not improve as the heap size grows. This results from the way mark-sweep garbage collector to reclaim free space. In the sweep phase, it scans from one end of the heap to the other end, thus if the number of garbage collection invocation is the same, smaller heap size could have short garbage collection time.

When taking both object allocation time and garbage collection time into accounts (see Figure 4-3), deferred coalescing and never coalescing strategy have 2 times speedup over immediate coalescing strategy if heap is sufficient large. However, in very constrained heap size, immediate coalescing strategy is the only usable strategy.

Figure 4-1: Object allocation time using different coalescing strategy

Figure 4-2: Garbage collection time using different coalescing strategy

Figure 4-3: Heap management time using different coalescing strategy

4.3.2 The Effectiveness of Next Hit Table Mechanism

After our NHT is added, size-order segregated list allocator using either deferred coalescing, never coalescing, and immediate coalescing strategy has improvement in allocation performance and the improvement is most significant when applying NHT with immediate coalescing strategy (see Figure 4-4 and 4-8). This is because using immediate coalescing strategy makes many free lists holding small chunks more likely to become insufficient or empty after garbage collection, thus originally many allocation requests spend considerable traversal to locate the right free list to get a large enough chunk. The allocation performance using deferred coalescing and never coalescing strategy are still comparable after adding NHT. And, as expected, the presence of NHT does not effect garbage collection time (see Figure 4-5 and 4-9).

We can also observe that when heap size is less than a threshold, which is about 2 times minimum heap size, the allocation performance gap between the allocator using immediate coalescing with NHT and the allocator using immediate coalescing without NHT is closer in smaller heap size. This is because in such a constrained heap size, the time to update NHT occupies more fraction of heap management time.

Figure 4-4: Object allocation time of using deferred coalescing strategy plus NHT

Figure 4-5: Garbage collection time of using deferred coalescing strategy plus NHT

Figure 4-6: Heap management time of using deferred coalescing strategy plus NHT

Figure 4-7: Heap management time of using never coalescing strategy plus NHT

Figure 4-8: Object allocation time of using immediate coalescing strategy plus NHT

Figure 4-9: Garbage collection time of using immediate coalescing strategy plus NHT

Figure 4-10: Heap management time of using immediate coalescing strategy plus NHT

4.3.3 NHT Leads to a Different Choice of Coalescing Strategy

As the experimental results shown in subsection 4.3.1, we already known that size-order segregated list allocator using deferred coalescing and never coalescing strategy outperform that using immediate coalescing, without our NHT mechanism. However, after adding NHT, the order changes dramatically. No matter the heap size is constrained or more sufficient, the allocator with NHT using immediate coalescing strategy constantly beats the other two strategies with NHT (see Figure 4-13). Although using deferred coalescing plus NHT has the fastest allocation speed because of the update of NHT is most infrequent if using deferred coalescing strategy, the allocation speed gap between using immediate coalescing strategy with Next Hit Table and using deferred coalescing strategy with Next Hit Table are too small to be observable. The advantage of low fragmentation of immediate coalescing strategy becomes a dominate factor because of NHT’s ability to reduce many traversals during allocation.

Figure 4-11: Object allocation time of 4 configurations

Figure 4-12: Garbage collection time of 4 configurations

Figure 4-13: Total heap management time of 4 configurations

4.3.4 Determining the Number of Free Lists

The above result has told us size-order segregated list allocator with NHT plus immediate coalescing strategy is the best configuration. Another import parameter for size-ordered segregated list fit allocator is the number of free lists. The number of free lists determines a size such that all free chunks larger than this size are chiained in the last free list.

For our experimental environment where heap objects are multiple of 4-byte, having N free lists means all free chunks of sizes equal to or larger than 4N are chained in the last free list. A

good value N should be chosen such that it can result in a balance between time spent on header traversals plus NHT updates, and time spent on best-fitting search in the last free lists.

We determine N by experiment.

As the result shown in Figure 4-14, we can observe that using more free lists gives better performance, until the number of free lists reaches 256. Using fewer free lists indicates that more time will be spent on best-fitting search in the last free list, and because immediate coalescing strategy tends to produce larger free chunks, N should not be chosen too small.

Also, using more than 256 free lists does not give further improvement because there is rare free chunk larger than 1K bytes using immediate coalescing strategy. We can conclude that 256 free lists are enough.

Figure 4-14: Using 256 free lists are good enough

Chapter 5 Conclusion

In this thesis, we proposed a mechanism, Next Hit Table, to accelerate object allocation for size-ordered segregated list object allocator in automatic garbage collection environment, with negligible space overhead. Our proposed mechanism is based on the observation that many free lists will become empty within the interval between two invocations of garbage collection. The concept of Next Hit Table is very simple, a mapping from allocation request for each size to the closest non-empty free list holding sufficient large chunks. The mechanism is very effective that the result shows that our proposed mechanism can improve the overall heap management performance by 100%.

Another issue we studied is the coalescing strategies of contiguous free chunks.

Although deferred coalescing is generally considered a better strategy than never coalescing strategy and immediate coalescing strategy, we showed that with the power of Next Hit Table mechanism, immediate coalescing is better, rather than deferred coalescing strategy. Although the update of Next Hit Table is more frequent if using immediate coalescing strategy, the allocation speed gap between using immediate coalescing strategy with Next Hit Table and using deferred coalescing strategy with Next Hit Table are very small. Such an upside-down result tells us that if allocation can be done very fast then fragmentation is the most important problem in garbage collection environment.

Explicitly managing heap and incremental garbage collection environment also have dynamic object allocation, thus they can benefit from the Next Hit Table mechanism.

However, because dead objects are de-allocated using explicit de-allocation statement in

explicit heap management environment, free chunks of each sizes are less likely to become insufficient due to the locality of object size. Therefore, the benefit of using Next Hit Table will be less.

Moreover, since using incremental garbage collector means the heap space might still be sufficient at garbage collection, free chunks of each sizes are less likely to become insufficient.

Furthermore, because not all dead objects at garbage collection triggering point will be collected at once, more time is spent on garbage collection due to more frequent garbage collection. These two factors make the benefit of Next Hit Table less if using incremental garbage collector.

Our proposed mechanism might also be incorporated in generational mark-sweep garbage collector to accelerate the promotion process which copies live objects from young space to old space, since the copying is essentially object allocation in old space.

References

[1] Wilson, P. R., et al. “Dynamic Storage Allocation – A Survey and Critical Review”. In Proceedings of 1995 International Workshop on Memory Management, Kinross,

Scotland, UK, September 27-29, 1995.

[2] Jones, R., Lins, R. Garbage Collection: Algorithms for Automatic Dynamic Memory Management, Wiley, 1996.

[3] Arnold, K., et al. The Java Programming Language, Addison Wesley, 3rd edition, 2000.

[4] Lindholm T., Yelling, F., The Java Virtual Machine Specification, Addison Wesley, 2nd edition, 1999.

[5] Johnstone, M. S. Non-Compacting Memory Allocation and Real-Time garbage Collection, University of Texas in Austin, PhD’s Dissertation, 1996.

[6] Appel, A. W., Palsberg J. Modern Compiler Implementation in Java, Cambridge University Press, 2nd edition, 2002.

[7] Fong, A. S., Li, R. C. L. “Dynamic Memory Allocation/Deallocation Behavior in Java Programs”. In Proceedings of 2002 IEEE Region 10 Conference on Computers, Communications, Control and Power Engineering, October 28-31, 2002.

[8] Sun Microsystems Inc. CVM. http://java.sun.com.

[9] Standard Performance Evaluation Corporation. SPECjvm98. http://www.spec.org.

相關文件