debunking dynamic optimization myths

Click here to load reader

Post on 30-Dec-2015

48 views

Category:

Documents

3 download

Embed Size (px)

DESCRIPTION

Debunking Dynamic Optimization Myths. Michael Hind Based on PLDI’04 Tutorial by Fink, Grove, and Hind. Well-known Facts. Because they execute at runtime, dynamic compilers must be blazingly fast Dynamic class loading is a fundamental roadblock to cross-method optimization - PowerPoint PPT Presentation

TRANSCRIPT

IBM supplementary templates on white© 2005 IBM Corporation
Presentation subtitle: 20pt Arial Regular, teal R045 | G182 | B179 Recommended maximum length: 2 lines
Confidentiality/date line: 13pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side Disclaimer information may also be appear in this area. Place flush left, aligned at bottom, 8-10pt Arial Regular, white
IBM logo must not be moved, added to, or altered in any way.
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Presentation title: 28pt Arial Regular, black Recommended maximum length: 2 lines
Group name: 17pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
For client presentations, client’s logo may go in this area
Debunking Dynamic Optimization Myths
Based on PLDI’04 Tutorial by Fink, Grove, and Hind
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Well-known Facts
Because they execute at runtime, dynamic compilers must be blazingly fast
Dynamic class loading is a fundamental roadblock to cross-method optimization
Sophisticated profiling is too expensive to perform online
A static compiler will always produce better code than a dynamic compiler
Program optimization is a dead field
The infrastructure investment stifles innovation in this field
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Well-known Facts ???
Because they execute at runtime, dynamic compilers must be blazingly fast
Dynamic class loading is a fundamental roadblock to cross-method optimization
Sophisticated profiling is too expensive to perform online
A static compiler will always produce better code than a dynamic compiler
Program optimization is a dead field
The infrastructure requirements stifles innovation in this field
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Terminology
Virtual Machine (for this talk): a software execution engine for a program written in a machine-independent language
Ex, Java bytecodes, CLI, Pascal p-code, Smalltalk v-code
Program
Loader
Thread
Scheduler
Security
Services
Libraries
Memory
Management
Runtime
Support
Mechanisms
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Adaptive Optimization Hall of Fame
1958-1962
1974
1980-1984
1986-1994
1995-present
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Adaptive Optimization Hall of Fame
1958-1962: LISP
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Quick History of VMs
LISP Interpreters [McCarthy’78]
First widely used VM
Adaptive Fortran [Hansen’74]
Selective optimization, models, multiple optimization levels, online profiling and control systems
ParcPlace Smalltalk [Deutsch&Schiffman’84]
First modern VM
Demonstrated software-only VMs were viable
TBD: Tamiya asks “Is there an earlier reference for the LISP work? Maybe CACM’64?”
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Quick History of VMs
Developed many advanced VM techniques
Introduced polymorphic inline caches, on-stack replacement, dynamic de-optimization, advanced selective optimization, type prediction and splitting, profile-directed inlining integrated with adaptive recompilation
Pure OO language that supports an interactive development environment
Much of the technology was transferred to Sun’s HotSpot JVM
Java/JVM [Gosling et al ‘95]
First VM with mainstream market penetration
Java vendors embraced and improved Smalltalk and Self technology
Encouraged VM adoption by others -> CLR
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Other VMs in this Talk
IBM DK for Java [’95- ]
Port of Sun Classic JVM with JIT, GC, and synch enhancements
World class performance
Independently developed VM + GNU Classpath libs
Open source, popular with researchers, not a full JVM
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Myth 1 - Dynamic compilers must be blazingly fast
Myth: Because they execute at runtime, dynamic compilers must be blazingly fast.
they cannot perform sophisticated optimizations, such as SSA, graph-coloring register allocation, inlining, etc.
Reality:
Selective optimization strategies successfully focus compilation effort where needed
What is Selective Optimization?
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
How are Programs Executed?
Ex, APL, SNOBOL, BCPL, Perl, Python, MATLAB
Useful for memory-challenged environments
Low startup overhead, but much slower than native code execution
Classic just-in-time compilation
Ex, ParcPlace Smalltalk-80, Self-91
Responsible for many of today’s myths
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Selective Optimization
Hypothesis: most execution is spent in a small pct. of methods
Idea: use two execution strategies
Interpreter or non-optimizing compiler
Profile application to find “hot” subset of methods
Use option 2 on this subset
“Still a good strategy even with a flat profile”
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Selective Optimization Examples
JVMs
Interpreter + compilers: Sun’s HotSpot, IBM DK for Java, IBM’s J9
Multiple compilers: Jikes RVM, Intel’s Judo/ORP, BEA’s JRocket
CLR?
But, also use ahead-of-time (AOT) compilation
IBM Research
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
Profiling: How to Find Candidates for Optimization
Counters
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
How to Find Candidates for Optimization: Counters
Insert method-specific counter on method entry and loop back edge
Counts how often a method is called
approximates how much time is spent in a method
Very popular approach: Self, HotSpot
Issues: overhead for incrementing counter can be significant
Not present in optimized code
foo ( … ) {
fooCounter++;
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
How to Find Candidates for Optimization: Call Stack Sampling
Periodically record which method(s) are on the call stack
Approximates amount of time spent in each method
Does not necessarily need to be compiled into the code
Ex) Jikes RVM, JRocket
A
B
C
A
B
A
A
B
A
B
C
A
B
C
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
How to Find Candidates for Optimization: Call Stack Sampling
Periodically record method(s) on call stack
Approximates amount of time spent in each method
Does not necessarily need to be compiled into the code
Ex) Jikes RVM, JRocket
A
B
C
A
B
A
A
B
A
B
C
A
B
C
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered in any way. Background should not be modified,
Title/subtitle/confidentiality line: 10pt Arial Regular, white Maximum length: 1 line Information separated by vertical strokes, with two spaces on either side
Slide heading: 28pt Arial Regular, blue R120 | G137 | B251 Maximum length: 2 lines Slide body: 18pt Arial Regular, black Square bullet color: teal R045 | G182 | B179 Recommended maximum text length: 5 principal points
Group name: 14pt Arial Regular, white Maximum length: 1 line
Copyright: 10pt Arial Regular, white
Template release: Oct 02 For the latest, go to http://w3.ibm.com/ibm/presentations
Indications in green = Live content Indications in white = Edit in master Indications in blue = Locked elements Indications in black = Optional elements
How to Find Candidates for Optimization: Combinations
Use counters initially and sampling later on
Ex) IBM DK for Java
foo ( … ) {
fooCounter++;
NC State Seminar February 18, 2005 Debunking Dynamic Optimization Myths
© 2005 IBM Corporation
IBM logo must not be moved, added to, or altered…

View more