Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.

21
Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.

Transcript of Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.

Exploiting Prolific Types for Memory Management and

Optimizations By Yefim Shuf et al.

Roadmap

• What is prolific types?– Properties of prolific types

• Applications– Type-based garbage collection– Reducing memory consumed by objects– Object co-allocation– Locality-based traversal

• Conclusions

Prolific Types

• Observation:– Relatively few object types usually account for

a large percentage of objects (and heap space)

• These frequently instantiated types are prolific types

• Others are non-prolific types

Identifying Prolific Types

• Offline profiling– Dump information in a file

• Adaptive approach– Collect info during execution– Sampling

• Compile-time– May be possible

Checking a Variable for Prolific Type

• Given “T o”– Object o is prolific if all subclasses of T are prolific– Need class hierarchy analysis

• Check added at compile time– Handle dynamic loading

• A simple heuristic– Prolific types are likely leaves or close to leaves

• Treat all children of prolific types as prolific

Application 1 :Type-based Memory Management

• Objects of prolific types have short lifetimes– Resemble nature: offspring of prolific species are often short-

lived

• Heap space partitioned into two regions– P-region: objects of prolific types– NP-region: objects of non-prolific types

• Collection– Perform frequent minor collection only in the P-region– In frequent full collection– Survivors of P-region collection stay in P-region

• Compared to generation collection

– Write barriers needed to remember pointer from NP-region to P-region

Additional Advantages

• Compile-time write barrier elimination– Eliminate barrier that are not pointing from NP

to P

• P-region Collection Processing– Only need to scan pointers to P-region

• Methods return two reference list– One full list– One partial list: references to prolific objects

Results: write barrier

Results: Throughput

Results: GC Times

Application 2: Short Type Pointers

• Observation: The number of prolific types is small– Mostly <= 16

• Application– Shorten object headers– Using a 4-bit field to encode TIB

• The value is an index to the table of real TIBs

Results: statistics on prolific types

Results: Space Saving

Application 3: Object Co-allocation

• Properties– Objects of prolific types tend to access together– The large number of prolific objects denote potential

benefit

• Co-allocate objects of prolific types– Improve spatial locality– Reduce GC times with improved GC-time locality– Reduce memory fragmentation

• Objects born together tend to die together

The Co-allocation Algorithm

• Create a directed graph– Nodes: types– Edges: from a (source) type to a type of the source’s reference

field• P-edge: prolific type to prolific type • NP-edge: non prolific type to non prolific-type• Others

• Co-allocation– Partition the graph into clusters– Each cluster is a set of nodes linked by P-edges– When one node (representative node) of a cluster is allocated,

reserve enough space for other nodes in cluster– In practice, each cluster consists of two nodes

Locality-based Traversal

• Divide heap into chunks

• Visit the objects in to same chunk before those in other chunks– Improve GC locality– Can improve locality when combined with a

copy collector

The Locality-based Traversal Algorithm

Implementation Issues

• Choice of chunk size– No bigger than the physical memory of a process

• Which chunk to collect first?– Last chunk allocated (may still in cache)

• Which pointer to choose from LP?– Choose an object close to the one visited recently

• Which chunk next?– With most reachable objects by sampling– A pointer into the chunk closest to the current chunk

Results: non-copy GC

Results: Copying GC

Conclusions

• Prolific type based GC perform better than a generational GC

• With encode prolific types, heap space reduced

• Proliflic objects co-allocation improve performance with non-copying GC

• Locality-based GC traversal has positive impacts on copying GC