for Complex Analy;cal Queries Milos Nikolic, Mohammed El - - PowerPoint PPT Presentation

for complex analy cal queries
SMART_READER_LITE
LIVE PREVIEW

for Complex Analy;cal Queries Milos Nikolic, Mohammed El - - PowerPoint PPT Presentation

LINVIEW: Incremental View Maintenance for Complex Analy;cal Queries Milos Nikolic, Mohammed El Seidy, Christoph Koch DATA, EPFL SIGMOD,


slide-1
SLIDE 1

¡ ¡ ¡ LINVIEW: ¡Incremental ¡View ¡Maintenance ¡ for ¡Complex ¡Analy;cal ¡Queries ¡

¡ Milos ¡Nikolic, ¡Mohammed ¡El ¡Seidy, ¡Christoph ¡Koch ¡ DATA, ¡EPFL ¡ ¡ SIGMOD, ¡24th ¡June ¡2014 ¡

¡ ¡ ¡ ¡ ¡

slide-2
SLIDE 2

Big ¡Data ¡Analy;cs ¡

2 ¡

Machine Learning Data Mining Scientific Computing

Simple (SQL) Analytics Complex (non-SQL) Analytics

Data Warehouses (OLAP)

slide-3
SLIDE 3

Complex ¡Analy;cal ¡Queries ¡

§ ORen ¡expressed ¡as ¡linear ¡algebra ¡on ¡array ¡data ¡

¡

¡

¡

§ Mul;dimensional ¡arrays ¡

HIGH ¡DIMENSIONAL: ¡Data ¡processing ¡is ¡increasingly ¡expensive ¡ DYNAMIC: ¡Con;nuously ¡changing, ¡evolve ¡through ¡small ¡changes ¡

(e.g., ¡user’s ¡Internet ¡ac;vity) ¡

§ Users ¡want ¡frequently ¡fresh ¡views ¡of ¡data ¡

3 ¡

Example: Ordinary Least Squares Y = X β β* = (XT X)-1 XT Y X, Y, β, β* matrices

Re-­‑evalua;ng ¡complex ¡queries ¡on ¡ every ¡(small) ¡change ¡is ¡inefficient ¡ ¡ => ¡Do ¡it ¡incrementally! ¡

slide-4
SLIDE 4

Result Dataset

Incremental ¡Processing ¡

Incremental ¡View ¡Maintenance ¡(IVM) ¡in ¡DBMS ¡(Oracle, ¡DB2, ¡PostgreSQL, ¡…) ¡

4 ¡

+ =

Recomputation Update Expensive! Delta Cheaper Computation SQL query

slide-5
SLIDE 5

LINVIEW ¡

¡

Incremental ¡evalua;on ¡of ¡(itera;ve) ¡linear ¡algebra ¡programs ¡

¡

5 ¡

INCREMENTAL ¡ MAINTENANCE ¡ OPTIMIZER ¡ CODE ¡GENERATOR ¡

LINVIEW compiler

APL-style programs

Exec over dynamic data Different runtimes (Spark, Octave) For instance: MATLAB, R, Octave Matrix operations (+/-­‑, ¡*, ¡AT, ¡A-­‑1) Basis of ML algos

Incremental programs

slide-6
SLIDE 6

+

0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ -­‑2 ¡ 0 ¡ 0 ¡ 0 ¡

Example: ¡Matrix ¡Powers ¡A4 ¡

0 ¡ -­‑1 ¡ 5 ¡ 3 ¡ 4 ¡ 1 ¡

  • ­‑2 ¡

1 ¡ -­‑3 ¡

6 ¡

A ¡ ΔA ¡

0 ¡ -­‑1 ¡ 5 ¡ 3 ¡ 4 ¡ -­‑1 ¡

  • ­‑2 ¡

1 ¡ -­‑3 ¡

A ¡+ ¡ΔA ¡

¡35 ¡ -­‑47 ¡ 224 ¡ ¡154 ¡ ¡254 ¡ ¡64 ¡

  • ­‑87 ¡ 51 ¡ -­‑96 ¡

C ¡

57 ¡ -­‑43 ¡ 224 ¡ 112 ¡ 200 ¡ -­‑56 ¡

  • ­‑93 ¡

39 ¡ -­‑80 ¡

C ¡+ ¡ΔC ¡

Incremental Program ΔB ¡= ¡... ¡ ΔC ¡= ¡... ¡ B ¡+= ¡ΔB ¡ C ¡+= ¡ΔC ¡ 22 ¡ 4 ¡ 0 ¡

  • ­‑42 ¡ -­‑54 ¡-­‑120 ¡
  • ­‑6 ¡ -­‑12 ¡

16 ¡

ΔC ¡ O(n3) ¡

Delta Matrix B ¡= ¡A ¡A ¡ C ¡= ¡B ¡B ¡

+ = =

O(n2) ¡ O(n3) ¡

A ¡= ¡A ¡+ ¡ΔA ¡ B ¡= ¡A ¡A ¡ C ¡= ¡B ¡B ¡

slide-7
SLIDE 7

IVM ¡of ¡Linear ¡Algebra ¡

7 ¡

How ¡to ¡ ¡ ¡ ¡… ¡derive ¡delta ¡expressions? ¡ ¡ ¡… ¡evaluate ¡delta ¡expressions? ¡ ¡ ¡… ¡represent ¡delta ¡expressions? ¡

¡ON ¡UPDATE ¡A ¡BY ¡ΔA: ¡ ¡ ¡ ¡A ¡+= ¡ΔA ¡ ¡ ¡ ¡B ¡= ¡A ¡A ¡ ¡ ¡ ¡C ¡= ¡B ¡B ¡ ¡ON ¡UPDATE ¡A ¡BY ¡ΔA: ¡ ¡ ¡ ¡ΔB ¡= ¡A(ΔA) ¡+ ¡(ΔA)A ¡+ ¡(ΔA)(ΔA) ¡ ¡ ¡ ¡ΔC ¡= ¡B(ΔB) ¡+ ¡(ΔB)B ¡+ ¡(ΔB)(ΔB) ¡ ¡ ¡ ¡A ¡+= ¡ΔA ¡ ¡ ¡ ¡B ¡+= ¡ΔB ¡ ¡ ¡ ¡C ¡+= ¡ΔC ¡

O(n3) O(n2)

… when ΔA is “simple”

slide-8
SLIDE 8

Delta ¡Deriva;on ¡

§ Exploits ¡proper;es ¡of ¡matrix ¡opera;ons ¡

(e.g., ¡distribu;vity ¡of ¡matrix ¡mul;plica;on ¡over ¡addi;on) ¡

¡

Example: ¡

¡ ¡ ¡ ¡ ¡B[A] ¡= ¡A ¡A ¡ ¡ ¡ ¡ ¡(consider ¡B ¡as ¡a ¡function ¡of ¡A) ¡ ¡ ¡ ¡ ¡ ¡ΔB[A,ΔA] ¡= ¡B[A ¡+ ¡ΔA] ¡– ¡B[A] ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡(A ¡+ ¡ΔA)(A ¡+ ¡ΔA) ¡– ¡A ¡A ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡A(ΔA) ¡+ ¡(ΔA)A ¡+ ¡(ΔA)(ΔA) ¡

¡

§ The ¡Sherman–Morrison ¡formula ¡for ¡maintaining ¡(A ¡+ ¡ΔA)-­‑1 ¡

8 ¡

slide-9
SLIDE 9

How ¡to ¡confine ¡the ¡avalanche ¡effect? ¡

A ¡single-­‑entry ¡change ¡contaminates ¡the ¡whole ¡output ¡=> ¡Ω(n2) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Delta ¡computa;on ¡involves ¡O(n3) ¡matrix ¡mul;plica;on ¡ ¡ ¡ ¡ ¡ ¡IVM ¡loses ¡its ¡performance ¡benefit ¡over ¡re-­‑evalua;on ¡

Delta ¡Evalua;on: ¡The ¡Avalanche ¡Effect ¡

9 ¡

0 ¡ -­‑1 ¡ 5 ¡ 3 ¡ 4 ¡ 1 ¡

  • ­‑2 ¡

1 ¡ -­‑3 ¡

A ¡

0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ -­‑2 ¡ 0 ¡ 0 ¡ 0 ¡

ΔA ¡

0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ -­‑2 ¡ 0 ¡ 0 ¡ 0 ¡

ΔA ¡

0 ¡ -­‑1 ¡ 5 ¡ 3 ¡ 4 ¡ -­‑1 ¡

  • ­‑2 ¡

1 ¡ -­‑3 ¡

A ¡+ ¡ΔA ¡

0 ¡ 0 ¡ 2 ¡ 4 ¡ -­‑2 ¡ -­‑2 ¡ 0 ¡ 0 ¡ -­‑2 ¡

ΔB ¡

  • ­‑13 ¡

1 ¡-­‑16 ¡ 10 ¡ 14 ¡ 16 ¡ 9 ¡ 3 ¡ 0 ¡

B ¡

0 ¡ 0 ¡ 2 ¡ 4 ¡ -­‑2 ¡ -­‑2 ¡ 0 ¡ 0 ¡ -­‑2 ¡

ΔB ¡

0 ¡ 0 ¡ 2 ¡ 4 ¡ -­‑2 ¡ -­‑2 ¡ 0 ¡ 0 ¡ -­‑2 ¡

ΔB ¡

  • ­‑13 ¡

1 ¡ -­‑14 ¡ 14 ¡ 12 ¡ 14 ¡ 9 ¡ 3 ¡ -­‑2 ¡

B ¡+ ¡ΔB ¡

22 ¡ 4 ¡ 0 ¡

  • ­‑42 ¡ -­‑54 ¡ -­‑120 ¡
  • ­‑6 ¡ -­‑12 ¡

16 ¡

ΔC ¡

+ = + =

slide-10
SLIDE 10

Delta ¡Representa;on ¡

§ Deltas ¡as ¡single ¡matrices ¡

✗ ¡ ¡quickly ¡escalate ¡to ¡full ¡matrices, ¡involve ¡O(n3) ¡ops ¡ ¡ ¡

§ Insight: ¡delta ¡matrices ¡have ¡low ¡ranks ¡

✓ represent ¡as ¡vector ¡outer ¡products ¡

§ Factored ¡representa;on ¡admits ¡efficient ¡evalua;on ¡

10 ¡

ΔA ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡u ¡vT ¡

0 ¡ 1 ¡ 0 ¡ 0 ¡ 0 ¡ -­‑2 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ 0 ¡ -­‑2 ¡ 0 ¡ 0 ¡ 0 ¡

slide-11
SLIDE 11

Revisited: ¡Matrix ¡Powers ¡A4 ¡

11 ¡

ΔA ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡u ¡vT ¡ ¡ ΔB ¡= ¡ ¡ A ¡ u ¡ + ¡ ¡ vT ¡ ¡ ¡ ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡+ ¡ ¡ u ¡ vT ¡ A ¡ ¡ + ¡... ¡ ¡

O(n2) ¡ O(n2) ¡

0 ¡ 0 ¡ 2 ¡ 4 ¡ -­‑2 ¡ -­‑2 ¡ 0 ¡ 0 ¡ -­‑2 ¡

ΔC ¡= ¡a ¡sum ¡of ¡4 ¡outer ¡products ¡ ¡ Delta ¡computa;on ¡involves ¡only ¡O(n2) ¡opera;ons! ¡ ¡= ¡ ¡

ΔA ¡is a rank-1 update (e.g., changes of one row/column)

rank-s, efficient when s << n

slide-12
SLIDE 12

§ Many ¡programs ¡in ¡prac;ce ¡converge ¡within ¡only ¡a ¡few ¡itera;ons ¡ ¡ ¡ ¡ ¡ ¡(e.g., ¡80.7% ¡of ¡pages ¡in ¡PageRank ¡converge ¡in ¡less ¡than ¡15 ¡itera;ons1) ¡

¡

§ Example: ¡ ¡ ¡Ti ¡= ¡f(A, ¡B, ¡Ti-­‑1) ¡= ¡A ¡Ti-­‑1 ¡+ ¡B ¡

¡

[1] ¡S. ¡Kamvar, ¡T. ¡Haveliwala, ¡and ¡G. ¡Golub. ¡Adap;ve ¡methods ¡for ¡the ¡computa;on ¡of ¡PageRank. ¡Technical ¡report, ¡Stanford, ¡2003 ¡

T1 ¡ T2 ¡ Tk ¡ . . . f ¡ A,B ¡ f ¡ T0 ¡ Tk ¡

IVM ¡of ¡Itera;ve ¡Programs ¡

  • 1. Materialize
  • 2. Derive deltas
  • 3. Update

States Iterative function Init Result T’1 ¡ T’2 ¡ T’k ¡ . . . f ¡ A+ΔA,B ¡ f ¡ T0 ¡ T’k ¡ Δf ¡ Δf ¡ Δf ¡

Incremental ¡ evalua;on ¡

Re-­‑evalua;on ¡(expensive!) ¡

slide-13
SLIDE 13

Time ¡Complexity ¡

(rank-­‑1 ¡updates, ¡big-­‑O ¡nota;on) ¡

Re-­‑evalua(on ¡ Incremental ¡ maintenance ¡

Ordinary ¡Least ¡Squares ¡ n3 ¡

n2 ¡

Matrix ¡Powers ¡Ak ¡ n3 ¡log ¡k ¡ n2 ¡k ¡ Ti+1 ¡= ¡A ¡Ti ¡+ ¡B ¡ where ¡T ¡= ¡(n ¡x ¡n) ¡ n3 ¡log ¡k ¡ n2 ¡k ¡ Ti+1 ¡= ¡A ¡Ti ¡+ ¡B ¡ where ¡T ¡= ¡(n ¡x ¡1) ¡ n2 ¡k ¡ n2 ¡k ¡

13 ¡

A – dimension (n x n) k – number of iterations

IVM ¡has ¡lower ¡;me ¡ complexity ¡in ¡most ¡cases! ¡ But ¡increases ¡memory ¡consump;on ¡(log ¡k ¡;mes, ¡details ¡in ¡paper) ¡

slide-14
SLIDE 14

Experimental ¡Setup ¡

§ Analy;cs: ¡OLS, ¡matrix ¡powers, ¡GD ¡for ¡lin. ¡regression, ¡… ¡ § Apache ¡Spark ¡

  • EC2 ¡cluster: ¡100 ¡workers ¡(8 ¡vCPUs, ¡13.6GB ¡RAM, ¡10GbE) ¡

§ GNU ¡Octave ¡

  • 2 ¡x ¡2.66GHz ¡6-­‑Core ¡Intel ¡Xeon, ¡64GB ¡RAM ¡

§ Randomly ¡generated ¡dense ¡matrices ¡

  • Precondi;oned ¡for ¡numerical ¡stability ¡

§ Stream ¡of ¡rank-­‑1 ¡updates ¡

  • Each ¡update ¡affects ¡one ¡row ¡of ¡the ¡input ¡matrix ¡

14 ¡

slide-15
SLIDE 15

0 ¡ 200 ¡ 400 ¡ 600 ¡ 800 ¡ 1000 ¡ 1200 ¡ 9 ¡ 16 ¡ 25 ¡ 36 ¡ 49 ¡ 64 ¡ 81 ¡ 100 ¡

  • Avg. ¡Time ¡(Sec) ¡/ ¡View ¡Refresh ¡

Number ¡of ¡Workers ¡ Re-­‑evalua;on ¡ Incremental ¡

15 ¡

Matrix ¡Powers ¡– ¡Scalability ¡(nodes) ¡

¡

A16 ¡using ¡Spark, ¡updates ¡to ¡A ¡= ¡(30K ¡x ¡30K) ¡

26 14 ¡ 12 ¡ 14 ¡ 13 ¡ 11 ¡ 10 ¡ 16 ¡

slide-16
SLIDE 16

16 ¡

0 ¡ 200 ¡ 400 ¡ 600 ¡ 800 ¡ 1000 ¡ 1200 ¡ 1400 ¡ 10K ¡ 20K ¡ 30K ¡ 40K ¡ 50K ¡ 60K ¡ 70K ¡ 80K ¡ 90K ¡ 100K ¡

  • Avg. ¡Time ¡(Sec) ¡/ ¡View ¡Refresh ¡

Dimension ¡Size ¡(n) ¡ Re-­‑evalua;on ¡ Incremental ¡

5.5x 10x 31.8x 53.3x

The ¡performance ¡gap ¡increases ¡with ¡higher ¡dimensionality! ¡

10bn entries

Matrix ¡Powers ¡– ¡Scalability ¡(dimension) ¡

¡

A16 ¡using ¡100 ¡Spark ¡workers, ¡updates ¡to ¡A ¡= ¡(n ¡x ¡n) ¡

14.4x ¡

slide-17
SLIDE 17

0 ¡ 50 ¡ 100 ¡ 150 ¡ 200 ¡ 250 ¡ 300 ¡ 4K ¡ 8K ¡ 10K ¡ 16K ¡ 20K ¡

  • Avg. ¡Time ¡(Sec) ¡/ ¡View ¡Refresh ¡

Dimension ¡Size ¡(n) ¡ Re-­‑evalu;on ¡ Incremental ¡

17 ¡

6.3x 10.6x 11.5x

Ordinary ¡Least ¡Squares ¡ ¡ ¡

β* ¡= ¡(XT ¡X)-­‑1 ¡XT ¡Y ¡

¡

GNU ¡Octave, ¡updates ¡to ¡X ¡= ¡(n ¡x ¡n), ¡β*,Y ¡= ¡(n ¡x ¡1) ¡

5.2x 3.6x

slide-18
SLIDE 18

LINVIEW: ¡Recap ¡

§ Incremental ¡computa;on ¡of ¡analy;cal ¡queries ¡expressed ¡ as ¡linear ¡algebra ¡programs ¡ § Factored ¡delta ¡representa;on ¡

¡ As ¡(sums ¡of ¡) ¡vector ¡outer ¡products ¡ ¡ Confines ¡the ¡avalanche ¡effect ¡ ¡ ¡ Admits ¡efficient ¡evalua;on ¡

§ IVM ¡has ¡lower ¡;me ¡complexity ¡than ¡re-­‑evalua;on ¡

  • Can ¡outperform ¡re-­‑evalua;on ¡by ¡orders ¡of ¡magnitude ¡

¡ ¡

hyp://data.epfl.ch/linview ¡

18 ¡

ΔA ¡= ¡