Making Database Applications Perform Using Program Analysis Alvin Cheung Samuel Madden Armando Solar-Lezama MIT Owen Arden Andrew C. Myers Cornell.

Slides:



Advertisements
Similar presentations
Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
Advertisements

Database Performance Tuning and Query Optimization
Constraint Based Synthesis for Beginners PSY 2012 Armando Solar-Lezama.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Programming Creating programs that run on your PC
Embedded SQL John Ortiz. Lecture 15Embedded SQL2 Why Isn’t Interactive SQL Enough?  How to do this using interactive SQL?  Print a well-formatted transcript.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
--What is a Database--1 What is a database What is a Database.
Chapter 4B: More Advanced PL/SQL Programming
Component-Based Software Engineering Introducing the Bank Example Paul Krause.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Management Systems (DBMS)
Module 5: Data Access. Overview Introduce database components involved in data access Introduce concepts of Transact -SQL and Procedural SQL as tools.
Introduction to PL/SQL Chapter 9. Objectives Explain the need for PL/SQL Explain the benefits of PL/SQL Identify the different types of PL/SQL blocks.
Google AppEngine. Google App Engine enables you to build and host web apps on the same systems that power Google applications. App Engine offers fast.
The Client/Server Database Environment
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Rainbow Facilitating Restorative Functionality Within Distributed Autonomic Systems Philip Miseldine, Prof. Taleb-Bendiab Liverpool John Moores University.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Secure Web Applications via Automatic Partitioning Stephen Chong, Jed Liu, Andrew C. Meyers, Xin Qi, K. Vikram, Lantian Zheng, Xin Zheng. Cornell University.
Cloud Computing Other High-level parallel processing languages Keke Chen.
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
1 © 2012 OpenLink Software, All rights reserved. Virtuoso - Column Store, Adaptive Techniques for RDF Orri Erling Program Manager, Virtuoso Openlink Software.
I Copyright © 2004, Oracle. All rights reserved. Introduction Copyright © 2004, Oracle. All rights reserved.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
CSE 3330 Database Concepts Stored Procedures. How to create a user CREATE USER.. GRANT PRIVILEGE.
RELATIONAL FAULT TOLERANT INTERFACE TO HETEROGENEOUS DISTRIBUTED DATABASES Prof. Osama Abulnaja Afraa Khalifah
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
An application architecture specifies the technologies to be used to implement one or more (and possibly all) information systems in terms of DATA, PROCESS,
The Client/Server Database Environment Ployphan Sornsuwit KPRU Ref.
Lesson Overview 3.1 Components of the DBMS 3.1 Components of the DBMS 3.2 Components of The Database Application 3.2 Components of The Database Application.
SECURE WEB APPLICATIONS VIA AUTOMATIC PARTITIONING S. Chong, J. Liu, A. C. Myers, X. Qi, K. Vikram, L. Zheng, X. Zheng Cornell University.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 8 Advanced SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Chapter 4: SQL Complex Queries Complex Queries Views Views Modification of the Database Modification of the Database Joined Relations Joined Relations.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
Dryad and DryaLINQ. Dryad and DryadLINQ Dryad provides automatic distributed execution DryadLINQ provides automatic query plan generation Dryad provides.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
IT System Administration Lesson 3 Dr Jeffrey A Robinson.
Programming Languages
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
CS523 Database Design Instructor : Somchai Thangsathityangkul You can download lecture note at Class Presence 10% Quiz 10%
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
Chapter 13: Query Processing
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
The Client/Server Database Environment
Database Performance Tuning &
Introduction to Databases
New applications of program synthesis
Database Application Development
The Client/Server Database Environment
The Client/Server Database Environment
Imperative languages Most familiar: computation modifies store
Database Performance Tuning and Query Optimization
PL/SQL Scripting in Oracle:
Making synthesis practical Are we there yet?
Introduction to Databases
Chapter 8 Advanced SQL.
Chapter 11 Database Performance Tuning and Query Optimization
Translating Imperative Code into SQL
Database Application Development
Presentation transcript:

Making Database Applications Perform Using Program Analysis Alvin Cheung Samuel Madden Armando Solar-Lezama MIT Owen Arden Andrew C. Myers Cornell

Developing Database Applications 2/1/13NEDB '132 Application Server SQL Database Java Application Logic SQL Query

Developing Database Applications 2/1/13NEDB '133 SQL Database Java Application Logic PL/SQL Stored Procedures SQL Query Application Server

Developing Database Applications 2/1/13NEDB '134 SQL Database Java Application Logic PL/SQL Stored Procedures SQL Query Application Server Language Choice for Application Logic Application Distribution Program analysis to the rescue!

StatusQuo Express application logic in ways that programmers are comfortable with Job of compiler & runtime to determine the most efficient implementation 2/1/13NEDB '135

Two Key Technologies Infer queries from imperative code Migrate computation between servers for optimal performance 2/1/13NEDB '136

Relational Operations in Imperative Code 2/1/13NEDB '137 List getUsersWithRoles () { List users = getUsersFromDB(); List roles = getRolesFromDB(); List results = new ArrayList(); for (User u : users) { for (Role r : roles) { if (u.roleId == r.id) results.add(u); }} return results; } SELECT * FROM user SELECT * FROM role List getUsersWithRoles () { return executeQuery( “SELECT u FROM users u, roles r WHERE u.roleId == r.id ORDER BY u.roleId, r.id”; } convert to

Relational Operations in Imperative Code 2/1/13NEDB '138 List getUsersWithRoles () { List users = getUsersFromDB(); List roles = getRolesFromDB(); List results = new ArrayList(); for (User u : users) { for (Role r : roles) { if (u.roleId == r.id) results.add(u); }} return results; } List getUsersWithRoles () { return executeQuery( “SELECT u FROM users u, roles r WHERE u.roleId == r.id ORDER BY u.roleId, r.id”; } convert to Goal Find a variable that we can rewrite into a SQL expression output variable results

Query By Synthesis (QBS) Identify potential code fragments –i.e., regions of code that fetches persistent data and return values Find SQL expressions for output variables Try to prove that those expressions preserve program semantics –if so, convert the code! 2/1/13NEDB '139

Initial Code Fragments Identification Find program points that retrieve persistent data Run an inter-procedural analysis that: –determine where persistent data are used –delimit code fragment to analyze 2/1/13NEDB '1310

Search for Output Expressions 2/1/13NEDB '1311 List getUsersWithRoles () { List users = query(select * from users); List roles = query(select * from roles); List results = []; for (User u : users) { for (Role r : roles) { if (u.roleId == r.id) results = results : [] }} return results; } Infinite search space size! users roles results

Constraints for Output Expressions 2/1/13NEDB '1312 List getUsersWithRoles () { List users = query(select * from users); List roles = query(select * from roles); List results = []; for (User u : users) { for (Role r : roles) { if (u.roleId == r.id) results = results : [] }} return results; } users roles results If output expression outer loop invariant outer loop terminates thenoutput expression is true and is true Still need a smarter way to search results = π user ( users roleId = id roles ) results = π user ( users[0.. i] roleId = id roles )

Search for Output Expressions and Invariants Use program synthesis as search engine 2/1/13NEDB '1313 Symbolic desc. of search space Solution constraints Expression that satisfies all the constraints Symbolic manipulation Counter-example driven search

Experiments 2/1/13NEDB '1314

Real-world Evaluation 2/1/13NEDB '1315 Wilos (project management application) – 62k LOC Operation type# Fragments found # Fragments converted Projection11 Selection1310 Join77 Aggregation1110 Total3328

Performance Evaluation: Join Query 2/1/13NEDB '1316 Nested-loop join  Hash join! O(n 2 ) O(n)

Developing Database Applications 2/1/13NEDB '1317 SQL Database Java Application Logic PL/SQL Stored Procedures SQL Query Application Server Application Distribution

Running Example discount = executeQuery("select discount from customers where id = " + cid); totalAmount = orderTotal * (1 – discount); credit = executeQuery("select credit from customers where id = " + cid); if (credit < totalAmount) printToConsole("Only " + credit + " in account!"); else executeUpdate("update customer set credit = " + (credit – totalAmount) + " where id = " + cid); 2/1/1318NEDB '13

Actual Execution discount = executeQuery("select discount from customers where id = " + cid); totalAmount = orderTotal * (1 – discount); credit = executeQuery("select credit from customers where id = " + cid); if (credit < totalAmount) printToConsole("Only " + credit + " in account!"); else executeUpdate("update customer set credit = " + (credit – totalAmount) + " where id = " + cid); 2/1/1319NEDB '13 DB APP DB

Actual Execution discount = executeQuery("select discount from customers where id = " + cid); totalAmount = orderTotal * (1 – discount); credit = executeQuery("select credit from customers where id = " + cid); if (credit < totalAmount) printToConsole("Only " + credit + " in account!"); else executeUpdate("update customer set credit = " + (credit – totalAmount) + " where id = " + cid); 2/1/1320NEDB '13 network communication DB APP DB

Speeding up Execution discount = executeQuery("select discount from customers where id = " + cid); totalAmount = orderTotal * (1 – discount); credit = executeQuery("select credit from customers where id = " + cid); if (credit < totalAmount) printToConsole("Only " + credit + " in account!"); else executeUpdate("update customer set credit = " + (credit – totalAmount) + " where id = " + cid); 2/1/1321NEDB '13 DB APP DB

Speeding up Execution discount = executeQuery("select discount from customers where id = " + cid); totalAmount = orderTotal * (1 – discount); credit = executeQuery("select credit from customers where id = " + cid); if (credit < totalAmount) printToConsole("Only " + credit + " in account!"); else executeUpdate("update customer set credit = " + (credit – totalAmount) + " where id = " + cid); 2/1/1322NEDB '13 data dependency DB APP DB control dependency

Speeding up Execution discount = executeQuery("select discount from customers where id = " + cid); totalAmount = orderTotal * (1 – discount); credit = executeQuery("select credit from customers where id = " + cid); if (credit < totalAmount) printToConsole("Only " + credit + " in account!"); else executeUpdate("update customer set credit = " + (credit – totalAmount) + " where id = " + cid); 2/1/1323NEDB '13 DB Server DB APP DB control dependency data dependency

Introducing Pyxis “Store-procedurizes” DB apps and pushes computation to the DB Adaptively controls the amount of computation pushed to DB for optimal performance No programmer intervention required 2/1/1324NEDB '13

Using Pyxis 2/1/13NEDB '1325

How Pyxis Works 2/1/13NEDB '1326 Instrument Partition Monitor App Server DB Server Deploy Java SQL Java SQL Java SQL Java SQL Java SQL Java SQL Java SQL Java SQL Java control transfer

How Pyxis Works 2/1/13NEDB '1327 Monitor App Server DB Server Deploy Java SQL Java SQL Java control transfer Instrument Partition Java SQL Java SQL Java SQL Java SQL Java SQL Java SQL Java

Generating Program Partitions Deploy and profile application as-is Construct a dependence graph of program statements –captures both control and data flow Formulate linear program from profile data and dependence graph –solution gives a partitioning of the source code 2/1/13NEDB '1328

Executing Partitioned Programs Pyxis compiler translates partitioned code into standard Java code Pyxis runtime executes compiled Java code –runtime is just another Java program running on a standard JVM –includes monitoring component to determine partition switching 2/1/13NEDB '1329

Experiments 2/1/13NEDB '1330

Experiment Setup TPC-C Java implementation –20 terminals issuing new order transactions –DB server has 16 cores total –Compared against two implementations: JDBC: everything on app server except for JDBC stmts Manual: custom “store procedurized” implementation where everything is on the DB server 2/1/1331NEDB '13

TPC-C on 16-core DB machine 2/1/1332NEDB '13 Pyxis generated implementation: 3x latency reduction 1.7x thruput increase

StatusQuo Ease DB application development Convert imperative program statements into declarative SQL Fully automatic code partitioning using application and server characteristics db.csail.mit.edu/statusquo 2/1/13NEDB '1333

Backup 2/1/13NEDB '1334