the use of traces for inlining in java programs
play

The Use of Traces for Inlining in Java Programs Borys J. Bradel - PowerPoint PPT Presentation

The Use of Traces for Inlining in Java Programs Borys J. Bradel Tarek S. Abdelrahman Edward S. Rogers Sr.Department of Electrical and Computer Engineering University of Toronto Toronto, Ontario, Canada Introduction Feedback-directed


  1. The Use of Traces for Inlining in Java Programs Borys J. Bradel Tarek S. Abdelrahman Edward S. Rogers Sr.Department of Electrical and Computer Engineering University of Toronto Toronto, Ontario, Canada

  2. Introduction  Feedback-directed systems provide information to a compiler Source Code regarding program behaviour Compiler  Examples:  Jikes RVM [AFG+00] Program  Open Runtime Platform [Mic03] Feedback 2

  3. Work Overview  Explore whether traces are useful in offline feedback directed systems  Create trace collection system for Jikes  Use traces to guide Jikes’s built in optimizing compiler  Help with a single optimization, inlining  Improves execution time 3

  4. Outline  Background  Implementation  Results  Related work  Conclusion 4

  5. Trace Definition  A trace is a frequently executed sequence of a=0 B0 i=0 unique basic blocks or goto B2 instructions Trace 1 B1 a+=i public static int foo() { i++ int a=0; for (int i=0;i<5;i++) B2 if (i<5) goto B1 a++; return a; B3 return a } 5

  6. Traces and Optimization  Traces may offer a better opportunity for optimization:  Enable inter-procedural analysis  Reduce the amount of instructions optimized  Simplify the control flow graph, allowing for more optimization 6

  7. Multiple Methods  Inter-procedural analysis B0 without an additional framework B1 Trace 1 call g(i)  Increase possibility of optimization A1 t=5+i  B1,A1,B2 can be return t simplified to two t=returned value B2 instructions a+=t  a+=(5+i) i++  i++ B3 B4 7

  8. Fewer Instructions  Fewer instructions to B0 optimize Trace 1 B1  May allow for extra B2: t=f(...) B3: t=5 optimization  If know that B3 is B4 executed then know that t=5 B5 B6 B6 8

  9. Trace Exits  Traces usually contain B0 many basic blocks Trace 1  Traces may not B1 execute completely B2 B3  Unlike basic blocks B4 B5 B6 B6 9

  10. Trace Collection System  Monitor program execution  Record traces a=0 B0  Start traces at frequently i=0 goto B2 occurring events Trace 1  Backward branches B1 a+=i  Trace exits i++  Returns  Stop at backward branches and trace starts B2 if (i<5) goto B1  Captures frequently executed loops and functions B3 return a 10

  11. Jikes Baseline Program Optimizing Compiler Compiler Adaptive System 11

  12. Jikes and our TCS Baseline Program Optimizing Compiler Compiler Inform TCS TCS Adaptive Trace System Information 12

  13. Jikes – Second Phase Baseline Program Optimizing Compiler Compiler Adaptive System Trace Information 13

  14. Inlining and Traces  Traces are executed frequently a:call b()  Therefore invocations on traces should be inlined b: …  Reduce invocation overhead  Allow for more method a() opportunities for … method b() invoke b() optimization … …  May lead to large code expansion 14

  15. Code Expansion Control  There are ways to control inline expansion a:call b()  Inline sequences b:call c() [HG03,BB04]  Selectively inlining: c:…  What if compile method a()?  What if compile method b()? 15

  16. Code Expansion Control  Compile method a()  Inline methods b() and c() method a() method b() … … method c() invoke b() invoke c() … … …  Compile method b()  No inlining method b() … method c() invoke c() … … 16

  17. Results  Provide inline information to Jikes based on previous executions  Compare our approach to two others:  Inline information provided by the Adaptive system of Jikes  A greedy algorithm based on work by Arnold et al. [Arn00]  Evaluate two approaches: Just in Time and Ahead of Time  Measure overhead of system 17

  18. JIT Inlining – Execution Time 1.2 1 Normalized Time 0.8 0.6 0.4 0.2 0 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean A d a p t i v e 2 5 . 6 s G r e e d y 2 3 . 3 s T r a c e 2 2 . 7 s 18

  19. JIT Inlining – Compilation Time 2.5 Normalized Time 2 1.5 1 0.5 0 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean A d a p t i v e 0 . 5 2 s G r e e d y 0 . 6 1 s T r a c e 0 . 6 9 s 19

  20. JIT Inlining – Code Expansion 2.5 Normalized Size 2 1.5 1 0.5 0 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean A d a p t i v e 2 1 . 3 k b G r e e d y 2 2 . 8 k b T r a c e 2 7 . 7 k b 20

  21. AOT Inlining – Execution Time 1.2 1 Normalized Time 0.8 0.6 0.4 0.2 0 201 202 209 222 228 2a1 2a2 2a3 2a4 2a5 mean Adaptive 29.3s Trace 21.8s 21

  22. AOT Inlining – Compilation Time 4 3.5 Normalized Time 3 2.5 2 1.5 1 0.5 0 201 202 209 222 228 2a1 2a2 2a3 2a4 2a5 mean A d a p t i v e 3 . 8 s T r a c e 5 . 6 s 22

  23. Overhead 3 2.5 Normalized Tim 2 1.5 1 0.5 0 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean B a s e 7 7 s B a s e + 9 0 s B a s e + a n d T C S 1 7 4 s 23

  24. Related Work  Arnold et al. [Arn00]  Feedback-directed inlining in Java  Collected edge counts at method invocations  Used a greedy algorithm to select inlines that maximize invocations relative to code expansion  Dynamo [BDB99]  Trace collection system  PA-RISC architecture  Assembly Instructions  Compiled traces 24

  25. Conclusions  Traces are beneficial for inlining:  Decreased execution time compared to one approach  Decrease competitive with another approach  Increases compilation time and code size  A potential avenue of future research 25

  26. Future Work  Different trace collection strategies  Trace based compilation and execution  Reduction of code size  Application of traces to other optimizations  Usage of an online feedback directed system 26

  27. References [MSD00] Matthew Arnold, Stephen Fink, David Grove, Michael  Hind, and Peter F. Sweeney. Adaptive optimization in the Jalapeno JVM. ACM SIGPLAN Notices, 35(10):47-65, 2000. [Mic03] Michael Cierniak et al. The open runtime platform: A  flexible high-performance managed runtime environment. Intel Technology Journal, February 2003. [HG03] Kim Hazelwood and David Grove. Adaptive online context-  sensitive inlining. International Symposium on Code Generation and Optimization, p 253-264, 2003. [BB04] Bradel, B.J.: The use of traces in optimization. Master’s  thesis, University of Toronto (2004). [Arn00] Matthew Arnold et al: A comparative study of static and  profile-based heuristics for inlining. SIGPLAN Workshop on Dynamic and Adaptive Compilation and Optimization. (2000) 52- 64. [BDB99] Vasanth Bala, Evelyn Duesterwald, and Sanjeev Banerjia.  27 Transparent dynamic optimization: The design and implementation of dynamo. HP Laboratories Technical Report HPL1999 –78,

  28. AOT – Compilation Time (Wall Time) 2.5 Normalized Time 2 1.5 1 0.5 0 201 202 209 222 228 2a1 2a2 2a3 2a4 2a5 mean A d a p t i v e 7 . 3 s T r a c e 8 . 2 s 28

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