Object Field Analysis for Heap Space Optimization ISMM 2004 G. Chen, M. Kandemir, N. Vijaykrishnanan and M. J. Irwin The Pennsylvania State University.

Slides:



Advertisements
Similar presentations
1 A Hybrid Adaptive Feedback Based Prefetcher Santhosh Verma, David Koppelman and Lu Peng Louisiana State University.
Advertisements

1 Overview Assignment 5: hints  Garbage collection Assignment 4: solution.
Zhiguo Ge, Weng-Fai Wong, and Hock-Beng Lim Proceedings of the Design, Automation, and Test in Europe Conference, 2007 (DATE’07) April /4/17.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
1 Error-Free Garbage Collection Traces: How to Cheat and Not Get Caught ACM SIGMETRICS, 2002.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
Guoquing Xu, Atanas Rountev Ohio State University Oct 9 th, 2008 Presented by Eun Jung Park.
1 S. Tallam, R. Gupta, and X. Zhang PACT 2005 Extended Whole Program Paths Sriraman Tallam Rajiv Gupta Xiangyu Zhang University of Arizona.
Heap Shape Scalability Scalable Garbage Collection on Highly Parallel Platforms Kathy Barabash, Erez Petrank Computer Science Department Technion, Israel.
Mark-Compact Sweep Garbage Collection & Automatic Heap Resizing: A Valuable Combination.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Trace-Based Automatic Parallelization in the Jikes RVM Borys Bradel University of Toronto.
OOPSLA 2003 Mostly Concurrent Garbage Collection Revisited Katherine Barabash - IBM Haifa Research Lab. Israel Yoav Ossia - IBM Haifa Research Lab. Israel.
Inside the KVM Real-Time Java Team University of Pennsylvania.
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002.
Age-Oriented Concurrent Garbage Collection Harel Paz, Erez Petrank – Technion, Israel Steve Blackburn – ANU, Australia April 05 Compiler Construction Scotland.
C and Data Structures Baojian Hua
1 Utilizing Field Usage Patterns for Java Heap Space Optimization Z. Guo, N. Amaral, D. Szafron and Y. Wang Department of Computing Science University.
Lecture 9: SHELL PROGRAMMING (continued) Creating shell scripts!
Reference Counters Associate a counter with each heap item Whenever a heap item is created, such as by a new or malloc instruction, initialize the counter.
Memory Layout C and Data Structures Baojian Hua
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Page 1 © 2001 Hewlett-Packard Company Tools for Measuring System and Application Performance Introduction GlancePlus Introduction Glance Motif Glance Character.
Exploiting Prolific Types for Memory Management and Optimizations By Yefim Shuf et al.
Tutorial 6 Memory Management
D2Taint: Differentiated and Dynamic Information Flow Tracking on Smartphones for Numerous Data Sources Boxuan Gu, Xinfeng Li, Gang Li, Adam C. Champion,
Tutorial 7 Memory Management presented by: Antonio Maiorano Paul Di Marco.
Dynamic Memory Allocation Questions answered in this lecture: When is a stack appropriate? When is a heap? What are best-fit, first-fit, worst-fit, and.
Lecture 10 : Introduction to Java Virtual Machine
Roopa.T PESIT, Bangalore. Source and Credits Dalvik VM, Dan Bornstein Google IO 2008 The Dalvik virtual machine Architecture by David Ehringer.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
CMPE 511 Computer Architecture A Faster Optimal Register Allocator Betül Demiröz.
1 Fast and Efficient Partial Code Reordering Xianglong Huang (UT Austin, Adverplex) Stephen M. Blackburn (Intel) David Grove (IBM) Kathryn McKinley (UT.
Conrad Benham Java Opcode and Runtime Data Analysis By: Conrad Benham Supervisor: Professor Arthur Sale.
Dynamic Object Sampling for Pretenuring Maria Jump Department of Computer Sciences The University of Texas at Austin Stephen M. Blackburn.
1 Tuning Garbage Collection in an Embedded Java Environment G. Chen, R. Shetty, M. Kandemir, N. Vijaykrishnan, M. J. Irwin Microsystems Design Lab The.
Java Security Model For Mobile Code Abdo Achkar. Mobile Code A mobile object is a “self contained piece” of executable code. Definition:  Code that can.
Mark Marron 1, Deepak Kapur 2, Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico 1.
1 Advanced Memory Management Techniques  static vs. dynamic kernel memory allocation  resource map allocation  power-of-two free list allocation  buddy.
1 Recursive Data Structure Profiling Easwaran Raman David I. August Princeton University.
Challenges and Solutions for Embedded Java Michael Wortley Computer Integrated Surgery March 1, 2001.
Dynamic Analysis and Visualizing of Data Structures in Java Programs Presented by Sokhom Pheng (Supervisor: Clark Verbrugge) McGill University February.
Department of Computer Sciences ISMM No Bit Left Behind: The Limits of Heap Data Compression Jennifer B. Sartor* Martin Hirzel †, Kathryn S. McKinley*
Heap liveness and its usage in automatic memory management Ran Shaham Elliot Kolodner Mooly Sagiv ISMM’02 Unpublished TVLA.
Pointer and Escape Analysis for Multithreaded Programs Alexandru Salcianu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
LECTURE 13 Names, Scopes, and Bindings: Memory Management Schemes.
® July 21, 2004GC Summer School1 Cycles to Recycle: Copy GC Without Stopping the World The Sapphire Collector Richard L. Hudson J. Eliot B. Moss Originally.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Lecture #20: Profiling NetBeans Profiler 6.0.
Reference Counting. Reference Counting vs. Tracing Advantages ✔ Immediate ✔ Object-local ✔ Overhead distributed ✔ Very simple Trivial implementation for.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java Author: Fridtjof Siebert, CASES 2000 Michael Sallas Object-Oriented Languages.
Object Lifetime and Pointers
Multitasking without Compromise: a Virtual Machine Evolution
Cork: Dynamic Memory Leak Detection with Garbage Collection
No Bit Left Behind: The Limits of Heap Data Compression
Compositional Pointer and Escape Analysis for Java Programs
Concepts of programming languages
Improving java performance using Dynamic Method Migration on FPGAs
Spare Register Aware Prefetching for Graph Algorithms on GPUs
Storage.
Hui Chen, Shinan Wang and Weisong Shi Wayne State University
Adaptive Code Unloading for Resource-Constrained JVMs
No Bit Left Behind: The Limits of Heap Data Compression
Garbage Collection Advantage: Improving Program Locality
COMP755 Advanced Operating Systems
Run-time environments
Reference Counting.
Presentation transcript:

Object Field Analysis for Heap Space Optimization ISMM 2004 G. Chen, M. Kandemir, N. Vijaykrishnanan and M. J. Irwin The Pennsylvania State University

Spectrum of Java Technologies From KVM White Paper (Sun Microsystems)

Heap Occupancy and Garbage Collection Size Heap Size Time Max Occupancy GC Total size of reachable objects Total size of allocated objects

Life Cycle of a Java Object o.f 4 o.f 3 o.f 2 o.f 1 o.f 0 Time Allocation First access Last access Last reference removed Garbage collected Drag Lifetime of object o Dead Field [Rojemo and Runcima 96], [Shaham et al. 2001]

Drag Time Reduction and Lazy Allocation Size Heap Size Time Max Occupancy GC Remove references to objects as soon as possible Allocate objects as late as possible Can we go further?

Life Cycle of the Fields o.f 4 o.f 3 o.f 2 o.f 1 o.f 0 Lifetime of o.f 4 Time Allocation First access Last access Last reference removed Garbage collected Drag Lifetime of object o Dead Field

Field Lifetime Aware Memory Management Manage the memory space in the granularity of fields – Allocate each field lazily – Allow collecting the fields that have been last accessed How much space can we save by managing the memory space in the granularity of fields? Can these potential savings be realized? – Possible for some applications

Experimental Setup Spec JVM98 Benchmarks Instrumented Kaffe VM Object Access Trace Trace Analyzer

Idle Field Ratio F4 F3 F2 F1 F0 Time Field lifetime Field idle time Lifetime of the Object Field Idle Field Ration = Percentage of the idle area How efficient an object uses the memory space when management the heap at the object level?

Idle Field Ratio Definition: idle field ratio of object o – l i : the length of lifetime of the i th field of object o – L o : the length of the lifetime of object o – n : the number of fields of object o If most objects have low idle field ratio, field lifetime aware memory management is not worthwhile If most objects have high idle field ratio, field lifetime aware memory management might be worthwhile

CDF of Idle Field Ratio (x%, y%): y% of the objects have an idle field ratio higher than x%

Potential of Filed Lifetime Aware Optimizations Field Last Use (FLU) – collect the space for each field as soon as the field is last used Field First Use (FFU) – Lazily allocate the space for each field upon the first access to this field Field First-Last Use (FFL) – Combination of FLU and FFU

Footprint (Jess)

Footprint (Raytrace)

Filed Lifetime Aware Max. Heap Occupancy

Compared with Object Granularity Drag Time Reduction + Lazy Allocation (Max. Occupancy)

Determining Last Access

Idle Space-Time Product F4 F3 F2 F1 F0 Time Field lifetime Field idle time Lifetime of the Object Field Idle space-time product = the area of field idle time How much space can be saved for each object?

Allocation Site Based Analysis Idle space-time product for object o – r(o) : idle field ratio of object o – B o : size of object o – L o : length of lifetime of object o Idle space-time product for allocation s – A s : the set of the objects allocated by s

Idle Space-Time Product for Allocation Sites

Idle Space-Time Product for Allocation Sites (Raytrace)

Life Cycle of the Fields o.f 4 o.f 3 o.f 2 o.f 1 o.f 0 Lifetime of o.f 4 Time Allocation First access Last access Last reference removed Garbage collected Drag Lifetime of object o Dead Field Disjoint fields Read Write

Using Union Advantages: – Allow disjoint fields in an object to share the same memory location Disadvantages: – Not safe Considering an integer field shares the memory space with a pointer – Might introduce bugs Open question: is it worthwhile to incorporate union in Java?

Disjointness Analysis Step 1: Build interference graph for each allocation site – Each note represents a field – Edge (f 1, f 2 ): for at least one object that is allocated by this allocation site, the values of fields f 1 and f 2 should be kept in the memory simultaneously Step 2: Combine interference graphs for the allocation sites that have the same accessing site Step 3: Determine object format for each allocation site Step 4: Evaluate memory savings

Disjointness Analysis – Example (1) (s 1 ) o = new C(…) (s 2 ) o = new C(…) (s 3 ) o = new C(…) (a 1 ) … o.f 3 … (a 2 ) … o.f 3 …

Disjointness Analysis – Example (2) f1f1 f2f2 f3f3 f4f4 f1f1 f2f2 f3f3 f4f4 f1f1 f2f2 f3f3 f4f4 f 1, f 2, f 3 f4f4 f 1, f 2 f 3, f 4 f 1, f 3, f 4 f2f2 Interference Graph Union s1s1 s2s2 s3s3 (a 1 ) … o.f 3 … (a 2 ) … o.f 3 … Check object format at runtime

Disjointness Analysis – Example (3) f1f1 f2f2 f3f3 f4f4 f 1, f 2 f3f3 f4f4 f 1, f 3, f 4 f2f2 Combined Interference Graph Union s1s1 s2s2 s3s3 (a 1 ) … o.f 3 … (a 2 ) … o.f 3 … f1f1 f2f2 f3f3 f4f4 2 f 1, f 2 f3f3 f4f

Space Saving Potential of Using Unions Max. Occupancy

Space Saving Potential of Using Unions Allocation Site Analysis (Jess)

Space Saving Potential of Using Unions Allocation Site Analysis (Raytrace)

Components for Realizing Memory Savings A mechanism to dynamically expand/shrink the format of object instances An analysis strategy to identify last use points of each fields A mechanism for safe employment of field unions An analysis strategy to identify the disjointness of fields of the same object

Example – Jess public class Value { int _type; int intval; double floatval; Object Objectval; public Value(int v) { _type = INTEGER; intval = v; } public Value(double v) { … … } public Value (Object v) { … … } public class Value { public static class IntValue extends Value { int intval; public IntValue(int v) { intval = v; } public static class FloatValue extends Value { double floatval; } public static class ObjectValue extends Value { Object Objectval; }

Example – Raytrace Public class OctNode { OctNode[ ] Adjacent; Face[ ] OctFace; OctNode[ ] Child; ObjNode ObjList; int NumObj; … … } Public class OctNode { OctNode[ ] Adjacent; Face[ ] OctFace; public class OctNode1 extends OctNode { OctNode[ ] Child; } public class OctNode2 extends OctNode { ObjNode ObjList; int NumObj; }

Conclusions We investigate two related issues: – The potential benefits of managing the heap space at a granularity that is smaller than an entire object – The challenges for implementing a heap space management strategy dealing with entities that are smaller than an object We present the results of two analyses: – Field-level lifetime analysis – Field-level disjointness analysis

Thank you!

Why Java? Cross-platform Compatibility – Especially important for the highly fragmented mobile device market Enhanced user experiences – Rich GUI support – Dynamically downloading third-party applications Security Mature developer community

Challenges Slow CPU (compared to high end systems) Limited energy supply – Powered by batteries Stringent memory budget – 0.5 ~ 2 MB RAM – The available memory is increasing rapidly, but… More energy consumption Higher price Memory hungry new applications

Memory Components of JVM Text Segment C code of KVM Heap Loaded classes, Objects, Java exec stacks, … C-Stack Data Segment C variables, Preloaded Class Lib 93KB 124KB 32KB 1~2MB

Filed Lifetime Aware Average Heap Occupancy

Compared with Object Granularity Drag Time Reduction + Lazy Allocation (Ave. Occupancy)

Space Saving Potential of Using Unions Average Occupancy