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

the use of traces for inlining in java programs
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

2

Introduction

 Feedback-directed systems

provide information to a compiler regarding program behaviour

 Examples:

 Jikes RVM [AFG+00]  Open Runtime Platform [Mic03] Source Code Compiler Program Feedback

slide-3
SLIDE 3

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

slide-4
SLIDE 4

4

Outline

 Background  Implementation  Results  Related work  Conclusion

slide-5
SLIDE 5

5

Trace Definition

 A trace is a frequently

executed sequence of unique basic blocks or instructions

a=0 i=0 goto B2 a+=i i++ if (i<5) goto B1 return a B0 B1 B2 B3 Trace 1

public static int foo() { int a=0; for (int i=0;i<5;i++) a++; return a; }

slide-6
SLIDE 6

6

Traces and Optimization

 Traces may offer a better opportunity for

  • ptimization:

 Enable inter-procedural analysis  Reduce the amount of instructions optimized  Simplify the control flow graph, allowing for more

  • ptimization
slide-7
SLIDE 7

7

Multiple Methods

 Inter-procedural analysis

without an additional framework

 Increase possibility of

  • ptimization

 B1,A1,B2 can be

simplified to two instructions

 a+=(5+i)  i++

B0 t=returned value a+=t i++ B3 B4 B1 call g(i) B2 t=5+i return t A1 Trace 1

slide-8
SLIDE 8

8

Fewer Instructions

 Fewer instructions to

  • ptimize

 May allow for extra

  • ptimization

 If know that B3 is

executed then know that t=5

B0 B6 B1 B5 B6 B2: t=f(...) Trace 1 B3: t=5 B4

slide-9
SLIDE 9

9

Trace Exits

 Traces usually contain

many basic blocks

 Traces may not

execute completely

 Unlike basic blocks B0 B6 B1 B5 B6 B2 Trace 1 B3 B4

slide-10
SLIDE 10

10

Trace Collection System

 Monitor program execution  Record traces  Start traces at frequently

  • ccurring events

 Backward branches  Trace exits  Returns

 Stop at backward branches

and trace starts

 Captures frequently executed

loops and functions

a=0 i=0 goto B2 a+=i i++ if (i<5) goto B1 return a B0 B1 B2 B3 Trace 1

slide-11
SLIDE 11

11

Jikes

Baseline Compiler Optimizing Compiler Program Adaptive System

slide-12
SLIDE 12

12

Jikes and our TCS

Baseline Compiler Optimizing Compiler Program Adaptive System TCS Inform TCS Trace Information

slide-13
SLIDE 13

13

Jikes – Second Phase

Baseline Compiler Optimizing Compiler Program Adaptive System Trace Information

slide-14
SLIDE 14

14

Inlining and Traces

 Traces are executed

frequently

 Therefore invocations on

traces should be inlined

 Reduce invocation

  • verhead

 Allow for more

  • pportunities for
  • ptimization

 May lead to large code

expansion

a:call b() b: … method a() … invoke b() … method b() …

slide-15
SLIDE 15

15

Code Expansion Control

 There are ways to control

inline expansion

 Inline sequences

[HG03,BB04]

 Selectively inlining:

 What if compile method a()?  What if compile method b()? a:call b() b:call c() c:…

slide-16
SLIDE 16

16

Code Expansion Control

 Compile method a()

 Inline methods b() and c()

 Compile method b()

 No inlining method a() … invoke b() … method c() … method b() … invoke c() … method b() … invoke c() … method c() …

slide-17
SLIDE 17

17

Results

 Provide inline information to Jikes based on

previous executions

 Compare our approach to two others:

 Inline information provided by the Adaptive system

  • f 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

slide-18
SLIDE 18

18

JIT Inlining – Execution Time

0.2 0.4 0.6 0.8 1 1.2 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Time

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

slide-19
SLIDE 19

19

JIT Inlining – Compilation Time

0.5 1 1.5 2 2.5 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Time

A d a p t i v e . 5 2 s G r e e d y . 6 1 s T r a c e . 6 9 s

slide-20
SLIDE 20

20

JIT Inlining – Code Expansion

0.5 1 1.5 2 2.5 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Size

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

slide-21
SLIDE 21

21

AOT Inlining – Execution Time

0.2 0.4 0.6 0.8 1 1.2 201 202 209 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Time

Adaptive 29.3s Trace 21.8s

slide-22
SLIDE 22

22

AOT Inlining – Compilation Time

0.5 1 1.5 2 2.5 3 3.5 4 201 202 209 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Time

A d a p t i v e 3 . 8 s T r a c e 5 . 6 s

slide-23
SLIDE 23

23

Overhead

0.5 1 1.5 2 2.5 3 201 202 209 213 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Tim

B a s e 7 7 s B a s e + 9 s B a s e + a n d T C S 1 7 4 s

slide-24
SLIDE 24

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

slide-25
SLIDE 25

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

slide-26
SLIDE 26

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

slide-27
SLIDE 27

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. Transparent dynamic optimization: The design and implementation

  • f dynamo. HP Laboratories Technical Report HPL1999 –78,
slide-28
SLIDE 28

28

AOT – Compilation Time (Wall Time)

0.5 1 1.5 2 2.5 201 202 209 222 228 2a1 2a2 2a3 2a4 2a5 mean

Normalized Time

A d a p t i v e 7 . 3 s T r a c e 8 . 2 s