Top Banner
How to make queries go fast and play nice with parallel languages Brandon Myers Department of Computer Science & Engineering University of Washington
47

How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Mar 18, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

How to make queries go fast

and play nice with parallel languages

Brandon Myers Department of Computer Science & Engineering

University of Washington

Page 2: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Parallel query processing

MPPxR. S. Xin et al. Shark: Sql and rich analytics at scale. SIGMOD 13

A. Pavlo et al. A comparison of approaches to large-scale data analysis. In SIGMOD, 2009.

Page 3: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Parallel query processing

MPPx < + compilation

R. S. Xin et al. Shark: Sql and rich analytics at scale. SIGMOD 13

A. Pavlo et al. A comparison of approaches to large-scale data analysis. In SIGMOD, 2009.

MPPx

Page 4: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Eliminating overheads

M. Zukowski, P. A. Boncz, N. Nes, and S. Heman. MonetDB/X100 - a DBMS in the CPU cache. IEEE Data Eng. Bull., 28(2) 17–22, 2005.

Page 5: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Eliminating overheads

M. Zukowski, P. A. Boncz, N. Nes, and S. Heman. MonetDB/X100 - a DBMS in the CPU cache. IEEE Data Eng. Bull., 28(2) 17–22, 2005.

Page 6: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Eliminating overheads

M. Zukowski, P. A. Boncz, N. Nes, and S. Heman. MonetDB/X100 - a DBMS in the CPU cache. IEEE Data Eng. Bull., 28(2) 17–22, 2005.

Page 7: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Eliminating overheads

M. Zukowski, P. A. Boncz, N. Nes, and S. Heman. MonetDB/X100 - a DBMS in the CPU cache. IEEE Data Eng. Bull., 28(2) 17–22, 2005.

Page 8: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compiling for distributed machines

select&R.a&*&R.b,&R.b,&S.b&from&R,S&where&R.b&=&S.a

for&r&in&R&&store(hash(r))

while&pull()&&insert(r.b,&r)

machine&code

program generation

sequentialcompiler

Page 9: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compiling for distributed machines

select&R.a&*&R.b,&R.b,&S.b&from&R,S&where&R.b&=&S.a

for&r&in&R&&store(hash(r))

while&pull()&&insert(r.b,&r)

machine&code

program generation

sequentialcompiler

Page 10: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compiling for distributed machines

select&R.a&*&R.b,&R.b,&S.b&from&R,S&where&R.b&=&S.a

for&r&in&R&&store(hash(r))

while&pull()&&insert(r.b,&r)

machine&code

program generation

sequentialcompiler

Page 11: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compiling for distributed machines

select&R.a&*&R.b,&R.b,&S.b&from&R,S&where&R.b&=&S.a

for&r&in&R&&store(hash(r))

while&pull()&&insert(r.b,&r)

machine&code

for&r&in&R&&on&partition(hash(r))&&&&insert(r.b,&r)

machine&code

program generation

sequentialcompiler

parallelcompiler

Page 12: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Scan(R)

Scan(S)

Shuffle(h(b), (t,b)) Shuffle(h(a), (a,b))

HashJoin(R.b=S.a)

Emit(t, R.b, S.b)

Apply(t = a*b)

Example

Scan(R) Scan(S)

Shuffle(h(b), (a,b)) Shuffle(h(a), (a,b))

HashJoin(R.b=S.a)

Apply(t = R.a*R.b)

Emit(t, R.b, S.b)

Page 13: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Scan(R)

Scan(S)

Shuffle(h(b), (t,b)) Shuffle(h(a), (a,b))

HashJoin(R.b=S.a)

Emit(t, R.b, S.b)

Apply(t = a*b)

Example

Scan(R) Scan(S)

Shuffle(h(b), (a,b)) Shuffle(h(a), (a,b))

HashJoin(R.b=S.a)

Apply(t = R.a*R.b)

Emit(t, R.b, S.b) ?

Page 14: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Partitioned global address space (PGAS)

programming model • shared memory with partitions • parallel tasks: loops, spawns • remote calls

Global data

DRAM DRAM DRAM DRAM

Core Core Core Core

Network

Global Tasks

Page 15: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Example…revisited

for$r$in$R:$

$t$=$(r.a*r.b)$$for$s$in$lookup(r.b)$$$$emit$t,$r.b,$s.b

Scan(R) Scan(S)

HashJoin(R.b=S.a)

Apply(t = R.a*R.b)

Emit(t, R.b, S.b)

Page 16: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Example…revisited

for$r$in$R:$

$t$=$(r.a*r.b)$$for$s$in$lookup(r.b)$$$$emit$t,$r.b,$s.b

for$r$in$R:$t$=$(r.a*r.b)$

$$for$s$in$lookup(r.b)$$$$$emit$t,$r.b,$s.b

Page 17: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

for$r$in$R:$

on$partition$[$hash(r.b)$]$t$=$(r.a*r.b)$$$for$s$in$lookup(r.b)$

$$$$emit$t,$r.b,$s.b

for$r$in$R:$t$=$(r.a*r.b)$on$partition$[$hash(r.b)$]$$$for$s$in$lookup(r.b)$$$$$emit$t,$r.b,$s.b

Example…revisited

Page 18: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

for$r$in$R:$

on$partition$[$hash(r.b)$]$t$=$(r.a*r.b)$$$for$s$in$lookup(r.b)$

$$$$emit$t,$r.b,$s.b

for$r$in$R:$t$=$(r.a*r.b)$on$partition$[$hash(r.b)$]$$$for$s$in$lookup(r.b)$$$$$emit$t,$r.b,$s.b

Example…revisited

Page 19: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Outline

• Motivation

• New technique for [query -> PGAS]

• Implementation of Radish

• Performance results

Page 20: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compilation to PGAS

Page 21: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compilation to PGAS

Page 22: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Compilation to PGAS

Page 23: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Code for 1 pipeline

parallel$for$each$t0$in$cnt_table$$$on$partition(join_table[t0.a_id])$$$$$parallel$for$each$t1$in$join_table[t0.id]$$$$$$$output$Tuple(t1,$t0)

HTProbe[a_id=id]

HTAggregateScan

Project[*]

h(a_id)

Page 24: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Parallel tasks

Page 25: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Parallel tasks

Page 26: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Parallel tasks

xx x

x

Page 27: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Inter-pipeline coordination• relation-grain (coarse) synchronization

• tuple-grain (fine) synchronization

Page 28: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Join

ScanSelect

Scan

Join

Scan

emit

Relation-grain synchronization

Page 29: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Hash table join

ScanSelect

Scan

Hash table join

Scan

emit

Relation-grain synchronization

Page 30: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Build

ScanSelect

Scan

Build

Scan

emit

Probe

Probe

Relation-grain synchronization

Page 31: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Build

ScanSelect

Scan

Build

Scan

emit

Probe

Probe

Relation-grain synchronization

task0.sync

task1.sync

Page 32: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Tuple-grain synchronization

Join

ScanSelect

Scan

Join

Scan

emit

Page 33: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Symmetric hash join

ScanSelect

Scan

Scan

emit

Symmetric hash join

Tuple-grain synchronization

Page 34: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

I+L left

ScanSelect

Scan

Scan

emit

I+L right

I+L left I+L left

emit

I+L right

emit

Tuple-grain synchronization

Page 35: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Symmetric hash join

core0

core1

core2

core3

Left Right

(1,6) (1,5), (1,9)pipeL pipeR

Page 36: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Symmetric hash join

core0

core1

core2

core3

Left Right

(1,6)

(1,6)

(1,0)

(1,5), (1,9)pipeL pipeR

Page 37: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Interface to parallel code

global tuple * results global tuple * results

local local local local

Page 38: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Implementation of Radish

PGAScompile

Datalog

SQL Logical plan

Distributed plan

PGAS code

machine code

pipeline code gen

optimize

PGASruntime

RadishXlibraries

Radishphysical

plan

MyriaL optimizeoptimize

Raco Radish

GrappaX10

Page 39: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Evaluation• How does the performance of Radish compare to

another in-memory query processing system for analytical queries?

• RADISHX backend built upon Grappa

• Compare to Shark: SQL on Spark

• input and output tables in memory

Page 40: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Graph data benchmark: Sp2bench

5.3x 16x

large input to many joins

{authors} x {authors}

0

2

4

6

Q3b Q3c Q1 Q3aQuery

Run

time

(s)

RadishXShark

41.4x

small input to joins

Page 41: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Execution breakdown

0

5

10

15

RadishX Shark

Tim

e (s

ec)

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20Cumulative time

Rel

ative

tim

e fo

r eac

h sy

stem

componentnetwork/messagingserializationiterationschedulerapplication

system grappa shark

0

5

10

15

RadishX Shark

Tim

e (s

ec)

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20Cumulative time

Rel

ative

tim

e fo

r eac

h sy

stem

componentnetwork/messagingserializationiterationschedulerapplication

system grappa shark

Page 42: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Network comparison

0

5

10

15

RadishX Shark

Tim

e (s

ec)

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20Cumulative time

Rel

ative

tim

e fo

r eac

h sy

stem

componentnetwork/messagingserializationiterationschedulerapplication

system grappa shark

0

5

10

15

RadishX Shark

Tim

e (s

ec)

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20Cumulative time

Rel

ative

tim

e fo

r eac

h sy

stem

componentnetwork/messagingserializationiterationschedulerapplication

system grappa shark

Page 43: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

CPU time comparison

0

5

10

15

RadishX Shark

Tim

e (s

ec)

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20Cumulative time

Rel

ative

tim

e fo

r eac

h sy

stem

componentnetwork/messagingserializationiterationschedulerapplication

system grappa shark

0

5

10

15

RadishX Shark

Tim

e (s

ec)

0.00

0.25

0.50

0.75

1.00

0 5 10 15 20Cumulative time

Rel

ative

tim

e fo

r eac

h sy

stem

componentnetwork/messagingserializationiterationschedulerapplication

system grappa shark

Page 44: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Takeaways• compiling queries is an effective approach to

mitigating the CPU bottleneck

• we described a technique to generate code for distributed memory systems by leveraging parallel languages

• our system, RADISH, outperforms a state-of-the-art distributed data analysis platform

get the code! RACO+RADISH: github.com/uwescience/raco GRAPPA: grappa.io

Grappa talk today 1:30pm CSE403

Page 45: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

People

Dan Halperin

Brandon Holt

Jacob Nelson

Bill Howe

Andrew Whitaker Vincent Lee

Luis Ceze

Simon Kahan

Mark Oskin

eScience Grappa

Page 46: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

backups

Page 47: How to make queries go fast and play nice with parallel ...homepage.cs.uiowa.edu/~bdmyers/papers/myers_affiliates_talk_radish_2014.pdf · Applicability • no fault tolerance as is,

Applicability• no fault tolerance as is, so not a replacement when

nodes are likely to fail during query

• fault tolerance akin to RDD lineage could be applied atop shared memory

• RADISHX compilation time averages 19s for Sp2bench. Until this is improved, Radish is most applicable for repetitive (like classifier) or sufficiently long running queries

• also, there’s room for improvement in compilation time