Download - Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Transcript
Page 1: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Generalized Sub-Query Fusion for Eliminating Redundant I/O from Big-Data QueriesKaushik Rajan,

Partho Sarthi, Akash Lal (Microsoft Research)

Abhishek Modi, Ashit Gosalia, Prakhar Jain, Mo Liu, (Microsoft)

Saurabh Kalikar (Intel, interned at Microsoft Research)

Page 2: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Big data query compilation

1 1 1 1

2 2 2 2

Query compilation

SQL Query

Data parallel execution

scheduling/execution exchange

Map 1

Reduce 2

Reduce 3 Execution Plan

Query compilation and execution in big-data systems (Spark, Hadoop, Snowflake, Amazon Redshift, Google

BigQuery, Azure Synapse)

Page 3: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Big data query compilation

1 1 1 1

2 2 2 2

scheduling/execution exchange

Plans with fewer stages preferable

Map 1

Reduce 2

Reduce 3 Execution Plan

Exchanges expensive as they induce disk and network I/O

Data parallel execution

Query compilation

SQL Query

Page 4: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Redundant stages of processing

• TPCDS, 40% of queries have redundant I/O

• 16% of all queries, High-impact spend at least 50% time on stages with redundant I/O

• 9% medium impact, spend 10-50% time on stages with redundant I/O

Redundancy analysis in SPARK on TPCDS

Page 5: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

RESIN: MapReduce reasoning during optimization

State-of-the-art

Logical plan

Physical plan

Map 1

Reduce 2Produce plans with

fewer stages

SQL→SQL+MR

RESIN

MR ops

Logical plan

SQLSQL → SQL rewrites SQL PhyOps,

exchanges Physical plan

Map 1

Reduce 2

Reduce 3

Page 6: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

RESIN: MapReduce reasoning during optimization

Logical plan

SQLSQL → SQL rewrites SQL PhyOps,

exchanges Physical plan

State-of-the-art

Map 1

Reduce 2

Reduce 3

Logical plan

Physical plan

MR opsMap 1

Reduce 2Produce plans with

fewer stages

SQL→SQL+MR

RESIN

1. Subquery Fusion2. Binary elimination

ResinMapResinReduce

Page 7: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Impact of RESIN on I/O and Memory

Page 8: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Rest of the talk

1. ResinMap and ResinReduce

2. Generalized sub-query fusion

3. Implementation on Spark

4. Experimental evaluation

Page 9: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

T1 = SELECT 𝑖𝑑, ℎ𝑟 ← ℎ𝑟1,𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙1

FROM rawLogsWHERE ℎ𝑟1 ≥ 0 ∧ ℎ𝑟1 <

24 ∧ 𝑠𝑖𝑔𝑛𝑎𝑙1 ≥ 0

signals = SELECT * FROM T1UNION ALL

SELECT * FROM T2

Union

Project

iotLogs : (𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

T2 = SELECT 𝑖𝑑, ℎ𝑟 ← ℎ𝑟2,𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙2

FROM rawLogsWHERE ℎ𝑟2 ≥ 0 ∧ ℎ𝑟2 <

24 ∧ 𝑠𝑖𝑔𝑛𝑎𝑙2 ≥ 0

ResinMap[/*1*/{Filter(ℎ𝑟1 ≥ 0 ∧ ℎ𝑟1 < 24 ∧𝑠𝑖𝑔𝑛𝑎𝑙1 ≥ 0)), Cols(id, ℎ𝑟 ← ℎ𝑟1,

𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙1)}, /*2*/{Filter(ℎ𝑟2 ≥ 0 ∧ ℎ𝑟2 < 24 ∧𝑠𝑖𝑔𝑛𝑎𝑙2 ≥ 0), Cols(id, ℎ𝑟 ← ℎ𝑟2,

𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙2)}

(a) SQL Query(b) Standardexecution plan

(c) Optimizedexecution plan

signals

signals

scaniotLogs

I scan iotLogs

FilterProjectFilter

scan iotLogsiotLogs :

(𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

ResinMapA row-wise operator, can produce multiple output rows per input row

Page 10: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

T1 = SELECT 𝑖𝑑, ℎ𝑟 ← ℎ𝑟1,𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙1

FROM rawLogsWHERE ℎ𝑟1 ≥ 0 ∧ ℎ𝑟1 <

24 ∧ 𝑠𝑖𝑔𝑛𝑎𝑙1 ≥ 0

signals = SELECT * FROM T1UNION ALL

SELECT * FROM T2

Union

Project

iotLogs : (𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

T2 = SELECT 𝑖𝑑, ℎ𝑟 ← ℎ𝑟2,𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙2

FROM rawLogsWHERE ℎ𝑟2 ≥ 0 ∧ ℎ𝑟2 <

24 ∧ 𝑠𝑖𝑔𝑛𝑎𝑙2 ≥ 0

ResinMap[/*1*/{Filter(ℎ𝑟1 ≥ 0 ∧ ℎ𝑟1 < 24 ∧𝑠𝑖𝑔𝑛𝑎𝑙1 ≥ 0)), Cols(id, ℎ𝑟 ← ℎ𝑟1,

𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙1)}, /*2*/{Filter(ℎ𝑟2 ≥ 0 ∧ ℎ𝑟2 < 24 ∧𝑠𝑖𝑔𝑛𝑎𝑙2 ≥ 0), Cols(id, ℎ𝑟 ← ℎ𝑟2,

𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙2)}

(a) SQL Query(b) Standardexecution plan

(c) Optimizedexecution plan

signals

signals

scaniotLogs

I scan iotLogs

FilterProjectFilter

scan iotLogsiotLogs :

(𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

ResinMapA row-wise operator, can produce multiple output rows per input row

Page 11: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

ResinMap[/*1*/{Filter(ℎ𝑟1 ≥ 0 ∧ ℎ𝑟1 < 24 ∧𝑠𝑖𝑔𝑛𝑎𝑙1 ≥ 0)), Cols(id, ℎ𝑟 ← ℎ𝑟1,

𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙1)}, /*2*/{Filter(ℎ𝑟2 ≥ 0 ∧ ℎ𝑟2 < 24 ∧𝑠𝑖𝑔𝑛𝑎𝑙2 ≥ 0), Cols(id, ℎ𝑟 ← ℎ𝑟2,

𝑠𝑖𝑔𝑛𝑎𝑙 ← 𝑠𝑖𝑔𝑛𝑎𝑙2)}

signals

scan iotLogs

ResinMapA row-wise operator, can produce multiple output rows per input row

//Each mapper m processes a partition rawlogs[m]Method ResinMap(m) {

foreach 𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2 ∈ 𝑖𝑜𝑡𝐿𝑜𝑔𝑠 𝑚 {if(ℎ𝑟1 ≥ 0 ∧ ℎ𝑟1 < 24 ∧ 𝑠𝑖𝑔𝑛𝑎𝑙1 ≥ 0) {

ℎ𝑟 = ℎ𝑟1; 𝑠𝑖𝑔𝑛𝑎𝑙 = 𝑠𝑖𝑔𝑛𝑎𝑙1; 𝑜𝑢𝑡𝑝𝑢𝑡 𝑖𝑑, ℎ𝑟, 𝑠𝑖𝑔𝑛𝑎𝑙}if(ℎ𝑟2 ≥ 0 ∧ ℎ𝑟2 < 24 ∧ 𝑠𝑖𝑔𝑛𝑎𝑙2 ≥ 0) {

ℎ𝑟 = ℎ𝑟2; 𝑠𝑖𝑔𝑛𝑎𝑙 = 𝑠𝑖𝑔𝑛𝑎𝑙2; 𝑜𝑢𝑡𝑝𝑢𝑡 𝑖𝑑, ℎ𝑟, 𝑠𝑖𝑔𝑛𝑎𝑙}

}

Single table select, project, union queries in one stage

Page 12: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

ResinReduce

𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑖𝑑,s1←max(𝑠𝑖𝑔𝑛𝑎𝑙1)𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑖𝑑,𝑠2←m𝑖𝑛(𝑠𝑖𝑔𝑛𝑎𝑙2)

Join (𝑐1 = 𝑐2)

Project(c1 ← 𝑖𝑑, 𝑠1) Project(c2 ← 𝑖𝑑, 𝑠2)

𝐹𝑖𝑙𝑡𝑒𝑟 (ℎ𝑟1 ≤ 12) 𝐹𝑖𝑙𝑡𝑒𝑟 (ℎ𝑟2 ≤ 18)

iotLogs : (𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

iotLogs : (𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

ResinReduce[(𝑘𝑒𝑦 = 𝑖𝑑),/*1*/{filter(ℎ𝑟1 ≤ 12)), aggregate(

)𝑠1 ←

max(𝑠𝑖𝑔𝑛𝑎𝑙1 , 𝑟𝑐1 ← 𝑐𝑜𝑢𝑛𝑡 ∗ )}/*2*/{ filter(ℎ𝑟2 ≤ 18)aggregate (s2 ←𝑚𝑖𝑛 𝑠𝑖𝑔𝑛𝑎𝑙2 𝑟𝑐2 ← 𝑐𝑜𝑢𝑛𝑡 ∗ )}]

iotLogs : (𝑖𝑑, ℎ𝑟1, 𝑠𝑖𝑔𝑛𝑎𝑙1, ℎ𝑟2, 𝑠𝑖𝑔𝑛𝑎𝑙2)

(Filter(𝑟𝑐1 > 0 ∧ 𝑟𝑐2 > 0)

Eliminate multiple shuffles from single table join queries

Filter( ℎ𝑟1 ≤ 12 ∨ ℎ𝑟2 ≤ 18)

Project(𝑖𝑑, 𝑠𝑖𝑔𝑛𝑎𝑙1) Project(𝑖𝑑, 𝑠𝑖𝑔𝑛𝑎𝑙2)

Key based operator, process rows sharing key, produce one row

Page 13: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

ResinReduce[(𝑘𝑒𝑦 = 𝑖𝑑),/*1*/{filter, aggregate}/*2*/{ filter,aggregate}]

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Filter(𝜙4)(ℎ𝑡))

Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑)

𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,s1←max(𝑠𝑖𝑔𝑛𝑎𝑙) 𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,𝑠2←max(𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑐1 = 𝑐2)

Scan signals Scan signals Scan dInfo

Filter(𝜙1(ℎ𝑟)) Filter(𝜙2(ℎ𝑟))

Project(id, 𝑠𝑖𝑔𝑛𝑎𝑙) Project(id, 𝑠𝑖𝑔𝑛𝑎𝑙)

Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑)

Scan dInfo

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Filter(𝜙3(ℎ𝑡))

S1 S2

S3

S4

S5 S6

S7 S8

S9

Project(c1 ← 𝑐𝑖𝑡𝑦, 𝑠1) Project(c2 ← 𝑐𝑖𝑡𝑦, 𝑠2)

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Filter( 𝜙1 ∧ 𝜙3 ∨ (𝜙2 ∧ 𝜙4)(ℎ𝑟, ℎ𝑡)

Filter(𝜙1 ∨ 𝜙2(ℎ𝑟))

Project(id,signal,hr) Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑,ht)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙, ℎ𝑟, ℎ𝑡)

S10

Filter(𝜙3 ∨ 𝜙4(ℎ𝑡))

Scan dInfoScan signals

S11

S12

S13

Sub-query fusion

Eliminate scans/shuffles from multi-table queries

Page 14: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Filter(𝜙4(ℎ𝑡))

Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑)

Scan signals Scan signals Scan dInfo

Filter(𝜙1(ℎ𝑟)) Filter(𝜙2(ℎ𝑟))

Project(id, 𝑠𝑖𝑔𝑛𝑎𝑙) Project(id, 𝑠𝑖𝑔𝑛𝑎𝑙)

Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑)

Scan dInfo

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Filter(𝜙3(ℎ𝑡))

S2

S3

S4

Filter(𝜙1 ∨ 𝜙2(ℎ𝑟))

Project(id,signal,hr) Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑,ht)

S10

Filter(𝜙3 ∨ 𝜙4(ℎ𝑡))

Scan dInfoScan signals

S11

Sub-query fusion

Eliminate scans/shuffles from multi-stage queries

Filter(𝜙1(ℎ𝑟)) Filter(𝜙2(ℎ𝑟))

S1

Filter(𝜙1 ∧ 𝜙3) Filter(𝜙2 ∧ 𝜙4)

𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,s1←max(𝑠𝑖𝑔𝑛𝑎𝑙) 𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,𝑠2←max(𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑐1 = 𝑐2)

Project(c1 ← 𝑐𝑖𝑡𝑦, 𝑠1) Project(c2 ← 𝑐𝑖𝑡𝑦, 𝑠2)

Page 15: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Sub-query fusion

Eliminate scans/shuffles from multi-stage queries

Filter(𝜙1 ∨ 𝜙2(ℎ𝑟))

Project(id,signal,hr) Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑,ht)

Filter(𝜙3 ∨ 𝜙4(ℎ𝑡))

Scan dInfoScan signals

Filter(𝜙1(ℎ𝑟)) Filter(𝜙2(ℎ𝑟))Filter(𝜙1 ∧ 𝜙3) Filter(𝜙2 ∧ 𝜙4)

S5 S6

Join (𝑑𝑖𝑑 = 𝑖𝑑)Filter( 𝜙1 ∧ 𝜙3 ∨ (𝜙2 ∧ 𝜙4)(ℎ𝑟, ℎ𝑡)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙, ℎ𝑟, ℎ𝑡)

Filter(𝜙1 ∧ 𝜙3) Filter(𝜙2 ∧ 𝜙4)

S12

𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,s1←max(𝑠𝑖𝑔𝑛𝑎𝑙) 𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,𝑠2←max(𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑐1 = 𝑐2)

Project(c1 ← 𝑐𝑖𝑡𝑦, 𝑠1) Project(c2 ← 𝑐𝑖𝑡𝑦, 𝑠2)

Page 16: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,s1←max(𝑠𝑖𝑔𝑛𝑎𝑙) 𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,𝑠2←max(𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑐1 = 𝑐2)

Project(c1 ← 𝑐𝑖𝑡𝑦, 𝑠1) Project(c2 ← 𝑐𝑖𝑡𝑦, 𝑠2)

Sub-query fusion

Eliminate scans/shuffles from multi-stage queries

Filter(𝜙1 ∨ 𝜙2(ℎ𝑟))

Project(id,signal,hr) Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑,ht)

Filter(𝜙3 ∨ 𝜙4(ℎ𝑡))

Scan dInfoScan signals

Join (𝑑𝑖𝑑 = 𝑖𝑑)Filter( 𝜙1 ∧ 𝜙3 ∨ (𝜙2 ∧ 𝜙4)(ℎ𝑟, ℎ𝑡)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙, ℎ𝑟, ℎ𝑡)

Filter(𝜙1 ∧ 𝜙3) Filter(𝜙2 ∧ 𝜙4)

S7 S8

S9S13

ResinReduce[(𝑘𝑒𝑦 = 𝑐𝑖𝑡𝑦),/*1*/{filter(𝜙1 ∧ 𝜙3), aggregate(

)𝑠1 ←

max(𝑠𝑖𝑔𝑛𝑎𝑙 , 𝑟𝑐1 ← 𝑐𝑜𝑢𝑛𝑡 ∗ )}/*2*/{ filter(𝜙2 ∧ 𝜙4)

aggregate (s2 ← 𝑚𝑎𝑥 𝑠𝑖𝑔𝑛𝑎𝑙 𝑟𝑐2 ←𝑐𝑜𝑢𝑛𝑡 ∗ )}]

(Filter(𝑟𝑐1 > 0 ∧ 𝑟𝑐2 > 0)

Page 17: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Filter(𝜙4)(ℎ𝑡))

Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑)

𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,s1←max(𝑠𝑖𝑔𝑛𝑎𝑙) 𝐺𝑟𝑜𝑢𝑝𝐵𝑦𝑐𝑖𝑡𝑦,𝑠2←max(𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑐1 = 𝑐2)

Scan signals Scan signals Scan dInfo

Filter(𝜙1(ℎ𝑟)) Filter(𝜙2(ℎ𝑟))

Project(id, 𝑠𝑖𝑔𝑛𝑎𝑙) Project(id, 𝑠𝑖𝑔𝑛𝑎𝑙)

Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑)

Scan dInfo

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙)

Filter(𝜙3(ℎ𝑡))

S1 S2

S3

S4

S5 S6

S7 S8

S9

Project(c1 ← 𝑐𝑖𝑡𝑦, 𝑠1) Project(c2 ← 𝑐𝑖𝑡𝑦, 𝑠2)

Join (𝑑𝑖𝑑 = 𝑖𝑑)

Filter( 𝜙1 ∧ 𝜙3 ∨ (𝜙2 ∧ 𝜙4)(ℎ𝑟, ℎ𝑡)

Filter(𝜙1 ∨ 𝜙2(ℎ𝑟))

Project(id,signal,hr) Project(𝑐𝑖𝑡𝑦, 𝑑𝑖𝑑,ht)

Project(𝑐𝑖𝑡𝑦, 𝑠𝑖𝑔𝑛𝑎𝑙, ℎ𝑟, ℎ𝑡)

S10

Filter(𝜙3 ∨ 𝜙4(ℎ𝑡))

Scan dInfoScan signals

S11

S12

S13

Sub-query fusion

Eliminate scans/shuffles from multi-table queries

ResinReduce[(𝑘𝑒𝑦 = 𝑐𝑖𝑡𝑦),/*1*/{filter(𝜙1 ∧ 𝜙3), aggregate(

)𝑠1 ←

max(𝑠𝑖𝑔𝑛𝑎𝑙 , 𝑟𝑐1 ← 𝑐𝑜𝑢𝑛𝑡 ∗ )}/*2*/{ filter(𝜙2 ∧ 𝜙4)

aggregate (s2 ← 𝑚𝑎𝑥 𝑠𝑖𝑔𝑛𝑎𝑙 𝑟𝑐2 ←𝑐𝑜𝑢𝑛𝑡 ∗ )}]

(Filter(𝑟𝑐1 > 0 ∧ 𝑟𝑐2 > 0)S13

Page 18: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

In the paper

•Parameters for ResinMap and ResinReduceoperators, semantics and implementation

• Fusing of operators without increasing the number of rows shuffled

• Fusion rules for all sparkSQL operators, conditions under which fusion is possible

Page 19: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Rest of the talk

1. ResinMap and ResinReduce

2. Generalized sub-query fusion

3. Implementation on Spark

4. Experimental evaluation

Page 20: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Implementation

Implemented RESIN on catalyst optimizer in SPARK 2.4

1. Added logical and physical operators for ResinMap andResinReduce

2. Added a new batch of optimization rules• Perform fusion in a single traversal of the tree

• Perform Union and Join elimination by checking fused parent

• Introduce exchanges if parent after fusion cannot be eliminated

3. Added implementations for our operators with codegen support

Page 21: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Evaluation

• Evaluated with TPCDS at 1TB and 10TB scale, data stored in parquet

• Two different clusters <120 cores, 480 GB memory> and <480 cores, 1.6TB memory>

• Detailed evaluation of 40 (out of 104) queries with redundant I/O

• Note: baseline that already has basic I/O optimizations (predicate and project pushdown to store, exchange reuse)

Page 22: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Speedup at 1TB

Page 23: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Impact of RESIN on I/O and Memory

Page 24: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Conclusions

•Big-data optimizers produce plans with redundant I/O and compute

•Proposed optimizer extensions to perform first class map-reduce reasoning

•Added generic map and reduce operators, rewrites that fuse stages and eliminate redundant I/O

•Demonstrated savings in terms of latency, disk and network I/O

Page 25: Generalized Sub-Query Fusion for Eliminating Redundant I/O ...

Thank You

Email [email protected] or any of the other authors to contact us