Performance Potential of Optimization Phase …mjantz/slides/vee13-slides.pdf · Performance...

20
Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation Michael R. Jantz Prasad A. Kulkarni Electrical Engineering and Computer Science, University of Kansas {mjantz,kulkarni}@ittc.ku.edu March 17, 2013 1/20

Transcript of Performance Potential of Optimization Phase …mjantz/slides/vee13-slides.pdf · Performance...

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Performance Potential of Optimization Phase

Selection During Dynamic JIT Compilation

Michael R. Jantz Prasad A. Kulkarni

Electrical Engineering and Computer Science, University of Kansas{mjantz,kulkarni}@ittc.ku.edu

March 17, 2013

1/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Introduction

Phase Selection in Dynamic Compilers

◮ Phase Selection – customizing set of optimizations applied foreach method / program to generate the best quality code

◮ Static solutions do not necessarily apply to JITs

◮ Heuristics improve startup performance.

◮ Is it possible for phase customization to improve peakthroughput (aka steady-state performance)?

2/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Introduction

Our Goals

◮ Understand optimization behavior relevant to phase selection

◮ Quantify the performance potential of customizing phaseselections in online JIT compilers

◮ Determine if current state-of-the-art heuristics achieve idealperformance

3/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Experimental Framework

Our Experimental Framework

◮ Uses the server compiler in Sun/Oracle’s HotSpotTMJVM◮ Applies a fixed optimization set to each compiled method◮ Imposes a strict optimization ordering◮ Modified to optionally enable / disable 28 optimizations

◮ Two benchmark suites with two inputs:◮ SPECjvm98 (input sizes 10 and 100)◮ DaCapo (small and default)

◮ Phase selection applied to one focus method at a time◮ Profiling run to determine hottest methods◮ Select methods that comprise at least 10% of total program

runtime (53 focus methods across all of the benchmarks)

4/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Experimental Framework

Performance Measurement

Performance Measurement

◮ All experiments measure steady-state performance◮ Hot methods pre-compiled◮ No compilation during steady-state iterations

◮ Run on a cluster of server machines◮ CPU: four 2.8GHz Intel Xeon processors◮ Memory: 6GB DDR2 SDRAM, 4MB L2 Cache◮ OS: Red Hat Enterprise Linux 5.1

5/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Analyzing Behavior of Compiler Optimizations for Phase Selection

Analyzing Behavior of Compiler Optimizations

◮ In some situations, applying an optimization may havedetrimental effects

◮ Optimization phases interact with each other

◮ Experiments to explore the effect of optimization phases oncode quality

T (OPT < defOpt − x >) − T (OPT < defOpt >)

T (OPT < defOpt >)(1)

6/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Analyzing Behavior of Compiler Optimizations for Phase Selection

Impact of each Optimization over Focus Methods

Impact of each Optimization over Focus Methods

-20

-10

0

10

20

30

40

-0.4

-0.2

0

0.2

0.4

0.6

0.8

Nu

mb

er

of

imp

act

ed

me

tho

ds

Acc

um

ula

ted

im

pa

ct

HotSpot optimizations

- acc. impact

+ acc. impact

- # impacted

+ # impacted

16.06 1.92

Figure 1: Left Y-axis: Accumulated positive and negative impact of each HotSpot optimization over our

focus methods (non-scaled). Right Y-axis: Number of focus methods that are positively or negatively impacted by

each HotSpot optimization.

◮ Optimizations not always beneficial to program performance

◮ Most optimizations have occasional negative effects

7/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Analyzing Behavior of Compiler Optimizations for Phase Selection

Impact of each Optimization over Focus Methods

Impact of each Optimization over Focus Methods

Figure 1: Left Y-axis: Accumulated positive and negative impact of each HotSpot optimization over our

focus methods (non-scaled). Right Y-axis: Number of focus methods that are positively or negatively impacted by

each HotSpot optimization.

◮ Some optimizations show degrading impact more often

8/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Analyzing Behavior of Compiler Optimizations for Phase Selection

Impact of each Optimization over Focus Methods

Impact of each Optimization over Focus Methods

Figure 1: Left Y-axis: Accumulated positive and negative impact of each HotSpot optimization over our

focus methods (non-scaled). Right Y-axis: Number of focus methods that are positively or negatively impacted by

each HotSpot optimization.

◮ Most optimizations only have marginal impact on performance

◮ Most beneficial is method inlining, followed by register allocation

9/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Analyzing Behavior of Compiler Optimizations for Phase Selection

Impact of Optimizations for each Focus Method

Impact of Optimizations for each Focus Method

-10

-5

0

5

10

15

20

-0.8

-0.4

0

0.4

0.8

1.2

1.6

Nu

mb

er

of

op

tim

iza

tio

ns

wit

h s

ign

ific

an

t im

pa

ct

Acc

um

ula

ted

im

pa

ct

Methods

- acc. Imp. + acc. Imp.

- # opts + # opts

2.48 3.33 3.38

Figure 2: Left Y-axis: Accumulated positive and negative impact of the 25 HotSpot optimizations for each

focus method (non-scaled). Right Y-axis: Number of optimizations that positively or negatively impact each focus

method. The rightmost bar displays the average.

◮ Not many optimizations degrade performance (2.2, on average)◮ Only a few optimizations benefit performance (4.4, on average)

10/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Limits of Optimization Phase Selection

Limits of Optimization Phase Selection

◮ Iterative search infeasible due to number of optimizations

◮ Employ long-running genetic algorithms (GA’s) to findnear-optimal phase selections

◮ Evaluate group of phase selections in each GA generation◮ Random mutation and crossover to next generation’s set of

phase selections◮ 20 phase selections per generation over 100 generations

11/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Limits of Optimization Phase Selection

GA Results for Focus Methods

0

0.2

0.4

0.6

0.8

1

1.2

Be

st m

eth

od

-sp

eci

fic

GA

tim

e /

tim

e w

ith

de

fau

lt c

om

pil

er

Methods

Figure 3: Performance of method-specific optimization selection after 100 GA generations. All results are

scaled by the fraction of total program time spent in the focus method to show the runtime improvement for each

individual method. The rightmost bar displays the average.

◮ Customizing optimization phase selections achieves significant gains◮ Maximum improvement of 44%, average improvements of 6.2%

12/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Effectiveness of Feature-Vector Based Heuristics

Effectiveness of Feature-Vector Based Heuristics

◮ Iterative searches not practical for JITs

◮ Previous works proposed using feature-vector based heuristicsduring online compilation [1, 2]

◮ GA results allow the first evaluation of these heuristics(compared to ideal phase selections)

13/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Effectiveness of Feature-Vector Based Heuristics

Overview of Approach

Overview of Approach

◮ Training stage◮ Evaluate program performance for different phase selections◮ Construct a feature set to characterize methods◮ Correlate good phase selections with method features

◮ Deployment stage◮ Install learned statistical model into compiler◮ Extract each method’s feature set at runtime◮ Predict a customized phase selection for each method

14/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Effectiveness of Feature-Vector Based Heuristics

Our Experimental Setup

Our Experimental Setup

Scalar Features Distribution Features

Counters Types ALU Operations

Bytecodes byte char add subArguments int double mul divTemporaries short long rem negNodes float object shift or

address and xorinc compare

Attributes Casting Memory Operations

Constructor to byte load load constFinal to char store newProtected to short new array / multiarrayPublic to intStatic to long Control Flow

Synchronized to float branch callExceptions to double jsr switchLoops to address

to object Miscellaneous

cast check instance of throwarray ops field opssynchronization

Table 1: List of method features used in our experiments

◮ Select method features relevant to HotSpot

◮ Use logistic regression to train our predictive model

15/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Effectiveness of Feature-Vector Based Heuristics

Feature-Vector Based Heuristic Algorithm Results

Feature-Vector Based Heuristic Algorithm Results

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

Fe

atu

re v

ect

or

mo

de

l ti

me

/

be

st m

eth

od

-sp

eci

fic

GA

tim

e

Methods

4.95 5.34

Figure 4: Effectiveness of method-specific feature-vector based heuristic. Training data for each method

consists of all the other focus methods.

◮ On average, 22% worse than ideal, 14% worse than default compiler

◮ Feature-vector based heuristics cannot achieve improvements found by GA, butthis result is similar to findings in previous research.

16/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Effectiveness of Feature-Vector Based Heuristics

Feature-Vector Based Heuristic Algorithm Results

Feature-Vector Based Heuristic with Additional Analysis

0

0.2

0.4

0.6

0.8

1

1.2

1.4

Fe

atu

re v

ect

or

mo

de

l ti

me

/

be

st m

eth

od

-sp

eci

fic

GA

tim

e

Methods

1.56 1.66

Figure 5: Experiments that use the observations from analysis of optimization behavior to improve the

performance of feature-vector based heuristic algorithms for online phase selection

◮ Only predict ON/OFF setting for optimizations that show negative performanceimpact for at least 10% of methods

◮ Does not achieve ideal code quality, but only 8.4% worse than ideal

17/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Conclusions

Conclusions

◮ Framework for optimization selection research in JITs

◮ Observations◮ Most optimizations have modest performance impact◮ Few optimizations are active for most methods◮ Most optimizations do not negatively affect performance◮ Modest potential for optimization phase selection◮ GA-based search yields 6.2% average improvement◮ Feature-vector based heuristics do not attain ideal performance◮ Suggested directions may improve phase selection heuristics

18/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

Conclusions

Questions

Thank you for your time. Questions?

19/20

Performance Potential of Optimization Phase Selection During Dynamic JIT Compilation

References

References

[1] John Cavazos and Michael F. P. O’Boyle. Method-specificdynamic compilation using logistic regression. In Proceedings

of the conference on Object-oriented programming systems,

languages, and applications, pages 229–240, 2006.

[2] R.N. Sanchez, J.N. Amaral, D. Szafron, M. Pirvu, andM. Stoodley. Using machines to learn method-specificcompilation strategies. In Code Generation and Optimization,pages 257 –266, April 2011.

20/20