CoCo: Sound and Adaptive Replacement of Java Collections Guoqing (Harry) Xu Department of Computer Science University of California, Irvine.

Slides:



Advertisements
Similar presentations
Uncovering Performance Problems in Java Applications with Reference Propagation Profiling PRESTO: Program Analyses and Software Tools Research Group, Ohio.
Advertisements

ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Collections Chapter Java Collection Frameworks The Java collection framework is a set of utility classes and interfaces. Designed for working with.
Data Structures A data structure is a collection of data organized in some fashion that permits access to individual elements stored in the structure This.
Resurrector: A Tunable Object Lifetime Profiling Technique Guoqing Xu University of California, Irvine OOPSLA’13 Conference Talk 1.
– Advanced Programming P ROGRAMMING IN Lecture 16 Interfaces.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
CS 106 Introduction to Computer Science I 04 / 27 / 2007 Instructor: Michael Eckmann.
© 2006 Pearson Addison-Wesley. All rights reserved16-1 Methods in the List Interface (Part 1 of 16)
Data Structures & Java Collections Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L15 (Chapter 22) Java Collections.
Lists in Java Part of the Collections Framework. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection.
Detecting Inefficiently-Used Containers to Avoid Bloat Guoqing Xu and Atanas Rountev Department of Computer Science and Engineering Ohio State University.
Composing Dataflow Analyses and Transformations Sorin Lerner (University of Washington) David Grove (IBM T.J. Watson) Craig Chambers (University of Washington)
CACHETOR Detecting Cacheable Data to Remove Bloat Khanh Nguyen Guoqing Xu UC Irvine USA.
Chapter 19 Java Data Structures
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Java Collections Framework A presentation by Eric Fabricant.
FEN 2012UCN Technology - Computer Science 1 Data Structures and Collections Principles revisited.NET: –Two libraries: System.Collections System.Collections.Generics.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
Semantics-Aware Performance Optimization Harry Xu CS Departmental Seminar 01/13/2012.
The Java Collections Framework (JCF) Introduction and review 1.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Chapter 18 Java Collections Framework
Chameleon Automatic Selection of Collections Ohad Shacham Martin VechevEran Yahav Tel Aviv University IBM T.J. Watson Research Center Presented by: Yingyi.
CSE 373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks; Eclipse.
Data structures Abstract data types Java classes for Data structures and ADTs.
1/20/03A2-1 CS494 Interfaces and Collection in Java.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
Static Detection of Loop-Invariant Data Structures Harry Xu, Tony Yan, and Nasko Rountev University of California, Irvine Ohio State University 1.
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Ordered Linked Lists using Abstract Data Types (ADT) in Java Presented by: Andrew Aken.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
COMP 121 Week 8: Generic Collections. Objectives To understand type variables and how they are used in generic programming To be able to implement and.
Detecting Inefficiently-Used Containers to Avoid Bloat Guoqing Xu and Atanas Rountev Department of Computer Science and Engineering Ohio State University.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Thomas Kuehne.
Slides prepared by Rose Williams, Binghamton University Chapter 16 Collections and Iterators.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CMSC 202 Containers and Iterators. Container Definition A “container” is a data structure whose purpose is to hold objects. Most languages support several.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
Collections Dwight Deugo Nesa Matic
Enabling Control over Adaptive Program Transformation for Dynamically Evolving Mobile Software Validation Mike Jochen, Anteneh Anteneh, Lori Pollock University.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java From Control Structures through Data Structures by.
1 CS162: Introduction to Computer Science II Abstract Data Types.
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Using the Java Collection Libraries COMP 103 # T2
Lecture 23:More on Interfaces
Sixth Lecture ArrayList Abstract Class and Interface
Chapter 19 Java Data Structures
Fundamentals of Java: AP Computer Science Essentials, 4th Edition
JAVA COLLECTIONS LIBRARY
JAVA COLLECTIONS LIBRARY
CACHETOR Detecting Cacheable Data to Remove Bloat
Java Collections Overview
Arrays and Collections
ArrayLists 22-Feb-19.
Collections Framework
Introduction to Data Structure
Web Design & Development Lecture 6
Presentation transcript:

CoCo: Sound and Adaptive Replacement of Java Collections Guoqing (Harry) Xu Department of Computer Science University of California, Irvine

Performance Concerns Programming with abstractions – Modern languages exhibit clear separation between abstractions and implementations – Developers are trained to use abstractions without knowing how they are implemented Pervasive use of large-scale, enterprise-level applications – Layers of libraries and frameworks – Inappropriate choices of implementations lead performance problems

Semantic Inefficiencies Performance problems caused by developers’ inappropriate choices and mistakes Semantics-agnostic optimizations cannot optimize them away – JIT optimizations do not help – Human insight is required Develop semantics-aware optimizations

Container Inefficiencies Inappropriate choice of containers is an important source of bloat Examples Use HashSet to store very few elements ArraySet or SingletonSet Call many get(i) on a LinkedList ArrayList …

Optimizing Containers Container semantics required – Different design and implementation rationales Chameleon – an offline approach [PLDI 2009] – Profile container usage – Report problematic container choices – Make recommendations Make it online? – remove burden from developers completely – Appears to be an impossible task – Soundness – how to provide consistency guarantee – Performance – how to reduce switch overhead

Nothing Is Impossible The CoCo approach – Users specify replacement rules, e.g., LinkedList ArrayList if #get(i) > X – CoCo switches implementations at run time CoCo is an application-level approach that performs optimizations via pure Java code – Manually modified container code – Automatically generated glue code Goal: reduce running time by exploiting algorithmic advantages of different implementations

CoCo System Overview 1. Manually modify container classes to make them CoCo- optimizable 2.Use CoCo static compiler to generate glue code and compile it with the optimizable container classes 3.Run the program No work is needed for end developers

The CoCo Methodology CoCo works only for same-interface optimizations – LinkedList can be replaced only with another List (that implement java.util.List) For each allocation of container type c, create a group of other containers {c 1, c 2, c 3 } LinkedList l = new LinkedList(); LinkedList ArrayList Hash ArrayList XYZList Active Inactive Container Combo

Soundness All operations are performed only on the active container When an object is added into the active container, its abstraction is added into inactive containers LinkedList ArrayList Hash ArrayList XYZList Active Inactive Combo add(o) get() addAbstraction(α) Inactive

Soundness Once a switch rule evaluates to true, an inactive container becomes active If an abstraction is located by a retrieval, it is concretized to provide safety guarantee LinkedList ArrayList Hash ArrayList XYZList active Inactive Combo Inactive o α α α if #get(i) > X LinkedList ArrayList get() α concretize o

Optimizable Container Classes class LinkedList implements List { void add (Object o) { //actual stuff } Object get (int index) {//actual stuff } } class ArrayList implements List { void add (Object o) { //actual stuff } Object get (int index) { //actual stuff } } class ListCombo implements List { void add(Object o) { } Object get(int index) { } $CoCo void add (Object o) {combo.add(o);} ListCombo combo = … ; Object get (int index) { return combo.get(index);} void add (Object o) {combo.add(o);} ListCombo combo = … ; Object get (int index) { return combo.get(index);} List active = …; List[] inactiveList = …; active.add$CoCo(o); Object o = active.get$CoCo(index); Manually modified Automatically generated for each l in inactiveList { l.addAbstract(α); } If (o instanceof Abstraction) { o = active.concretize(o, index); } return o;

Optimizable Container Classes LinkedList l = new LinkedList(); create combo create inactive lists l.add(o); call forward dispatch

Perform Online Container Switch Change field active to the appropriate container The client still interfaces with the original container class ListCombo implements List { void add(Object o) { } Object get(int index) { } active.add$CoCo(o); … Object o = active.get$CoCo(index); … void profileAndReplace(int oprType) { switch(oprType) { //profiling case ADD: ADD_OPR++; break; case GET: GET_OPR++; break; } //rules if (GET_OPR > X && active instanceof LinkedList) swap(active, inactive[i]); // inactive[i] is ArrayList } profileAndReplace(ADD); profileAndReplace(GET);

Abstraction An abstraction is a placeholder for a set of concrete elements – Container specific – Its granularity influences performance Two simple ways to define abstractions – Most fine-grained: One abstraction for each element – Most coarse-grained: One abstraction for all elements

Our Abstractions We have modified 4 containers from the Java Collections Framework and implemented 3 from the scratch – List – ArrayList, LinkedList, and HashArrayList Map – HashMap and ArrayMap Set – HashSet and ArraySet – The same set of switch rules as used in Chameleon For List, an abstraction contains – Host container ID – Indices of a range of elements it represents

Abstraction and Concretization Functions List – Update existing abstractions or create a new abstraction upon an add – Concretization first splits an retrieved abstraction and brings back exactly one element requested by the client For Map and Set, one single abstraction is used to represent all concrete elements

Implementation Modify Jikes RVM to do the instrumentation – Replace each new java.util.X (…) with new coco.util.X (…) in both the baseline and the optimizing compiler Optimizations – Dropping combo – Sampling – Lazy creation of inactive containers – Aggressively inline CoCo-related methods

Evaluation Micro-benchmarks – 75X faster for one benchmark after switching from ArrayList to HashArrayList Five large-scale (DaCapo) applications – bloat, chart, fop, lusearch, and avrora – 1/50 sampling rate : profileAndReplace is invoked once per 50 calls to add/get – 14.6% speedup on average at the cost of 18.8% space overhead

Conclusions A semantics-aware bloat removal technique Developer insight is encoded by – Replacement rules – Abstraction and concretization functions Future dynamic optimization research – Develop more semantics-aware optimization techniques

Thanks You Q/A

Optimizations Do HelpO