A New Garbage Collection Technique For Server Environment: Xiting Xie
A New Garbage Collection Technique For Server Environment: Xiting Xie
Xiting Xie
Zhong Xing Telecommunication Inc.
Nanjing, China
AbstractConventional generational garbage collection threshold for each object; (2) providing an extra generation
techniques cannot achieve low tenuring costs, low scavenging (e.g., aging space); (3) enlarging young generation size.
costs on the medium-lived objects and low generation size at the These approaches give medium-lived objects more time to
meantime. In this paper, we will propose a novel Two- die in the youngest generation, which avoid premature
Dimensional Generational Garbage Collector (2D-GC) which promotion problem to some extent. However, the first two
can meet these three requirements at once. By its name, the approaches will bring multiple-scavenging problem, that is,
2D-GC arranges the heap in two dimensions. Our the medium-lived object will be scavenged for multiple times
experimental results show that 2D-GC can achieve the lowest before its death. Therefore, this approach will increase
tenuring cost and scavenging cost without enlarging generation
scavenging cost of the medium-lived object. The last
size.
approach will cost a lot of space, which can translate to long
Keywords-Java Virtual Machine; Garbage Collection pause time of a minor collection.
In summary, conventional generational garbage collection
techniques can not achieve low tenuring costs, low
I. INTRODUCTION
scavenging costs on the medium-lived objects and low
One of the most useful language features of modern generation size at the meantime. In this paper, we will
Object-Oriented programming languages is garbage propose a novel Two-Dimensional Generational Garbage
collection (GC).GC improves programming productivity by Collector (2D-GC) which can meet these three requirements
reducing errors resulting from explicit memory management. at once. The 2D-GC leverages Xian et.al.s research on
Moreover, GC underpins sound software engineering remote/local objects [10][23] to dynamically identify
principles of abstraction and modularity. GC leads to clusters of similar-lifespan objects. Xian et.al defined key
cleaner code since memory management concerns are no objects and segregate objects into groups based on temporal
longer cluttered with the programming logic. locality and lifespan similarity. Similarly, the 2D-GC
To date, the best performing garbage collectors in wide arranges the heap in two dimensions: (1) heap is divided
use are generational collectors. These collectors rely on the into two vertical generations: a young generation and an old
fact that most objects die young. Generational GC partitions generation; (2) the young generation is divided into two
the heap into age-based generations of objects, where age is horizontal generations: one for accommodating short-lived
measured in the amount of allocation. New objects are 1 objects and the other for medium-lived and long-lived
allocated in the youngest generation. Rather than collecting objects. New objects are allocated in either one horizontal
the entire heap and incurring the cost of copying all live generation, depending on the estimated lifetimes of these
objects, generational collectors collect the youngest objects. Survivors of either horizontal generation will be
generation (i.e., minor collection or nursery collection), promoted to the old generation. The 2D-GC can be easily
place survivors in the next older generation, and only collect extended to supply more horizontal generations in the young
older generations (i.e., major collection or full collection) if generation, or tailored to a conventional generational
necessary. collector.
However, the generational garbage collection has In the remainder of the paper, we will present some
difficulty of treating medium-lived objects. Medium-lived related work and then describe our 2D-GC. Next we discuss
objects are the objects which survive at least one minor its design issues and its implementation in Sun's JVM. Then
collection but die before the next full collection. Tenuring we give experimental results and finally conclude this paper.
medium-lived objects too early will cause premature
promotion problem, which increases tenuring cost and also II. TWO DIMENSIONAL GENERATIONAL GARBAGE
causes the older generation to fill up too soon, resulting in a COLLECTION (2DGC)
full collection with a longer pause time. Also, premature
promotion has an adverse effect on the user program's Figure 1 illustrates the diagram of 2D-GC. 2D-GC
locality, since it is likely that most program accesses will be arranges the heap in two dimensions: (1) heap is divided into
to younger objects. The premature promotion problem can be a young generation and an old generation vertically; (2) the
alleviated by the following approaches: (1) setting a tenuring young generation is divided into two horizontal generations:
Gen-s for accommodating short-lived objects and Gen-o for usually short-lived) and non-short-lived sites. During an
non-short-lived objects (i.e., medium-lived and long-lived actual run, the runtime system uses the prediction advice to
objects). New objects are allocated in either one horizontal identify short-lived objects. Thus, no monitoring overhead is
generation, depending on the estimated lifetimes of these incurred during the production run of the application. Online
objects. When the Gen-s is filled up, it will trigger a Gen-s profiling approaches can be accurate but they are tedious and
collection. When the Gen-o is filled up, it will trigger a Gen- inconsistent in different production runs (e.g., different
o collection. Survivors of either collection will be promoted input). In online sampling, we do not profile all object
to the old generation. lifetimes. Instead, we compute survival rate of allocation
sites during every collection. By the sample information, we
can guide collector to identity short-lived (or non-short-lived)
objects. The accuracy of online sampling approaches highly
depends on the sampling interval.
The other way, that we plan to use, is to segregate objects
based on type and connectivity information. Our segregation
scheme is based on the following two observations:
1. The type with higher allocation rate tends to
have shorter lifetime. This observation
conforms to the prolific hypothesis [20] that
prolific types (i.e., objects types that are
allocated most frequently) have short lifetimes.
An intuitive basis for this hypothesis is that if
this were not true, an application that
continuously allocates dynamic memory
would have unsustainable memory
requirements, as it would keep creating objects
Figure 1. 2D-GC Diagram
of prolific types at a fast pace without
reclaiming sufficient space. Put in another way,
III. DESIGN ISSUES OF 2D-GC the hypothesis predicts that the objects of
prolific types die younger than objects of non-
In the design of 2D-GC, several important and prolific types. Shuf et al. [20] validated this
interrelated challenges need to be solved: hypothesis and found that the relative survival
1. Object segregation. Object segregation is directly rates are usually lower for objects of prolific
related with object allocation. Objects are types than for objects of non-prolific types.
segregated based on lifetime classification. Short- We also found that most of the dead objects
lived objects are allocated in Gen-s and the rest and most of the garbage comes from short-
objects are allocated in Gen-o. We need a cost- lived objects of prolific types.
effective approach to classify objects into short- 2. Connected objects tend to die together. Hirzel
lived and non-short-lived. et al. [19] investigated the relationship
2. Heap organization. What is the optimal size ratio between lifetime and heap connectivity. They
between Gen-s and Gen-o? found that on average linked objects have a
3. Intergenerational pointers. Intergenerational very high probability (about 70-80.4%) of
pointers include pointers from the old generation dying at the same time.
to the young generation, and pointers between Our segregation scheme has two phases: the first phase is
Gen-s and Gen-o. How do we remember these coarse-grained classification phase; the second is refining
pointers? classification phase. The first phase use type-based lifetime
classification approach. Based on the first observation, we
A. Object Segregation can classify object types into short-lived types and non-short-
We can use several ways to differentiate short-lived and lived types based on their allocate rates. We compute
non-short-lived objects, varying in terms of accuracy and allocation rate of each object type periodically (here we
overhead. perform computation at each collection point). If the
One possible way is predicting object lifetimes based on allocation rate of an object type exceeds a certain threshold,
allocation-site by using online profiling [12][13] or online then this type will be treated as short-lived type, or else
sampling [21]. Most recent research indicated a strong treated as non-short-lived type. All objects of short-lived
correlation between allocation-sites and object lifetimes. In types will be assumed as short-lived objects and others will
online profiling, a runtime system monitors memory be non-short-lived objects.
activities at each allocation site. When an application exits, However, type-based lifetime classification is too strict
the collected profile is saved into a file. By analyzing the and error-prone. For example, objects of long-lived types
profile, we generate an advice file which classifies allocation might die young because they are linked to short-lived
sites into short-lived sites (i.e., the sites whose objects are objects. Therefore, we use connectivity-based lifetime
V2-631
2011 3rd International Conference on Computer Modeling and Simulation (ICCMS 2011)
Note that these two rules cannot be applied at the same Ephemeral
10 0 20
GC
time because they might fail at the situation shown in Figure
4. In Figure 4, o1 and o2 are allocated at time 1. Assume we GC without
know o1 is short-lived and o2 is long-lived. Then o3 is tenuring 4 10 30
allocated at the same time and later both o1 and o2 point to threshold
o3. By rule 1, o3 should be most likely short-lived. By rule 2,
however, o3 should be most likely long-lived. Therefore, we GC with
set different priority levels to these two rules. By default, enlarged
4 10 20
rule 2 has higher priority than rule 1. generation
size
2D-GC 4 0 20
V. RELATED WORK
Blackburn et al. [15][16] used the profile-based approach
to select objects for pretenuring. They classified objects into
three different classes: short lived, long lived, and immortal
based on two measures: age and time of death. The proposed
method was to provide the statically-analyzed object
information to the compiler so that the optimal object
When using connectivity-based lifetime classification to
allocation site could be determined at runtime.
segregate objects, we encounter another difficulty: when an
Jump and Blackburn et al. [21] introduced a low-
object is allocated, its future connectivity information is not
overhead object sampling technique to dynamically
known a priori. This is a dilemma: we need the object's
pretenure long-lived objects. The sampling technique can
connectivity information to predict its lifetime and allocate it
accurately predict allocation site survival rates. Their
to a proper space (Gen-s or Gen-o); but connectivity can only
approach cannot attain the consistent performance
be established after its allocation. Fortunately, we can
improvement on SPECjvm98 benchmarks. So they leave
capture partial connectivity information from calling context
open optimization policies that can benefit from lifetime
before the object's allocation. For example, if o2 is allocated
sampling.
within o1's method call, then o1 will be connecting to o2
Huang et al. extended the aforementioned work by
indirectly. Actually, we do not need the thorough
maintaining online lifetime history based on the object type
connectivity information of an object, because it will be
to adaptively select which objects are to be pretenured. They
costly and have little help to improve the accuracy of lifetime
found a strong correlation between an object type and its
classification.
lifespan. Depending on the nature of the applications, some
object types are by default long-lived. They claimed that by
V2-632
2011 3rd International Conference on Computer Modeling and Simulation (ICCMS 2011)
V2-633
2011 3rd International Conference on Computer Modeling and Simulation (ICCMS 2011)
[16] S. M. Blackburn, M. Hertz, K. S. McKinley, E. J. B. Moss, and T. [20] Y. Shuf, M. Gupta, R. Bordawekar, and J. Pal Singh. Exploiting
Yang, "Profile-based pretenuring," ACM Transactions on prolific types for memory management and optimizations. SIGPLAN
Programming Languages and Systems, vol. 27, iss. 1, 2007. Not. 37, 295-306.
[17] S. M. Blackburn, P. Cheng, and K. S. McKinley, "Myths and [21] M. Jump, S. M. Blackburn, and K. S. McKinley, "Dynamic Object
Realities: The Performance Impact of Garbage Collection," in Sampling for Pretenuring," in The 2004 International Symposium on
SIGMETRICS Performance 2004, Joint International Conference Memory Management (ISMM 2004), Vancouver, Canada, October
on Measurement and Modeling of Computer Systems, New York, NY, 24-25, 2004.
USA, June 1216, 2004, 2004. [22] F. Xian, W. Srisa-an, H. Jiang. MicroPhase: Proactively Invoking
[18] S. M. Blackburn, R. Garner, C. Hoffmann, A. M. Khang, K. S. Garbage Collection for Improved Performance. In Proceedings of
McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. ACM SIGPLAN Conference on Object-Oriented Programming,
Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. Eliot, B. Moss, A. Systems, Languages and Applications (OOPSLA'07), Montreal,
Phansalkar, D. Stefanovic, T. VanDrunen, D. von Dincklage, and B. Canada. Oct 21-25.
Wiedermann, "The DaCapo benchmarks: Java benchmarking [23] F. Xian, W. Srisa-an, C. Jia, H. Jiang. "AS-GC: An Efficient
development and analysis," in OOPSLA 06: Proceedings of the 21st Generational Garbage Collector for Java Application Servers". In
annual ACM SIGPLAN conference on Object-oriented programming Proceedings of 21st European Conference on Object-Oriented
systems, languages, and applications, New York, NY, USA, 2006, pp. Programming (ECOOP'07), Berlin, Germany. July 30-Aug 03, 2007.
169-190.
[24] F. Xian, W. Srisa-an, H. Jiang. "Investigating Throughput
[19] M. Hirzel, A. Diwan, and M. Hertz. Connectivity-based garbage Degradation Behavior of Java Application Servers: A View from
collection. In Proceedings of the 18th ACM Conference on Object- Inside a Virtual Machine". In Proceedings of ACM International
Oriented Programming, Systems, Languages, & Applications Conference on Principles and Practices of Programming In Java
(Anaheim, CA, Oct. 2003), pp. 359373. (PPPJ'06), Mannheim, Germany, Aug 30-Sep 1, 2006, Page 40-49.
V2-634