Java Virtual Machine for Resource Constrained
Total Page:16
File Type:pdf, Size:1020Kb
The Pennsylvania State University The Graduate School Department of Computer Science and Engineering JAVA VIRTUAL MACHINE FOR RESOURCE CONSTRAINED ENVIRONMENTS A Thesis in Computer Science and Engineering by Guangyu Chen c 2006 Guangyu Chen Submitted in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy August 2006 ∗ The thesis of Guangyu Chen was reviewed and approved by the following: Mahmut T. Kandemir Associate Professor of Computer Science and Engineering Thesis Adviser Chair of Committee Mary J. Irwin Professor of Computer Science and Engineering Soundar R. T. Kumara Professor of Industrial and Manufacturing Engineering Kenan Unlu Professor of Mechanical and Nuclear Engineering Vijaykrishnan Narayanan Associate Professor of Computer Science and Engineering Graduate Program Officer of Computer Science and Engineering Department ∗ Signatures are on file in the Graduate School. iii Abstract Java-enabled mobile phones are dominating today’s market. Java is becoming the lan- guage of choice for personal mobile information devices such as smart phones and PDAs. This great success can be attributed to several factors, including portability, safety, ease of program- ming, and mature developer community. Java Virtual Machine (JVM) is the key component of Java technologies; its quality, in terms of energy efficiency, memory requirement, performance and reliability, has critical impact on the future success of Java technologies in the market of personal information devices. This thesis addresses the four critical issues in the design of a Java Virtual Machine for resource constrained devices: improving energy efficiency, reducing memory requirements, improving performance, and enhancing reliability. iv Table of Contents List of Tables ...................................... x List of Figures ...................................... xi Acknowledgments .................................... xiv Chapter 1. Introduction ................................ 1 1.1 Java Virtual Machine for Resource Constrained Systems .......... 1 1.2 Contribution of the Thesis .......................... 3 1.2.1 Improving Energy Efficiency ..................... 3 1.2.2 Reducing Memory Footprint ..................... 4 1.2.3 Improving Performance . ...................... 5 1.2.4 Enhancing Reliability . ...................... 6 1.3 Organization of the Thesis .......................... 6 I Energy Aware Optimizations 7 Chapter 2. Tuning Garbage Collection for Reducing Memory System Energy ..... 8 2.1 Introduction . ................................. 8 2.2 KVM and Mark-and-Sweep Garbage Collector ............... 9 2.3 Experimental Setup . ........................... 12 2.3.1 Banked Memory Architecture .................... 12 2.3.2 Energy Models . ........................... 14 2.3.3 Benchmark Codes and Heap Footprints ............... 16 2.4 Energy Characterization and Optimization . ................ 18 2.4.1 Base Configuration .......................... 18 2.4.2 Impact of Mode Control . ...................... 21 2.4.3 Impact of Garbage Collection Frequency . ........... 22 2.4.4 Impact of Object Allocation Style . ................ 26 2.4.5 Impact of Compaction . ...................... 28 2.4.6 Impact of Number of Banks and Heap Size . ........... 33 2.4.7 Impact of Cache Memory ...................... 35 2.5 Concluding Remarks . ........................... 36 v Chapter 3. Energy Aware Adaptive Garbage Collection ................ 39 3.1 Introduction . ................................. 39 3.2 Experimental Setup . ........................... 42 3.3 Experimental Results . ........................... 43 3.3.1 Heap Energy . ........................... 43 3.3.2 Overall Energy . ........................... 46 3.3.3 Execution Profiles .......................... 46 3.3.4 Performance Behavior . ...................... 48 3.3.5 Bank Size Variations . ...................... 48 3.3.6 Heap Size Variations . ...................... 50 3.4 Related Work on Garbage Collection and Memory Energy Optimization . 52 3.5 Concluding Remarks . ........................... 53 Chapter 4. Reducing Energy Consumption by Memory Compression ......... 54 4.1 Introduction . ................................. 54 4.2 SoC Architecture ............................... 55 4.3 Compressing KVM Code and Class Libraries ................ 57 4.4 Simulation Methodology ........................... 60 4.4.1 Energy Model . ........................... 60 4.4.2 Base Configuration and Energy Distribution . ........... 61 4.5 Results ..................................... 61 4.5.1 Sensitivity to the Decompression Cost ................ 63 4.5.2 Sensitivity to the SPM Size ...................... 65 4.5.3 Sensitivity to the Block Size ..................... 66 4.5.4 Selective Compression . ...................... 67 4.5.5 Clustering ............................... 69 4.6 Concluding Remarks . ........................... 70 Chapter 5. Offloading Computation/Compilation ................... 71 5.1 Introduction . ................................. 71 5.2 Target Platform and Benchmarks . ...................... 75 5.3 Analysis of Execution and Compilation Strategies . ........... 80 5.3.1 Analysis of Static Strategies ..................... 81 5.3.2 Analysis of the Adaptive Execution Strategy . ........... 82 5.3.3 Analysis of Adaptive Compilation Strategy . ........... 91 5.3.4 Using Reconfigurable Datapath to Optimize Local Execution .... 92 5.3.5 Using Data Compression to Optimize of Remote Execution .... 95 5.4 Related Work ................................. 96 5.5 Concluding Remarks . ........................... 99 vi II Memory Footprint Reduction 100 Chapter 6. Heap Compression for Reducing Memory Footprint ............ 101 6.1 Introduction . ................................. 101 6.2 Implementation Details . ........................... 104 6.2.1 Indirect Object References ...................... 104 6.2.2 Compression . ........................... 105 6.2.3 Decompression . ........................... 108 6.2.4 Breaking Down Large Objects .................... 111 6.2.5 Lazy Allocation . ........................... 112 6.3 Benchmarks and Experimental Setup ..................... 114 6.4 Experimental Results . ........................... 115 6.4.1 Reduction in Heap Space Demand . ................ 115 6.4.2 Compression/Decompression Behavior ............... 118 6.4.3 Performance Impact . ...................... 125 6.5 Aggressive Object Compression . ...................... 127 6.6 Eliminating Object Handles .......................... 130 6.7 Discussion and Future Work . ...................... 134 6.8 Concluding Remarks . ........................... 138 Chapter 7. Exploiting Frequent Field Values in Java Objects .............. 140 7.1 Introduction . ................................. 140 7.2 Frequent Field Value Characterization .................... 140 7.2.1 Experimental Setup .......................... 141 7.2.2 Existence of Frequent Field Values . ................ 141 7.2.3 Opportunities for Storage Optimizations ............... 143 7.3 Our Compression Approach . ...................... 145 7.3.1 Determining the Level of Each Field . ................ 146 7.3.2 Scheme-1: Eliminating Level-2 Fields ................ 148 7.3.3 Scheme-2: Sharing Level-1 Fields . ................ 150 7.4 Experimental Results . ........................... 154 7.4.1 Baseline Results ........................... 154 7.4.2 Sensitivity Analysis . ...................... 159 7.4.2.1 Impact of the Field Selection Scheme ........... 159 7.4.2.2 Robustness of the Profiling-Based Approach . ..... 160 7.5 Concluding Remarks . ........................... 160 vii Chapter 8. Field Level Analysis for Heap Space Optimization ............. 162 8.1 Introduction . ................................. 162 8.2 Experimental Setup . ........................... 163 8.3 Field Access Characterization . ...................... 164 8.3.1 Field Lifetime Analysis . ...................... 164 8.3.1.1 Life Cycle of Java Instances ................ 164 8.3.1.2 Idle Field Ratio of Java Instances . ........... 165 8.3.1.3 Potential of Lifetime-Aware Space Optimization ..... 165 8.3.1.4 Determining the Last Access Time . ........... 169 8.3.1.5 Allocation Site Based Analysis . ........... 171 8.3.2 Disjointness Analysis . ...................... 173 8.3.2.1 Using Unions in Java . ................ 173 8.3.2.2 Memory Saving Potential of Using Unions . ..... 175 8.3.2.3 Allocation Site Based Analysis . ........... 177 8.4 Realizing Memory Savings .......................... 177 8.5 Related Work ................................. 184 8.6 Concluding Remarks . ........................... 188 III Reliability and Security 190 Chapter 9. Transient Error Tolerance ......................... 191 9.1 Introduction . ................................. 191 9.2 Implementation ................................ 193 9.2.1 Object Model . ........................... 193 9.2.2 Object Sharing . ........................... 194 9.2.3 Checkpointing and Rolling Back . ................ 195 9.2.4 Garbage Collection .......................... 196 9.2.4.1 Local Collector ...................... 198 9.2.4.2 Global Collector ...................... 199 9.2.5 Handling Non-Dual-Executable Methods . ........... 201 9.2.6 Scheduling Java Threads . ...................... 204 9.3 Experiments . ................................. 204 9.3.1 Experimental Setup .......................... 204 9.3.2 Experimental Results . ...................... 205 9.4 Related Work ................................. 207 9.5 Concluding Remarks . ..........................