Virtual Machine Learning: Thinking Like a Computer Architect



Similar documents
A Unified View of Virtual Machines

General Introduction

Language Based Virtual Machines... or why speed matters. by Lars Bak, Google Inc

Wiggins/Redstone: An On-line Program Specializer

picojava TM : A Hardware Implementation of the Java Virtual Machine

CSCI E 98: Managed Environments for the Execution of Programs

Performance Management for Cloudbased STC 2012

The Design of the Inferno Virtual Machine. Introduction

Tachyon: a Meta-circular Optimizing JavaScript Virtual Machine

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Introduction to Virtual Machines

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

HOTPATH VM. An Effective JIT Compiler for Resource-constrained Devices

Validating Java for Safety-Critical Applications

Replication on Virtual Machines

Java Garbage Collection Basics

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Virtual Servers. Virtual machines. Virtualization. Design of IBM s VM. Virtual machine systems can give everyone the OS (and hardware) that they want.

Cloud Computing. Up until now

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software?

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

Java Environment for Parallel Realtime Development Platform Independent Software Development for Multicore Systems

Jonathan Worthington Scarborough Linux User Group

Garbage Collection in the Java HotSpot Virtual Machine

Object Oriented Database Management System for Decision Support System.

Driving force. What future software needs. Potential research topics

LaTTe: An Open-Source Java VM Just-in Compiler

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Precise and Efficient Garbage Collection in VMKit with MMTk

Java Virtual Machine: the key for accurated memory prefetching

Multi-core Programming System Overview

CIS570 Modern Programming Language Implementation. Office hours: TDB 605 Levine

Java Performance. Adrian Dozsa TM-JUG

12. Introduction to Virtual Machines

A JIT Compiler for Android s Dalvik VM. Ben Cheng, Bill Buzbee May 2010

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Lesson 06: Basics of Software Development (W02D2

Lecture 1 Introduction to Android

Effective Java Programming. efficient software development

Virtualization. Explain how today s virtualization movement is actually a reinvention

.NET and J2EE Intro to Software Engineering

Real Time Programming: Concepts

PHP vs. Java. In this paper, I am not discussing following two issues since each is currently hotly debated in various communities:

Habanero Extreme Scale Software Research Project

Optimizing compilers. CS Modern Compilers: Theory and Practise. Optimization. Compiler structure. Overview of different optimizations

IA-64 Application Developer s Architecture Guide

<Insert Picture Here> Java, the language for the future

Monitoring Java enviroment / applications

Understanding Hardware Transactional Memory

1/20/2016 INTRODUCTION

A Practical Method to Diagnose Memory Leaks in Java Application Alan Yu

Virtualization. Clothing the Wolf in Wool. Wednesday, April 17, 13

Oracle Corporation Proprietary and Confidential

The Hotspot Java Virtual Machine: Memory and Architecture

Static detection of C++ vtable escape vulnerabilities in binary code

Cloud Computing #6 - Virtualization

Software and the Concurrency Revolution

Full and Para Virtualization

Availability Digest. Raima s High-Availability Embedded Database December 2011

1. Overview of the Java Language

Instrumentation Software Profiling

Lecture 12: Software protection techniques. Software piracy protection Protection against reverse engineering of software

Eclipse Visualization and Performance Monitoring

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Virtualization for Cloud Computing

Hardware Acceleration for Just-In-Time Compilation on Heterogeneous Embedded Systems

Introduction to Cloud Computing

Data Centric Systems (DCS)

Applications to Computational Financial and GPU Computing. May 16th. Dr. Daniel Egloff

Hardware/Software Co-Design of a Java Virtual Machine

Virtual Machines.

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM

Course MS10975A Introduction to Programming. Length: 5 Days

Developing Embedded Software in Java Part 1: Technology and Architecture

Performance Optimization For Operational Risk Management Application On Azure Platform

GROUPWARE. Ifeoluwa Idowu

CHAPTER 1 INTRODUCTION

Web Application Development and Frameworks

Write Barrier Removal by Static Analysis

Operating System Support for Java Virtual Machine: A New Methodology of Boosting Java Runtime Performance

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

AMD Opteron Quad-Core

11.1 inspectit inspectit

Operating System Overview. Otto J. Anshus

Sequential Performance Analysis with Callgrind and KCachegrind

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Extreme Performance with Java

Java 6 'th. Concepts INTERNATIONAL STUDENT VERSION. edition

Transcription:

Virtual Machine Learning: Thinking Like a Computer Architect Michael Hind IBM T.J. Watson Research Center March 21, 2005 CGO 05 Keynote 2005 IBM Corporation

What is this talk about? Virtual Machines? 2

What is this talk about? Virtual Machines? YES! 3

What is this talk about? Virtual Machines? YES! Machine Learning? 4

What is this talk about? Virtual Machines? YES! Machine Learning? NO! 5

Outline Why Performance Matters Mathematicians and Gamblers Are Today s VM Gambling Now? A Call for More Gambling Other Issues and Conclusions 6

Developing Sophisticated Software Software development is difficult PL & SE innovations, such as Dynamic memory allocation, object-oriented programming, strong typing, components, frameworks, design patterns, aspects, etc. have helped enable the creation of large, sophisticated applications Resulting in modern languages with many benefits Better abstractions & reduced programmer efforts Better (static and dynamic) error detection Significant reuse of libraries 7

The Catch Implementing these features can pose performance challenges Dynamic memory allocation Need pointer knowledge to avoid conservative dependences Object-oriented programming Need efficient virtual dispatch, overcome small methods, extra indirection Automatic memory management Need efficient allocation and garbage collection algorithms Runtime bindings Need to deal with unknown information... Features require a rich runtime environment virtual machine 8

How Have We Done? So far, so good Today s typical application on today s hardware runs as fast as 1970s typical application on 1970s typical hardware Today s application is much more sophisticated eg. Current IDEs perform compilation on every save Where has the performance come from? 1. Processor technology, clock rates (X%) 2. Architecture design (Y%) 3. Software implementation (Z%) X + Y + Z = 100% HW assignment: determine X, Y, and Z 9

Future Trends Software development is still complex PL/SE innovation will continue to occur Trend towards more late binding, resulting in dynamic requirements Will pose further performance challenges Processor speed advances not as great as in the past (x << X?) Computer architects providing multicore machines Will require software to utilize these resources Not clear if it will contribute more than in the past (y? Y) Software implementation must pick up the slack (z > Z) Because languages are becoming more dynamic, dynamic/speculative approaches are needed 10

Type Safe, OO, VM-implemented Languages Are Mainstream Java is ubiquitous eg. Hundreds of IBM products are written in Java Virtualization is everywhere browsers, databases, binary translators, hypervisors, in hardware, etc. Extreme dynamic languages are widespread and run on a VM eg. PHP, Perl, Python, etc. These languages are not just for traditional applications Virtual Machine implementation, eg. Jikes RVM Operating Systems, eg. Singularity Real-time and embedded systems Massively parallel systems, eg. DARPA-supported efforts at IBM and Sun 11

Outline Why Performance Matters Mathematicians and Gamblers Are Today s VM Gambling Now? A Call for More Gambling Other Issues and Conclusions 12

Traditional Software Optimization Proves properties of the program by analyzing its structure True for all executions Performed by compiler prior to execution Mathematicians optimization based on proving properties Picking lottery numbers by analyzing the structure of balls 13

Hardware Optimization Speculates that the past will predict the future Occurs at runtime No pre-execution analysis Gamblers optimization by speculating on runtime properties Picking lottery numbers based on past results 14

Mathematicians vs Gamblers Pre-execution Proves properties for all executions Occurs at Runtime Speculates based on current execution Mathematicians Compiler Optimizers What about a JIT? Occurs at runtime Prove or speculate? Gamblers Hardware 15

Mathematicians vs Gamblers Speculate Hardware Optimization How Prove Traditional Software Optimization Pre-execution at Runtime When 16

Outline Why Performance Matters Mathematicians and Gamblers Are Today s VM Gambling Now? A Call for More Gambling Other Issues and Conclusions 17

How Do Today s VMs Achieve High Performance? Efficient Memory Management Quick allocation performed in parallel Garbage collection performed in parallel, mostly concurrent w/ app Efficient VM Services Synchronization, method/interface dispatch, etc. Dynamic Compiler ( JIT )... 18

What Is a JIT Compiler? Code generation component of a virtual machine Compilation is interspersed with program execution Program compiled incrementally; unit of compilation is a method Compiler may never see the whole program Must modify traditional notions of IPA (Interprocedural Analysis) 19

Similar to a Traditional Compiler? Build an IR, CFG, SSA, etc. Contains all traditional optimizations SSA-based opts, graph coloring register allocation (HotSpot), etc. Heavy use of inlining Support multiple optimization levels 20

What s the difference? How the JIT is used! To achieve high performance need full suite of optimizations But overhead is too high Compile time == runtime! Systems use selective optimization strategies Assume methods are unimportant until profile says otherwise Use interpreter or dumb compiler initially Use JIT for the subset of important methods eg. Self, HotSpot, IBM VMs, JRocket, ORP, Jikes RVM, etc. Profiling is being used to determine what to compile, i.e., to avoid the bad news of high overhead 21

But it is not all about avoiding bad news Because compilation occurs at runtime, profile information can be used to guide heuristic-based optimizations Similar to offline profile-guided optimization Only requires 1 run! Performed in many systems use branch profiles to infer basic block hotness Input to code layout, register allocation, loop unrolling, etc. 22

Mathematicians vs Gamblers Speculate Hardware Optimization How Prove Traditional Software Optimization Pre-execution Most JIT Optimization at Runtime When 23

Types of Optimization 1. Ahead of time optimization It is never incorrect, prove for every execution 2. Runtime static optimization Will not require invalidation Ex. inlining of final or static methods 3. Speculative optimizations Profile, speculate, invalidate if needed Two flavors: a) True now, but may change Ex. Class hierarchy analysis-based inlining b) True most of the time, but not always Ex. Speculative inlining with invalidation mechanisms JIT world does 2 & 3a, but not much of 3b 24

Outline Why Performance Matters Mathematicians and Gamblers Are Today s VM Gambling Now? A Call for More Gambling Other Issues and Conclusions 25

Speculative Approaches Are Common Hardware/OS Caching, prefetching, scheduling, speculative HW, Within a VM Generational Garbage Collection Assume objects die young until proven otherwise Polymorphic Inline Caches for Virtual Method Invocation Assume call target will be the same as last time Synchronization Assume a lock won t be contended Hashing Assume an object s hashcode won t be requested Selective Optimization Assume a method is not important 26

Why Aren t Speculative Strategies Used More in a JIT? Requires more infrastructure Mechanism to gather profile to speculate on Speculative strategy Invalidation mechanism Detect if speculation is wrong Correct previous strategy Introduces overhead and complexity Most of JIT community are Mathematicians Dynamic compiler looks a lot like a static compiler Dynamic compiler writers look like static compiler writers Contrast this to dynamic binary optimizers Similar problem, but different community Much more gambling occurs! 27

Why Should VMs Be More Speculative? Applications are being composed at runtime, limiting program scope Modern languages are more dynamic, difficult to model Pointers, virtual functions, dynamic class loading, scripting languages Unknown environment Architecture implementation details, unknown libraries Can adapt to application s dynamic behavior Most of underlying system is already speculative Opportunity for better synergy? A necessary step towards empirical optimization Significant performance gain may be possible Ex. Suganuma et al. 02 says don t use any static heuristics for inlining, but instead rely on dynamic data 28

Example 1: Stack Allocation Problem: OO languages encourage creation of many short-lived local objects Complex c = new Complex(3.4, 2.1); foo(c);... Optimization: allocate these objects on the stack rather than the heap (if legal) - reduces pressure on garbage collector - can improve data locality 29

Example 1: Approaches Ahead of time static optimization Perform escape analysis of whole program Proves which objects cannot escape their stack frame Lots of papers, but doesn t work for dynamic language like Java Runtime static optimization Perform local escape analysis on this method (and inlined methods) to prove it cannot escape Conservative assumptions for other calls Speculative [Qian&Hendren 02] 1. Assume the object will not escape 2. Use write barriers to check to see if it does 3. Adjust and learn from result in the future 30

Example 2: Interprocedural Analysis Problem: OO languages encourage small methods Solution: Construct a call graph that represents calling relation among methods Propagate method summary information along call graph Avoid pessimistic assumptions at call sites 31

Example 2: Approaches Ahead of time static optimization Analyze whole program, building a call graph and propagate Lots of papers, but doesn t work for dynamic language like Java Runtime static optimization [Hirzel et al 04] Capture information as methods are compiled Solve interprocedural problem when needed during execution eg. at GC time A form of incremental analysis Speculative [Qian&Hendren 04] 1. Instrument calls to track actual targets, building dynamic call graph 2. Provides speculative interprocedural information to optimizations 3. May need to invalidate 32

Is Static Runtime Analysis a Bad Idea? NO!!! If something can be proven easily, then prove it Ex. Loop invariant code motion However, a speculative approach provides other opportunities Interesting Hybrid Combine static runtime with speculative [Hirzel et al 04] Capture information as methods are compiled But reflective code results are unpredictable Track actual values used in reflective calls and use them as facts 33

Outline Why Performance Matters Mathematicians and Gamblers Are Today s VM Gambling Now? A Call for More Gambling Other Issues and Conclusions 34

Other VM Issues Part 1 Language interoperability Applications in different managed languages? Single VM vs co-operative VMs Managed applications and native applications? How many levels of virtualization do we need? Application server, OS, hypervisor, HW are all in the game Are they even aware of each other? Security & Metadata Reliable, Predictable, Usable Why do we have to specify a heap size? 35

Other VM Issues Part 2 HW Interactions Do HW folks need us now? Return of HW VM, or co-designed VMs Better use of existing HW support in VMs What about phase detection? Hardware solutions are robust Software optimization tend to ignore issue, but have larger scope Dealing with the implementation complexity Layering, non-determinism, etc. Can we speculate without adding complexity? 36

Conclusions VMs are mainstream and are growing in importance Get on board, or watch the train go by SE demands and processor frequency scaling issues require software optimization to deliver performance Dynamic languages require dynamic optimization Current JIT strategies are not gambling enough Speculative software optimization is ripe for research But, we need to deal with the complexity! How can we encourage VM awareness in universities? 37

Appendix Acknowledgements (ideas and inspiration) Matt Arnold, Vas Bala, Bob Blainey, Perry Cheng, Stephen Fink, Dave Grove, Martin Hirzel, Feng Qian, Jim Smith, Mark Stoodley, Peter Sweeney, Mark Wegman, Ben Zorn,... Future of VEE Workshop attendees 2.5 days of slides and video available Brad Calder Additional Resources (available on my web page) Survey paper on Adaptive Optimization in VMs, IEEE Proceedings, Feb 05 by Arnold, Fink, Grove, Hind, Sweeney 3+ hour tutorial on Dynamic Compilation and Adaptive Optimization VEE 05 Conference, June 11-12, Chicago 38