TL;DR
This paper introduces two novel Java Virtual Machine (JVM) techniques to significantly reduce heap memory usage in embedded and mobile devices by exploiting the observation that certain field values appear frequently across many objects. These methods achieve up to a 24% reduction in minimum heap size with minimal performance overhead, making Java applications more viable on resource-constrained platforms.
What Problem Does This Paper Address?
Embedded and mobile devices, while increasingly powerful, are fundamentally limited by memory size, cost, and power consumption. These constraints often lead to slow performance or outright crashes for applications, especially those written in memory-intensive languages like Java. While general-purpose compression techniques exist, they often treat memory as unstructured data, requiring full decompression for access and incurring significant overhead. This paper addresses the specific challenge of reducing Java heap memory requirements by leveraging the inherent redundancy within Java objects themselves, without requiring manual programmer intervention or complex application rewrites.
Methods
The core of this work lies in identifying and exploiting "frequent field values" – values that appear repeatedly in specific fields across multiple objects in the heap. The authors propose a two-stage approach:
- Field Classification:
- They first analyze Java applications (using the SpecJVM98 benchmark suite) to identify fields that exhibit a high frequency of specific values.
- This analysis is performed offline using an instrumented JVM.
- Fields are classified into three levels:
- Level-0: No dominant frequent value.
- Level-1: A non-zero (or non-null) frequent value.
- Level-2: A frequent value that is zero (or null).
- This classification is stored in "field description files" that the JVM uses at runtime.
- Object Compression Schemes:
- Scheme-1: Eliminating Level-2 Fields: This scheme focuses on fields classified as Level-2 (zero or null). It restructures objects so that Level-2 fields are stored in a separate, lazily allocated "secondary part." If all Level-2 fields within an object are zero, this secondary part can be entirely omitted, saving space.
- Scheme-2: Sharing Level-1 Fields: This scheme builds upon Scheme-1 by also addressing Level-1 fields (non-zero frequent values). It allows multiple objects with identical Level-1 field values to share a single secondary part, further reducing memory footprint. Objects can be compressed (Level-2 fields removed) or shared (Level-1 fields shared).
The JVM dynamically manages these compressed and shared object formats, with garbage collection playing a role in reclaiming space from uncompressed objects with zeroed Level-2 fields.
Datasets
The primary dataset used for analysis and evaluation is the SpecJVM98 benchmark suite. This suite consists of eight Java programs, and the authors used two input sets, s1 and s10, for their characterization. They also mention using a trace-based simulator to evaluate the memory behavior of a JVM.
Key Insights and Ideas
- Field-Level Redundancy is Significant: The most surprising and impactful insight is the sheer prevalence of frequent field values. The authors demonstrate that for many fields, a single value accounts for a substantial portion (often around 90%) of occurrences. This is a rich source of redundancy that can be exploited.
- Zero/Null Fields are Prime Targets: Level-2 fields (zero or null) are particularly attractive for compression because they can be entirely eliminated from an object's representation when they hold their frequent value.
- Sharing is Caring (for Memory): Scheme-2's ability to allow multiple objects to share common Level-1 field data is a powerful extension, demonstrating that object-level similarity can be leveraged beyond just individual field values.
- Offline Profiling is Sufficient: The authors show that profiling with a typical input set (
s1) is largely sufficient to determine field classifications, and these classifications remain effective even when the application is run with a different input set (s10), highlighting the robustness of their approach. - JVM-Aware Compression is Key: Unlike manual optimizations or generic compression, these techniques are integrated into the JVM, allowing for transparent and efficient memory management without programmer burden.
Key Results
- Heap Size Reduction: The proposed schemes achieved significant reductions in minimum heap size:
- Scheme-1: Up to 24% reduction (14% on average) for instances.
- Scheme-2: Up to 38% reduction for instances and 14% on average when including arrays.
- Performance Overhead: The performance overhead was minimal, with Scheme-1 incurring less than 3.7% extra execution cycles and Scheme-2 generally staying within a few percentage points (around 4.2% on average when considering instruction counts and memory accesses). This is crucial for embedded systems where performance is critical.
- User-Level Optimization Comparison: The paper also evaluated user-level optimizations (e.g., making fields static) and found that their JVM-integrated schemes can provide further savings on top of these.
Limitations and Future Work
- Profiling Accuracy: The authors acknowledge that profiling results may not be 100% accurate for all executions, especially if the input data changes drastically. However, they demonstrate that the impact on performance and savings is manageable.
- Shared Object Granularity: Scheme-2 currently only allows objects of the same class to share secondary parts. Future work could explore sharing across different classes.
- Performance Estimation: The performance overheads are estimated based on instruction counts and memory accesses. While this is a reasonable approach for embedded systems, more direct hardware measurements could provide even greater accuracy.
- Garbage Collection Interaction: The interaction between compression and garbage collection algorithms could be further explored for potential optimizations.
- Field Selection Scheme: The paper briefly discusses an alternative "product-based" field selection scheme but concludes the "minimum-based" (default) scheme is superior. Further investigation into optimal field selection strategies could be beneficial.
Summary updated