Departamento de Computación Facultad de Ciencias Exactas y Naturales Universidad de Buenos Aires (UBA) (*) VERIMAG, France. Currently visiting UBA. 1.

Slides:



Advertisements
Similar presentations
E-science grid facility for Europe and Latin America Marcelo Risk y Juan Francisco García Eijó Laboratorio de Sistemas Complejos Departamento.
Advertisements

E-science grid facility for Europe and Latin America Marcelo Risk y Juan Francisco García Eijó Laboratorio de Sistemas Complejos Departamento.
Menéndez, Re & Kind Flood risk maps & salinity front FACULTAD DE INGENIERÍA UNIVERSIDAD DE BUENOS AIRES REGIONAL AIACC WORKSHOP Buenos Aires, Argentina.
Code Tuning Techniques CPSC 315 – Programming Studio Fall 2008 Most examples from Code Complete 2.
As I see it. Eric AUTOMATIC Just another day in he office.
Understand the Storm: France-Mexico and Puerto Rico Prof. Elizabeth Torres Rodriguez- Puerto Rico Prof. Yves Darbarie- France Prof. Gloria Elena Faus-
The Fundamental Rule for Testing Methods Every method should be tested in a program in which every other method in the testing program has already been.
Memory Management & Method Calls in Java Program Execution © Allan C. Milne v
Informática II Prof. Dr. Gustavo Patiño MJ
1/03/09 De 89 à 98. 1/03/09 De 89 à 98 1/03/09 De 89 à 98.
Stopping, straggling and inner-shell ionization within the shellwise local plasma approximation C. C. Montanari and J. E. Miraglia Instituto de Astronomía.
CS 536 Spring Automatic Memory Management Lecture 24.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
DEPENDEX 1Synthesis of parametric specifications of dynamic memory utilization. BGY. FTFJP'05 Synthesizing parametric specifications of dynamic memory.
Objectives Learn about objects and reference variables Explore how to use predefined methods in a program.
Projection of future climate change conditions using IPCC simulations, neural networks and Bayesian statistics. Temperature and Precipitation mean state.
Vehicle dynamics simulation using bond graphs
Run-Time Storage Organization
WISDNA: An Information Visualization Paradigm for XML Ricardo Baeza-Yates, Ricardo Lemus, Dulce Ponceleon, Savitha Srinivasan Presented by Ricardo Lemus.
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
Garbage collection (& Midterm Topics) David Walker COS 320.
PREDICCIÓN DE ESTRUCTURAS DE CRISTALES CON MOLÉCULAS FLEXIBES EN SU CELDA V. Bazterra, M. B. Ferraro, J. C. Facelli Departamento de Física Facultad de.
Linked lists and memory allocation Prof. Noah Snavely CS1114
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
Garbage Collection and High-Level Languages Programming Languages Fall 2003.
Characterization of GEM detectors, and the way there… Rodrigo G. Cortiñas CERN, Summer Student Program 2013 Universidad de Buenos Aires, Facultad de Ciencias.
Dynamic Memory Allocation Conventional array and other data declarations An incorrect attempt to size memory dynamically Requirement for dynamic allocation.
E-science grid facility for Europe and Latin America Marcelo Risk y Juan Francisco García Eijó Laboratorio de Sistemas Complejos Departamento.
Object Oriented Methods for Software Development The OO-Method Group Departamento de Sistemas Informáticos.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
Computer Science Topical Paper Presentation #12 Mark Pfeffer Pooling P a t t e r n P o o l i n g – P a g e 1 by Michael Kircher, Prashant Jain.
Introduction to Client Side Scripting CS Client Side Scripting Client side means the Browser is interpreting the script Script is downloaded with.
Copyright © Curt Hill Structured Data What this course is about.
Chapter 7 Pointers: Java does not have pointers. Used for dynamic memory allocation.
Copyright © Genetic Computer School 2008 Computer Systems Architecture SA 7- 0 Lesson 7 Memory Management.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
CSI 3125, Preliminaries, page 1 Class. CSI 3125, Preliminaries, page 2 Class The most important thing to understand about a class is that it defines a.
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
Lecture 10 Page 1 CS 111 Online Memory Management CS 111 On-Line MS Program Operating Systems Peter Reiher.
Visit:
。 33 投资环境 3 开阔视野 提升竞争力 。 3 嘉峪关市概况 。 3 。 3 嘉峪关是一座新兴的工业旅游城市,因关得名,因企设市,是长城文化与丝路文化交 汇点,是全国唯一一座以长城关隘命名的城市。嘉峪关关城位于祁连山、黑山之间。 1965 年建市,下辖雄关区、镜铁区、长城区, 全市总面积 2935.
What Do Computers Do? A computer system is
Topic: Java Garbage Collection
Unit-2 Objects and Classes
Understand the Storm Prof. Elizabeth Torres Rodriguez- Puerto Rico
Seminar in automatic tools for analyzing programs with dynamic memory
Storage Management.
University of Central Florida COP 3330 Object Oriented Programming
malloc(): Dynamic Memory Management
Godrej Prakriti Sodepur | Godrej Prakriti Kolkata
Runtime Analysis of Hotspot Java Virtual Machine
Led T-shirts Collection at ShoppyZip.
Real-time Software Design
Giftalove Best Cake Offers
Henning Schulzrinne Advanced Programming
Lecture 4: Process Memory Layout
Oral Health Comparison In Special Schools Using Cloud- Based Charting Tools Carrera de Odontología, Facultad de Ciencias de la Salud, Universidad Católica.
مدیریت استراتژيک منابع انسانی
Smart Pointers.
Scope, Visibility, and Lifetime
أنماط الإدارة المدرسية وتفويض السلطة الدكتور أشرف الصايغ
Object-Oriented Programming Paradigm
Ռազմավարական կառավարում
Sketchs characterization and compression for nomadic computing
C H A P T E R F I V E Memory Management.
point when a program element is bound to a characteristic or property
LANGUAGE EDUCATION.
RESEARCHING ABOUT SOR MARCELA DE SAN FÉLIX.
Automating Memory Management
Visit us:
Presentation transcript:

Departamento de Computación Facultad de Ciencias Exactas y Naturales Universidad de Buenos Aires (UBA) (*) VERIMAG, France. Currently visiting UBA. 1

 Context: Java like languages  Object orientation  Automatic memory management (GC)  Predicting amount of memory allocations is very hard  Problem undecidable in general ▪ Impossible to find an exact expression of dynamic memory requested, even knowing method parameters  Predicting actual memory requirements is harder  Memory is recycled ▪ Unused objects are collected ▪  memory required <= memory requested/allocated 2

How much memory is required to run m0? void m0(int mc) { 1: m1(mc); 2: B[] m2Arr=m2(2 * mc); } void m1(int k) { 3: for (int i = 1; i <= k; i++){ 4: A a = new A(); 5: B[] dummyArr= m2(i); } B[] m2(int n) { 6: B[] arrB = new B[n]; 7: for (int j = 1; j <= n; j++) { 8: arrB[j-1] = new B(); 9: C c = new C(); 10: c.value = arrB[j-1]; } 11: return arrB; } m0(2) m0(7) 3 ret m1

 An expression over-approximating the peak amount of memory consumed using an ideal memory manager  Parametric  Easy to evaluate  E. g. :Required(m)(p1,p2) = 2p 2 + p1  Evaluation cost known “a priori” 4 Given a method m(p 1,..,p n )  peak(m) : an expression in terms of p 1,…,p n for the max amount of memory consumed by m

 Previous work  A general technique to find non-linear parametric upper- bounds of dynamic memory allocations ▪ totAlloc(m) computes an expression in terms of m parameters for the amount of dynamic memory requested by any run starting at m ▪ Relies on programs invariants to approximate number of visits of allocating statements  Using a scope-based region management… ▪ An application of that technique to approximate region sizes 5

For linear invariants, # of integer solutions = # of integer points = Ehrhart polynomial size(B) * ( ½k2+½k)   {0≤ i < n, 0≤j<i}: a set of constraints describing a iteration space for(i=0;i<n;i++) for(j=0;j<i;j++) new C() o Dynamic Memory allocations  number of visits to new statements o  number of possible variable assignments at its control location o  number of integer solutions of a predicate constraining variable assignments at its control location (i.e. an invariant) i j Basic idea: counting visits to memory allocating statements. 6

 How much memory (in terms of m0 parameters) is requested/allocated by m0 7 totAlloc(m0)(mc) = = ( size(B[]) + size(B) + size(C) )(1/2 mc 2 +5/2 mc) + size(A) mc

 Memory is released by a garbage collector  Very difficult to predict when, where, and how many object are collected  Our approach: Approximate GC using a scope-based region memory manager m0(2)m0(7) 8

Memory organized using m-regions void m0(int mc) { 1: m1(mc); 2: B[] m2Arr=m2(2 * mc); } void m1(int k) { 3: for (int i = 1; i <= k; i++){ 4: A a = new A(); 5: B[] dummyArr= m2(i); } B[] m2(int n) { 6: B[] arrB = new B[n]; 7: for (int j = 1; j <= n; j++) { 8: arrB[j-1] = new B(); 9: C c = new C(); 10: c.value = arrB[j-1]; } 11: return arrB; } 9

Memory organized using m-regions 10

 Escape(m): objects that live beyond m  Escape(mo) = {}  Escape(m1) = {}  Escape(m2) = {m2.6, m2.8}  Capture(m): objects that do not live more that m  Capture(mo) = {m0.2.m2.6, m0.2.m2.8},  Capture(m1) = {m1.4, m0.1.m1.5.m2.6, m0.1.m1.5.m2.8},  Capture(m2) = {m2.9}  Region(m)  Capture(m) Escape Analysis void m0(int mc) { 1: m1(mc); 2: B[] m2Arr=m2(2 * mc); } void m1(int k) { 3: for (int i = 1; i <= k; i++){ 4: A a = new A(); 5: B[] dummyArr= m2(i); } B[] m2(int n) { 6: B[] arrB = new B[n]; 7: for (int j = 1; j <= n; j++) { 8: arrB[j-1] = new B(); 9: C c = new C(); 10: c.value = arrB[j-1]; } 11: return arrB; } 11

 Region(m)  Capture(m)  memCap(m) : an expression in terms of p 1,…,p n for the amount of memory required for the region associated with m  memCap(m) is totAlloc(m) applied only to captured allocations 12 memCap(m0) = (size(B[]) + size(B)).2mc memCap(m1) = (size(B[]) + size(B)).(1/2 k 2 +1/2k) +size(A).k memCap(m2)= size(C).n

Approach:  Over approximate an ideal memory manager using an scoped-based memory regions  m-regions: one region per method  When & Where: ▪ created at the beginning of method ▪ destroyed at the end  How much memory is allocated/deallocated in each region: ▪ memCap(m) >= actual region size of m for any call context  How much memory is allocated in outer regions : ▪ memEsc(m) >= actual memory that is allocated in callers regions 13

 Peak(m) = Peak  (m) + Peak  (m)  peak  (m): peak consumption for objects allocated in regions created when m is executed  peak  (m): consumption for objects allocated in regions that already exist before m is executed Our technique:  mem  (m) >= Peak  (m)  Approximation of peak memory allocated in newly created regions  mem  (m) >= Peak  (m)  Approximation of memory allocated in preexistent regions (memEsc(m)) Pre existent regions m region m callees’ regions 14

Some region configurations can not happen at the same time Region’s stack evolution ? ? ? ? rm0 rm1 rm0 rm1 rm2 rm0 rm2 rm0 rm1 … rm0 rm1 rm2 rm0 rm1 15 peak  (  0, m0) = max  size(r k (  ))

Region sizes may vary according to method calling context m0.1.m1.5.m2 rsize(m2) = n (assume size(C)=1) { k= mc, 1  i  k, n = i} { k= mc = n} maximizes maxrsize(m0.1.m1.5.m2,m0) = mc 16 rm0 rm1 rm2 rm0 rm1 rm2 rm0 rm1 rm2 peak  (m0) … In terms of m0 parameters!

We consider the largest region for the same calling context maxrm0 maxrm1 maxrm0 maxrm1 maxrm2 maxrm0 maxrm2 peak  (m0)  17 mem  (m0) = mem  (m0) m0.1.m1.5.m2 m0.1.m1.5 m0 m0.2

 m-region expressed in terms of m parameters  rsize(m2)(m0) = n  Maximum according to calling context and in terms of MUA parameters  maxrsize(m0.1.m1.5.m2,m0) (mc) = mc  maxrsize(m0.2.m2,m0)(mc) = 2mc 3. Maximizing instantiated regions maxrsize( .m,m0)(P m0 ) = Maximize rsize(m) subject to I  (P m0,P m, W) We cannot solve a non-linear maximization problem in runtime!! Too expensive Execution time difficult to predict We need a parametric solution that can be solved at compile time. We cannot solve a non-linear maximization problem in runtime!! Too expensive Execution time difficult to predict We need a parametric solution that can be solved at compile time. 18

 Solution: use an approach based on Bernstein basis over polyhedral domains (Clauss et al. 2004)  Enables bounding a polynomial over a parametric domain given as a set of linear restraints  Obtains a parametric solution  Bernstein(pol, I):  Input: a polynomial pol and a set of linear (parametric) constrains I  Return a set of polynomials (candidates) ▪ Bound the maximum value of pol in the domain given by I 19

 Partial solution to our problem  We still need to determine symbolically maximum between polynomials  In the worst case we can leave it for run-time evaluation (cost known “a priori”) ▪ A comparison when actual parameters are available 20 Example:  Input Polynomial  Q(n)=n 2 -1,  Restriction: A parametric domain (linear restraint)  D(P1,P2) = {(i, n) |1 ≤i≤P1 +P2, i ≤ 3P2, n=i}  Bernstein(Q, D) = D1 = {P1 ≤ 2P2} C1: {(P1+P2) 2 -1,P2+P1 } D2 = {2P2 ≤ P1} C2: {9P2 2 -1}

max { q(P mo )  C1} if D1(P mo ) Maxrsize (m0, .m k )= max { q(P mo )  Ck} if Dk(P mo ) where {Ci, Di} = Bernstein(rsize(m k ), I .mk,P m0 ) Maxrsize (m0,m0)(mc) = (size(B[]) + size(B)).2mc Maxrsize (m0.1.m1,m0 ) (mc ) = (size(B[]) + size(B)).(1/2 mc 2 +1/2mc) +size(A).mc Maxrsize (m0.1.m1.5.m2,m0)(mc) = size(C).mc Maxrsize (m0.21m2,m0)(mc) = size(C).2mc 21

 mem  :  basically a sum maximized regions  A comparison of the results of the sum max 22 maxrm0 maxrm1 maxrm0 maxrm1 maxrm2 maxrm0 maxrm2 m0.1.m1.5.m2 m0.1.m1.5 m0 m0.2

rm1 rm2 rm0 rm2 23

24 Considering size(T) = 1 for all T

 Memreq m0 (mc) = mc 2 +7mc Computing memReq 25

26

Experimentation (#objects) Jolden: totAlloc vs Peak vs region based code MST, Em3d completely automatic For the rest we need to provide some region sizes manually MST, Em3d, Bisort, TSP: peak close to totAlloc (few regions, long lived objects) Power, health, BH, Perimeter: peak << totAlloc 27

28

29 AuthorYearLanguageExpressionsMemory Manager Benchmarks Hofmann & Jost2003FunctionalLinearExplicitNo Lui & Unnikrishnan 2003FunctionalRecursive functions Ref. Counting Add-hoc (Lists) Chin et al2005Java likeLinear (Pressburger): Checking ExplicitJolden Chin et al NEXT PRESENTATION! 2008BytecodeLinear: Inference ExplicitSciMark, MyBench Albert et al (2)2007BytecodeRecurrence equations No && Esc Analysis No

 A technique for computing parametric (easy to evaluate) specifications of heap memory requirements  Consider memory reclaiming  Use memory regions to approximate GC  A model of peak memory under a scoped-based region memory manager  An application of Bernstein to solve a non-linear maximization problem  A tool that integrates this technique in tool suite  Precision relies on several factors:  invariants, region sizes, program structure, Bernstein 30

 Restrictions on the input  Better support for recursion  More complex data structures  Other memory management mechanisms  Usability / Scalability  Integration with other tools/ techniques ▪ JML / Spec# (checking+inferring) ▪ Type Systems (Chin et al.) ▪ Modularity  Improve precision Future work 31