costa a cost and termination analyzer for java bytecode
play

COSTA: A COSt and Termination Analyzer for Java (bytecode) Programs - PowerPoint PPT Presentation

COSTA: A COSt and Termination Analyzer for Java (bytecode) Programs Elvira Albert and Germ an Puebla Ecole Normale Sup erieure (ENS) Paris, Sept 2, 2011 Elvira Albert The COSTA Group The COSTA Team Staff: E. Albert P. Arenas J.


  1. COSTA: A COSt and Termination Analyzer for Java (bytecode) Programs Elvira Albert and Germ´ an Puebla ´ Ecole Normale Sup´ erieure (ENS) Paris, Sept 2, 2011 Elvira Albert The COSTA Group

  2. The COSTA Team Staff: E. Albert P. Arenas J. Correas S. Genaim G-Zamalloa G. Puebla Zanardini UCM UCM UCM UCM UCM UPM UPM PhD Students: D. Alonso A. Flores A. Masud D. Ramirez J. Rojas G. Roman UCM UCM UPM UPM UPM UPM Elvira Albert The COSTA Group

  3. Outline of the Talk 1 Part 1: Resource Usage Analysis (Elvira) Introduction to Resource Usage Analysis Overview of COSTA Generation of cost relations Closed-form upper and lower bounds Conclusions Future work Main publications Elvira Albert The COSTA Group

  4. Outline of the Talk 1 Part 1: Resource Usage Analysis (Elvira) Introduction to Resource Usage Analysis Overview of COSTA Generation of cost relations Closed-form upper and lower bounds Conclusions Future work Main publications 2 Part 2: Tool Demo (Germ´ an) Simple complexity classes Memory consumption Libraries Elvira Albert The COSTA Group

  5. Introduction: Resource Usage Analysis Part 1: Resource Usage Analysis Elvira Albert The COSTA Group

  6. Introduction: Resource Usage Analysis static cost analysis bound the cost of executing program P on any input data x without having to actually run P ( x ) Elvira Albert The COSTA Group

  7. Introduction: Resource Usage Analysis static cost analysis bound the cost of executing program P on any input data x without having to actually run P ( x ) reasoning about execution cost is difficult and error-prone cost analysis, or resource analysis or complexity analysis should be automatic Elvira Albert The COSTA Group

  8. Introduction: Resource Usage Analysis static cost analysis bound the cost of executing program P on any input data x without having to actually run P ( x ) reasoning about execution cost is difficult and error-prone cost analysis, or resource analysis or complexity analysis should be automatic The resources considered number of executed (bytecode) instructions memory usage billable events (number of calls to a specific method) Termination (it guarantees the existence of an upper bound) Elvira Albert The COSTA Group

  9. Kinds of Cost Analysis Different kinds of cost can be considered: worst case → upper bound average case → requires probabilistic study best case → lower bound Elvira Albert The COSTA Group

  10. Kinds of Cost Analysis Different kinds of cost can be considered: worst case → upper bound average case → requires probabilistic study best case → lower bound Two classes of upper bounds can be considered: non-asymptotic (or concrete, or micro-analysis) asymptotic (or macro-analysis) Elvira Albert The COSTA Group

  11. Kinds of Cost Analysis Different kinds of cost can be considered: worst case → upper bound average case → requires probabilistic study best case → lower bound Two classes of upper bounds can be considered: non-asymptotic (or concrete, or micro-analysis) asymptotic (or macro-analysis) Analysis results can be platform-independent platform-dependent → WCET Elvira Albert The COSTA Group

  12. State of the Art in Automatic Cost Analysis Work on automatic cost analysis dates back to 1975, with the seminal work of Wegbreit. His system, metric was able to compute: interesting results, but for restricted class of functional programs Also, the seminal work on abstract interpretation [Cousot & Cousot’77] mentions performance analysis as an application. Since then, a number of analyses and systems have been built which extend the capabilities of cost analysis: functional programs [Le Metayer’88, Rosendahl’89, Wadler’88, Sands’95, Benzinger’04] logic programs [Debray and Lin’93, Navas et al’07] imperative programs [Adachi et al’79, Albert et al’07] Elvira Albert The COSTA Group

  13. A Classical Approach to Cost Analysis COST CLOSED RECURRENCE SOLVER PROGRAM ANALYSIS FORM RELATIONS A classical approach [Wegbreit’75] to cost analysis consists of: 1 expressing the cost of a program part in terms of other program parts, thus obtaining recurrence relations 2 solving the relations by obtaining a closed-form for the cost in terms of the input arguments Elvira Albert The COSTA Group

  14. A Classical Approach to Cost Analysis COST CLOSED RECURRENCE SOLVER PROGRAM ANALYSIS FORM RELATIONS A classical approach [Wegbreit’75] to cost analysis consists of: 1 expressing the cost of a program part in terms of other program parts, thus obtaining recurrence relations 2 solving the relations by obtaining a closed-form for the cost in terms of the input arguments The current situation is that Most work has concentrated on the first phase The difficulties of the second phase have been overseen Practical usage of cost analysis requires both! In COSTA we address both phases. Elvira Albert The COSTA Group

  15. The COSTA System COSTA : COSt and Termination analyzer for Java Bytecode INPUT: bytecode + cost model OUPUT: upper bound on resource consumption + termination info Elvira Albert The COSTA Group

  16. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  17. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  18. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  19. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  20. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  21. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  22. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  23. Worked Example on Cost Analysis · · List f(String x[]) { List l=null; int i=0; while (i<x.length) { � a l = new List(g(x,i),l); i += COND ?1:3; } return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  24. Worked Example on Cost Analysis · · List f(String x[]) { W List l=null; o r s t - C a s e ( U int i=0; B ) while (i<x.length) { � a l = new List(g(x,i),l); f ( x ) = x � ( x ∗ + b 1 ) i += COND ?1:3; + � ∗ 2 c x + � ∗ } a x return l; } Integer g(String x[], int i) { int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  25. Worked Example on Cost Analysis · · List f(String x[]) { W List l=null; o r s t - C a s e ( U int i=0; B ) while (i<x.length) { � a l = new List(g(x,i),l); f ( x ) = x � ( x ∗ + b 1 ) i += COND ?1:3; + � ∗ 2 c x + � ∗ } a x ) B L ( e return l; s a � ∗ x C - t s e } B 3 + a � ∗ x 3 � ∗ x ( x +3) + c 18 Integer g(String x[], int i) { = b ) x ( f int r=0; for(int j=0; j<i; j++) { � b Integer t = new Integer(x[i]); r += t.intValue (); } � return c new Integer(r); } · · Elvira Albert The COSTA Group

  26. COSTA - Worst/Best Case · · Program Static Analysis Cost Relations CRs Solver Best/Worst Case · · Elvira Albert The COSTA Group

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend