210 likes | 220 Views
Utilizing Field Usage Patterns for Java Heap Space Optimization. Z. Guo, N. Amaral, D. Szafron and Y. Wang Department of Computing Science University of Alberta. Motivation. Java has become a popular platform for mobile and embedded systems. Prediction: 1.8 billion by 2008.
E N D
Utilizing Field Usage Patterns for Java Heap Space Optimization Z. Guo, N. Amaral, D. Szafron and Y. Wang Department of Computing Science University of Alberta
Motivation • Java has become a popular platform for mobile and embedded systems. • Prediction: 1.8 billion by 2008. • Mobile and embedded systems tend to be memory constrained: • Physics: device size, weight, power consumption. • Economics: price • Applications: multimedia streams, video games…
Motivation • Memory constraints make Java programs to execute slowly or even crash. • Many researches have been done to reduce the memory footprint of Java: • Runtime environment • Code • Data
Contribution • A study of the characteristics of the field usage patterns using the SpecJVM 98 benchmark. • New opportunities for space optimization. • A design of a heap compression mechanism.
Field Usage Patterns • A Java class has a set of fields with a fixed layout. • However, not all fields need be stored: • A number of fields have zero or null values. • Used fields often have frequent field values. • Optimization opportunities: • Scheme-1: eliminating zero or null fields. • Scheme-2: externalizing fields with frequent values.
Field-Usage Patterns • Instances of the same class often exhibit different field-usage patterns. • Definition: • The field usage pattern of an object is the set of fields used by the object. • Consider fields with frequent values: The field usage pattern of an object is the set of fields of the object that do not store frequent field values.
The SpecJVM 98 benchmark • Field usage pattern distributions (Scheme-1):
The SpecJVM 98 benchmark • Field usage pattern distributions (Scheme-2):
The SpecJVM 98 benchmark • Field usage pattern distributions:
The SpecJVM 98 benchmark • Summary: • Except raytrace, 80% instances are compressible using field usage patterns. • On average, each class is expected to have 2 to 3 fields with frequent values and its instances have 3 to 4 different field-usage patterns. • The 1st and 2nd most frequent field usage patterns account for a significant portion of field usage pattern occurrences. • Compressing non-zero frequent field values can dramatically benefit some programs, including jess and javac.
Existing Compression Mechanisms • LCTES 2003. C. S. Ananian and M. Rinard. • Use hash table to record non-frequent field values. • VEE 2005. G. Chen, M. Kandemir and M. J. Irwin • Only assume a single field-usage pattern for each class. • Extra space (one word) required for objects that do not have the single field-usage pattern.
An Example • In jess, a benchmark in the SpecJVM 98 suite, the class Value has four fields: _type, intval, floatval, and Objectval.
Our Mechanism • Comprehensive: exploits opportunities associated with multiple field-usage patterns per class. • Aggressive: eliminates all zero/null fields and fields with frequent values. • Low space overhead: requires extra space per field usage pattern, rather than per object.
Our Mechanism • Fields are classified into three levels: • Level-0: fields with no frequent values. • Level-1: fields with non-zero frequent values. • Level-2: fields with zero/null frequent values.
Our Mechanism • Bidirectional object layout
Our Mechanism • Meta-class
Performance Evaluation • Compression effectiveness (Scheme-1 max):
Performance Evaluation • Compression effectiveness (Scheme-2 max):
Performance Evaluation • Runtime overhead
Performance Evaluation • Summary: • Scheme-1 reduces the max heap space requirement by 12% on average. • Scheme-2 reduces the max heap space requirement by 14% on average. • A performance penalty 4.4% on average for scheme-2.