Optimizing Big-Data Queries using Program Synthesis

Slides:



Advertisements
Similar presentations
Computations with Big Image Data Phuong Nguyen Sponsor: NIST 1.
Advertisements

SkewReduce YongChul Kwon Magdalena Balazinska, Bill Howe, Jerome Rolia* University of Washington, *HP Labs Skew-Resistant Parallel Processing of Feature-Extracting.
LIBRA: Lightweight Data Skew Mitigation in MapReduce
© Hortonworks Inc Daniel Dai Thejas Nair Page 1 Making Pig Fly Optimizing Data Processing on Hadoop.
Manish Bhide, Manoj K Agarwal IBM India Research Lab India {abmanish, Amir Bar-Or, Sriram Padmanabhan IBM Software Group, USA
Distributed Computations
Design Patterns for Efficient Graph Algorithms in MapReduce Jimmy Lin and Michael Schatz University of Maryland Tuesday, June 29, 2010 This work is licensed.
1 External Sorting for Query Processing Yanlei Diao UMass Amherst Feb 27, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Jingren Zhou, Per-Ake Larson, Ronnie Chaiken ICDE 2010 Talk by S. Sudarshan, IIT Bombay Some slides from original talk by Zhou et al. 1.
Hadoop & Cheetah. Key words Cluster  data center – Lots of machines thousands Node  a server in a data center – Commodity device fails very easily Slot.
Hadoop Team: Role of Hadoop in the IDEAL Project ●Jose Cadena ●Chengyuan Wen ●Mengsu Chen CS5604 Spring 2015 Instructor: Dr. Edward Fox.
Advanced Topics: MapReduce ECE 454 Computer Systems Programming Topics: Reductions Implemented in Distributed Frameworks Distributed Key-Value Stores Hadoop.
USING HADOOP & HBASE TO BUILD CONTENT RELEVANCE & PERSONALIZATION Tools to build your big data application Ameya Kanitkar.
Interpreting the data: Parallel analysis with Sawzall LIN Wenbin 25 Mar 2014.
Database Management 9. course. Execution of queries.
An Introduction to HDInsight June 27 th,
MC 2 : Map Concurrency Characterization for MapReduce on the Cloud Mohammad Hammoud and Majd Sakr 1.
BlinkDB: Queries with Bounded Errors and Bounded Response Times on Very Large Data ACM EuroSys 2013 (Best Paper Award)
ApproxHadoop Bringing Approximations to MapReduce Frameworks
MapReduce: Simplified Data Processing on Large Clusters By Dinesh Dharme.
Lecture 3 - Query Processing (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad university- Mashhad Branch
Practical Hadoop: do’s and don’ts by example Kacper Surdy, Zbigniew Baranowski.
Lecture 3 – MapReduce: Implementation CSE 490h – Introduction to Distributed Computing, Spring 2009 Except as otherwise noted, the content of this presentation.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Integration of Oracle and Hadoop: hybrid databases affordable at scale
TensorFlow– A system for large-scale machine learning
Big Data is a Big Deal!.
MapReduce “MapReduce allows us to stop thinking about fault tolerance.” Cathy O’Neil & Rachel Schutt, 2013.
Efficient Evaluation of XQuery over Streaming Data
Seth Pugsley, Jeffrey Jestes,
Optimizing Parallel Algorithms for All Pairs Similarity Search
Distributed Programming in “Big Data” Systems Pramod Bhatotia wp
Running TPC-H On Pig Jie Li, Koichi Ishida, Muzhi Zhao, Ralf Diestelkaemper, Xuan Wang, Yin Lin CPS 216: Data Intensive Computing Systems Dec 9, 2011.
Database Management System
Scaling SQL with different approaches
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing MapReduce - Introduction Dr. Xiao Qin Auburn.
Kay Ousterhout, Christopher Canel, Sylvia Ratnasamy, Scott Shenker
Building Analytics At Scale With USQL and C#
Abstract Major Cloud computing companies have started to integrate frameworks for parallel data processing in their product portfolio, making it easy for.
Evaluation of Relational Operations
Verification of Concurrent Programs
MapReduce Computing Paradigm Basics Fall 2013 Elke A. Rundensteiner
Introduction to Spark.
Database Applications (15-415) Hadoop Lecture 26, April 19, 2016
MapReduce Simplied Data Processing on Large Clusters
On Spatial Joins in MapReduce
Cse 344 May 2nd – Map/reduce.
February 26th – Map/Reduce
Lecture 12: Data Wrangling
Cse 344 May 4th – Map/Reduce.
SETL: Efficient Spark ETL on Hadoop
Akshay Tomar Prateek Singh Lohchubh
SQL: Structured Query Language
Lecture 2- Query Processing (continued)
CSE 491/891 Lecture 24 (Hive).
Analysis of Algorithms
Overview of Query Evaluation
Probabilistic Databases
Introduction to MapReduce
CS222P: Principles of Data Management Notes #13 Set operations, Aggregation, Query Plans Instructor: Chen Li.
Incremental Problem Solving for CS1100
DryadInc: Reusing work in large-scale computations
Analysis of Algorithms
COS 518: Distributed Systems Lecture 11 Mike Freedman
MapReduce: Simplified Data Processing on Large Clusters
Software Development Techniques
Analysis of Algorithms
Query Transformations
Analysis of Structured or Semi-structured Data on a Hadoop Cluster
Jiasi Shen, Martin Rinard MIT EECS & CSAIL
Presentation transcript:

Optimizing Big-Data Queries using Program Synthesis Kaushik Rajan Matthias Schlaipfer, Akash Lal, Malavika Samak Microsoft Research, India

Why is query optimization important Many BigData jobs are SQL Millions of SCOPE jobs a day, billions of compute minutes ~80% of all jobs on Azure’s Spark and Hadoop offerings are SQL Massive clusters deployed, huge cost and resource consumption Better query optimization can lead to significant savings

Big-Data query optimization Rules to rewrite SQL queries to other equivalent SQL queries Rules have limited applicability, miss optimization opportunities that involve non-SQL operators Query script Rule driven query optimization DAG of Map/Reduce Stages

Big-Data query optimization Rules to rewrite SQL queries to other equivalent SQL queries Rules have limited applicability, miss optimization opportunities that involve non-SQL operators Query script Rule driven query optimization DAG of Map/Reduce Stages Program Synthesis Synthesize query specific non-SQL operators on the fly Generate query plans with fewer stages

sum(blobBytes) as bSum,… sum (pageBytes) as pSum Example StoreLog GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum Input:<id,use,dt,blobBytes,pageBytes…> Query Intent For each use,date pair count the number of request ids that access 100MB of blob data and count the number of request ids that access 100MB of page data use, dt, id, bSum, pSum WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt … use, dt, cnt, “blob” use, dt, cnt, “page” output UNION use, dt, cnt, type Production Query

sum(blobBytes) as bSum,… sum (pageBytes) as pSum Example SV1 Extract 1000 vertices StoreLog Data Read 3TB GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum Group By 1TB SV2 Agg 1000 vertices use, dt, id, bSum, pSum Data Read 1TB WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt 560GB 510GB … SV3 Agg 500 vertices SV4 Extract 500 vertices use, dt, cnt, “blob” Group By use, dt, cnt, “page” Data Read 560GB 420GB 280GB Rule driven Data Read 510GB output 240GB 160GB UNION Union SV5 Extract 250 vertices use, dt, cnt, type Execution plan Production Query Data Read 400GB

sum(blobBytes) as bSum,… sum (pageBytes) as pSum Example SV1 Extract 1000 vertices StoreLog Data Read 3TB GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum Group By 1TB SV2 Agg 1000 vertices use, dt, id, bSum, pSum Data Read 1TB WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt 560GB 510GB … SV3 Agg 500 vertices SV4 Extract 500 vertices use, dt, cnt, “blob” Group By use, dt, cnt, “page” Data Read 560GB 420GB 280GB Rule driven Data Read 510GB output 240GB 160GB UNION Union SV5 Extract 250 vertices use, dt, cnt, type Execution plan Production Query Data Read 400GB Many stages dominated by a single stage, shuffles inhibit parallelism and performance

sum(blobBytes) as bSum,… sum (pageBytes) as pSum Example SV1 Extract 1000 vertices StoreLog Data Read 3TB GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum Group By 1TB SV2 Agg 1000 vertices use, dt, id, bSum, pSum Data Read 1TB WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt 560GB 510GB … SV3 Agg 500 vertices SV4 Extract 500 vertices use, dt, cnt, “blob” Group By use, dt, cnt, “page” Data Read 560GB 420GB 280GB Rule driven Data Read 510GB output 240GB 160GB UNION Union SV5 Extract 250 vertices use, dt, cnt, type Execution plan Production Query Data Read 400GB Every row in output only influenced by few rows from input, here input can be partitioned on use,dt Many stages dominated by a single stage, shuffles inhibit parallelism and performance

sum(blobBytes) as bSum,… sum (pageBytes) as pSum Example StoreLog GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum StoreLog use, dt, id, bSum, pSum PARTITION BY use,dt SORT BY ??=id use, dt, List<id, blobBytes,pageBytes> WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt … use, dt, cnt, “blob” use, dt, cnt, “page” Query template Final output ??? UNION use, dt, cnt, type use, dt, cnt, type partial rewrite Production Query Can we replace with a simpler query that partitions the input and applies a custom operator equivalent to the query?

sum(blobBytes) as bSum,… sum (pageBytes) as pSum Example StoreLog GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum StoreLog use, dt, id, bSum, pSum PARTITION BY use,dt SORT BY ??=id use, dt, List<id, blobBytes,pageBytes> WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt … use, dt, cnt, “blob” use, dt, cnt, “page” Program Synthesis Query template Final output udo UNION use, dt, cnt, type use, dt, cnt, type partial rewrite Production Query Can we replace with a simpler query that partitions the input and applies a custom operator equivalent to the query?

Example Execution plan 3.5x faster, shuffles 1/3rd the data, StoreLog SV1 Extract 1000 vertices PARTITION BY use,dt SORT BY id=c use, dt, List<id, blobBytes,pageBytes> Data Read 3TB 1TB SV5 Extract 250 vertices Final Data Read 1TB udo use, dt, cnt, type Execution plan 3.5x faster, shuffles 1/3rd the data, Requires only half the cumulative CPU time

Rest of the talk Program synthesis Scaling synthesis via program analysis Evaluation

Program Synthesis Given a specification, a partial program, generate a complete program that satisfies the specification Uses SAT/SMT solvers to find satisfying assignments Possible because of advances in program reasoning, verification and SAT solving Hard to scale synthesis to large programs (scales only to 10s of lines) Typical reducers are about this size so there is hope

Program synthesis for query optimization Query simplification Partial program Specification Generic template generation standard SQL operator implementations Grammar extraction Operator synthesis

Program synthesis for query optimization Input PARTITION by <c> SORT by ??=c Query simplification UDO(use,dt, List rows) { //Linear Complexity foreach(row in partition) if(pred1) expr1; ... if(predn) exprn; foreach(row) … } Partial program Specification Generic template generation Final standard SQL operator implementations UDO Grammar extraction Operator synthesis

Program synthesis for query optimization Input PARTITION by <c> SORT by ??=c Query simplification UDO(use,dt, List rows) { //Linear Complexity foreach(row in partition) if(pred1) expr1; ... if(predn) exprn; foreach(row) … } Partial program Specification Generic template generation Final standard SQL operator implementations UDO Grammar extraction Operator synthesis Sort columns, predicates and expressions extracted via static analysis of query

Program synthesis for query optimization StoreLog sort : id,blobBytes,pageBytes expri:pSum=0|pSum+=blobBytes| bSum=0|bSum+=blobBytes| cnt1=0|cnt1++| cnt2=0|cnt2++ out(row)|prevRow=row flagi=true/false predi :bSum>100 | pSum>100 !pred | pred AND/OR pred flag|prevRow[c]==row[c] GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum use, dt, id, bSum, pSum WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt Extract grammar … use, dt, cnt, “blob” use, dt, cnt, “page” output UNION use, dt, cnt, type sufficient to emulate aggregations in the query, can do more, multiple aggregations in the same loop

Program synthesis for query optimization StoreLog sort : id,blobBytes,pageBytes expri:pSum=0|pSum+=blobBytes| bSum=0|bSum+=blobBytes| cnt1=0|cnt1++| cnt2=0|cnt2++ out(row)|prevRow=row flagi=true/false predi :bSum>100 | pSum>100 !pred | pred AND/OR pred flag|prevRow[c]==row[c] GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum use, dt, id, bSum, pSum WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt Extract grammar … use, dt, cnt, “blob” use, dt, cnt, “page” output UNION use, dt, cnt, type sufficient to emulate aggregations in the query, can do more, multiple aggregations in the same loop Additional power, for example allow some flag variables

PARTITION by <c> SORT by ??=c Input PARTITION by <c> SORT by ??=c id,blobBytes,pageBytes UDO(use,dt,rows) { foreach(row in rows) if(pred1) expr1; ... if(predn) exprn; foreach(row) … } pSum=0|pSum+=pBytes| bSum=0|bSum+=bBytes| cnt1=0|cnt1++| cnt2=0|cnt2++| out(row)|prevRow=row| flagi=true/false ⊆ bSum>100 | pSum>100| !pred | pred AND/OR pred| flag|prevRow[c]==row[c]

Scaling synthesis Example query still does not work One of our more complex examples Too many predicates and expressions in grammar Operator still quite large, needs many guarded statements Reasoning about n-ary (n>3) operators like joins and unions leads to blow up in size of the specification (formulae to be solved) Query Query simplification specification Partial program operator synthesis

Query simplification Synthesize UDO incrementally one part at a time Input GROUP BY use, dt, c sum(blobBytes)…, sum(pageBytes) use, dt, id, Taint analysis removes cols that don’t influence output. WHERE bSum > 100 GROUP BY use, dt count(id) as cnt StoreLog Splitting use, dt, id, “blob” GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum Redundant column analysis removes dt as it always occurs with use use, dt, id, bSum, pSum WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt … use, dt, cnt, “blob” use, dt, cnt, “page” Synthesize UDO incrementally one part at a time output UNION use, dt, cnt, type

Query simplification Synthesize UDO incrementally one part at a time Input GROUP BY use, dt, c sum(blobBytes)…, sum(pageBytes) use, dt, id, Taint analysis removes cols that don’t influence output. WHERE bSum > 100 GROUP BY use, dt count(id) as cnt StoreLog Splitting use, dt, id, “blob” GROUP BY use, dt, id sum(blobBytes) as bSum,… sum (pageBytes) as pSum Redundant column analysis removes dt as it always occurs with use use, dt, id, bSum, pSum WHERE bSum > 100 GROUP BY use, dt count(id) as cnt WHERE pSum > 100 GROUP BY use, dt count(id) as cnt … use, dt, cnt, “blob” use, dt, cnt, “page” Synthesize UDO incrementally one part at a time output UNION use, dt, cnt, type

Query simplification Reassemble full operator

Rest of the talk Program synthesis Scaling synthesis via program analysis Evaluation 20 long running and hourly repeating SCOPE queries

Execution time Synthesis fails on one query, succeeds on 19 within 10 min

Resource savings (SCOPE) Task time Shuffled data

Open challenge Synthesis relies on bounded model checking Only guarantees partial soundness, requires manual verification of UDO Our experience has been very positive (no erroneous UDOs), small world assumption holds in practise Applicability Identifies potential problems and suggest a likely correct fix Readily applies to repeat queries optimize them over time by involving users Amortize verification cost over repeated runs Be brief… defend along the lines of paper

Summary New technique for optimizing BigData queries Significant speedups on evaluated benchmarks Demonstrate program synthesis can be applied to a important and non-standard setting New analyses for SQL queries to scale synthesis Several new open problems Further scaling synthesis Full verification Other query optimization problems Be brief… defend along the lines of paper

Thank You