large-scale graph processing · graph-parallel processing i restrictsthetypes of computation. i new...

164
Large-Scale Graph Processing Amir H. Payberah Swedish Institute of Computer Science [email protected] May 13-15, 2014 Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 1 / 116

Upload: others

Post on 03-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Large-Scale Graph Processing

Amir H. PayberahSwedish Institute of Computer Science

[email protected] 13-15, 2014

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 1 / 116

Page 2: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 2 / 116

Page 3: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Introduction

I Graphs provide a flexible abstraction for describing relationships be-tween discrete objects.

I Many problems can be modeled by graphs and solved with appro-priate graph algorithms.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 3 / 116

Page 4: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Large Graph

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 4 / 116

Page 5: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Large-Scale Graph Processing

I Large graphs need large-scale processing.

I A large graph either cannot fit into memory of single computer orit fits with huge cost.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 5 / 116

Page 6: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Question

Can we use platforms like MapReduce or Spark, which are based on data-parallel

model, for large-scale graph proceeding?

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 6 / 116

Page 7: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data-Parallel Model for Large-Scale Graph Processing

I The platforms that have worked well for developing parallel applica-tions are not necessarily effective for large-scale graph problems.

I Why?

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 7 / 116

Page 8: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Algorithms Characteristics (1/2)

I Unstructured problems

• Difficult to extract parallelism based on partitioning of the data: theirregular structure of graphs.

• Limited scalability: unbalanced computational loads resulting frompoorly partitioned data.

I Data-driven computations

• Difficult to express parallelism based on partitioning of computation:the structure of computations in the algorithm is not known a priori.

• The computations are dictated by nodes and links of the graph.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 8 / 116

Page 9: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Algorithms Characteristics (1/2)

I Unstructured problems

• Difficult to extract parallelism based on partitioning of the data: theirregular structure of graphs.

• Limited scalability: unbalanced computational loads resulting frompoorly partitioned data.

I Data-driven computations

• Difficult to express parallelism based on partitioning of computation:the structure of computations in the algorithm is not known a priori.

• The computations are dictated by nodes and links of the graph.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 8 / 116

Page 10: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Algorithms Characteristics (2/2)

I Poor data locality

• The computations and data access patterns do not have much local-ity: the irregular structure of graphs.

I High data access to computation ratio

• Graph algorithms are often based on exploring the structure of agraph to perform computations on the graph data.

• Runtime can be dominated by waiting memory fetches: low locality.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 9 / 116

Page 11: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Algorithms Characteristics (2/2)

I Poor data locality

• The computations and data access patterns do not have much local-ity: the irregular structure of graphs.

I High data access to computation ratio

• Graph algorithms are often based on exploring the structure of agraph to perform computations on the graph data.

• Runtime can be dominated by waiting memory fetches: low locality.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 9 / 116

Page 12: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Proposed Solution

Graph-Parallel Processing

I Computation typically depends on the neighbors.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 10 / 116

Page 13: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Proposed Solution

Graph-Parallel Processing

I Computation typically depends on the neighbors.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 10 / 116

Page 14: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph-Parallel Processing

I Restricts the types of computation.

I New techniques to partition and distribute graphs.

I Exploit graph structure.

I Executes graph algorithms orders-of-magnitude faster than moregeneral data-parallel systems.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 11 / 116

Page 15: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data-Parallel vs. Graph-Parallel Computation

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 12 / 116

Page 16: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data-Parallel vs. Graph-Parallel Computation

I Data-parallel computation• Record-centric view of data.• Parallelism: processing independent data on separate resources.

I Graph-parallel computation• Vertex-centric view of graphs.• Parallelism: partitioning graph (dependent) data across processing

resources, and resolving dependencies (along edges) throughiterative computation and communication.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 13 / 116

Page 17: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Outline

I Pregel

I GraphLab

I PowerGraph

I GraphX

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 14 / 116

Page 18: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 15 / 116

Page 19: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Seven Bridges of Konigsberg

I Finding a walk through the city that would cross each bridge onceand only once.

I Euler proved that the problem has no solution.

Map of Konigsberg in Euler’s time, highlighting the river Pregel and the bridges.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 16 / 116

Page 20: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Pregel

I Large-scale graph-parallel processing platform developed at Google.

I Inspired by bulk synchronous parallel (BSP) model.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 17 / 116

Page 21: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Bulk Synchronous Parallel (1/2)

I It is a parallel programming model.

I The model consists of:• A set of processor-memory pairs.• A communications network that delivers messages in a point-

to-point manner.• A mechanism for the efficient barrier synchronization for all or

a subset of the processes.• There are no special combining, replicating, or broadcasting fa-

cilities.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 18 / 116

Page 22: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Bulk Synchronous Parallel (2/2)

All vertices update in parallel (at the same time).

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 19 / 116

Page 23: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Vertex-Centric Programs

I Think like a vertex.

I Each vertex computes individually its value: in parallel

I Each vertex can see its local context, and updates its value accord-ingly.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 20 / 116

Page 24: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Model

I A directed graph that stores the program state, e.g., the currentvalue.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 21 / 116

Page 25: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (1/3)

I Applications run in sequence of iterations: supersteps

I During a superstep, user-defined functions for each vertex is invoked(method Compute()): in parallel

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending mes-sages.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 22 / 116

Page 26: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (1/3)

I Applications run in sequence of iterations: supersteps

I During a superstep, user-defined functions for each vertex is invoked(method Compute()): in parallel

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending mes-sages.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 22 / 116

Page 27: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (1/3)

I Applications run in sequence of iterations: supersteps

I During a superstep, user-defined functions for each vertex is invoked(method Compute()): in parallel

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending mes-sages.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 22 / 116

Page 28: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (1/3)

I Applications run in sequence of iterations: supersteps

I During a superstep, user-defined functions for each vertex is invoked(method Compute()): in parallel

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending mes-sages.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 22 / 116

Page 29: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/3)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 23 / 116

Page 30: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/3)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 23 / 116

Page 31: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/3)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 23 / 116

Page 32: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/3)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 23 / 116

Page 33: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (3/3)

I Aggregation: a mechanism for global communication, monitoring,and data.

I Runs after each superstep.

I Each vertex can provide a value to an aggregator in superstep S.

I The system combines those values and the resulting value is madeavailable to all vertices in superstep S + 1.

I A number of predefined aggregators, e.g., min, max, sum.

I Aggregation operators should be commutative and associative.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 24 / 116

Page 34: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (3/3)

I Aggregation: a mechanism for global communication, monitoring,and data.

I Runs after each superstep.

I Each vertex can provide a value to an aggregator in superstep S.

I The system combines those values and the resulting value is madeavailable to all vertices in superstep S + 1.

I A number of predefined aggregators, e.g., min, max, sum.

I Aggregation operators should be commutative and associative.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 24 / 116

Page 35: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (3/3)

I Aggregation: a mechanism for global communication, monitoring,and data.

I Runs after each superstep.

I Each vertex can provide a value to an aggregator in superstep S.

I The system combines those values and the resulting value is madeavailable to all vertices in superstep S + 1.

I A number of predefined aggregators, e.g., min, max, sum.

I Aggregation operators should be commutative and associative.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 24 / 116

Page 36: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: Max Value (1/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 25 / 116

Page 37: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: Max Value (2/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 26 / 116

Page 38: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: Max Value (3/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 27 / 116

Page 39: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: Max Value (4/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 28 / 116

Page 40: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: PageRank

I Update ranks in parallel.

I Iterate until convergence.

R[i ] = 0.15 +∑

j∈Nbrs(i)wjiR[j ]

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 29 / 116

Page 41: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: PageRank

Pregel_PageRank(i, messages):

// receive all the messages

total = 0

foreach(msg in messages):

total = total + msg

// update the rank of this vertex

R[i] = 0.15 + total

// send new messages to neighbors

foreach(j in out_neighbors[i]):

sendmsg(R[i] * wij) to vertex j

R[i ] = 0.15 +∑

j∈Nbrs(i)wjiR[j ]

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 30 / 116

Page 42: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Partitioning the Graph

I The pregel library divides a graph into a number of partitions.

I Each consisting of a set of vertices and all of those vertices’ outgoingedges.

I Vertices are assigned to partitions based on their vertex-ID (e.g.,hash(ID)).

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 31 / 116

Page 43: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Implementation (1/4)

I Master-worker model.

I User programs are copied on machines.

I One copy becomes the master.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 32 / 116

Page 44: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Implementation (2/4)

I The master is responsible for• Coordinating workers activity.• Determining the number of partitions.

I Each worker is responsible for• Maintaining the state of its partitions.• Executing the user’s Compute() method on its vertices.• Managing messages to and from other workers.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 33 / 116

Page 45: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Implementation (3/4)

I The master assigns one or more partitions to each worker.

I The master assigns a portion of user input to each worker.

• Set of records containing an arbitrary number of vertices and edges.

• If a worker loads a vertex that belongs to that worker’s partitions,the appropriate data structures are immediately updated.

• Otherwise the worker enqueues a message to the remote peer thatowns the vertex.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 34 / 116

Page 46: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Implementation (3/4)

I The master assigns one or more partitions to each worker.

I The master assigns a portion of user input to each worker.

• Set of records containing an arbitrary number of vertices and edges.

• If a worker loads a vertex that belongs to that worker’s partitions,the appropriate data structures are immediately updated.

• Otherwise the worker enqueues a message to the remote peer thatowns the vertex.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 34 / 116

Page 47: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Implementation (4/4)

I After the input has finished loading, all vertices are marked as active.

I The master instructs each worker to perform a superstep.

I After the computation halts, the master may instruct each workerto save its portion of the graph.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 35 / 116

Page 48: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Combiner

I Sending a message between workers incurs some overhead: use com-biner.

I This can be reduced in some cases: sometimes vertices only careabout a summary value for the messages it is sent (e.g., min, max,sum, avg).

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 36 / 116

Page 49: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Fault Tolerance (1/2)

I Fault tolerance is achieved through checkpointing.

I At start of each superstep, master tells workers to save their state:• Vertex values, edge values, incoming messages• Saved to persistent storage

I Master saves aggregator values (if any).

I This is not necessarily done at every superstep: costly

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 37 / 116

Page 50: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Fault Tolerance (2/2)

I When master detects one or more worker failures:

• All workers revert to last checkpoint.

• Continue from there.

• That is a lot of repeated work.

• At least it is better than redoing the whole job.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 38 / 116

Page 51: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Pregel Summary

I Bulk Synchronous Parallel model

I Vertex-centric

I Superstep: sequence of iterations

I Master-worker model

I Communication: message passing

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 39 / 116

Page 52: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Pregel Limitations

I Inefficient if different regions of the graph converge at differentspeed.

I Can suffer if one task is more expensive than the others.

I Runtime of each phase is determined by the slowest machine.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 40 / 116

Page 53: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 41 / 116

Page 54: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Model

I A directed graph that stores the program state, called data graph.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 42 / 116

Page 55: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Vertex Scope

I The scope of vertex v is the data stored in vertex v , in all adjacentvertices and adjacent edges.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 43 / 116

Page 56: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (1/4)

I Rather than adopting a message passing as in Pregel, GraphLaballows the user defined function of a vertex to read and modify anyof the data in its scope.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 44 / 116

Page 57: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/4)

I Update function: user-defined function similar to Compute in Pregel.

I Can read and modify the data within the scope of a vertex.

I Schedules the future execution of other update functions.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 45 / 116

Page 58: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (3/4)

I After executing an update function (f, g, · · ·) the modified scopedata in Sv is written back to the data graph.

I Each task in the set of tasks T , is a tuple (f, v) consisting of anupdate function f and a vertex v.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 46 / 116

Page 59: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (4/4)

I Sync function: similar to aggregate in Pregel.

I Maintains global aggregates.

I Performs periodically in the background.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 47 / 116

Page 60: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: PageRank

GraphLab_PageRank(i)

// compute sum over neighbors

total = 0

foreach(j in in_neighbors(i)):

total = total + R[j] * wji

// update the PageRank

R[i] = 0.15 + total

// trigger neighbors to run again

foreach(j in out_neighbors(i)):

signal vertex-program on j

R[i ] = 0.15 +∑

j∈Nbrs(i)wjiR[j ]

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 48 / 116

Page 61: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (1/3)

I Overlapped scopes: race-condition in simultaneous execution of twoupdate functions.

I Full consistency: during the execution f(v), no other function readsor modifies data within the v scope.

I Edge consistency: during the execution f(v), no other functionreads or modifies any of the data on v or any of the edges adja-cent to v.

I Vertex consistency: during the execution f(v), no other functionwill be applied to v.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 49 / 116

Page 62: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (1/3)

I Overlapped scopes: race-condition in simultaneous execution of twoupdate functions.

I Full consistency: during the execution f(v), no other function readsor modifies data within the v scope.

I Edge consistency: during the execution f(v), no other functionreads or modifies any of the data on v or any of the edges adja-cent to v.

I Vertex consistency: during the execution f(v), no other functionwill be applied to v.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 49 / 116

Page 63: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (1/3)

I Overlapped scopes: race-condition in simultaneous execution of twoupdate functions.

I Full consistency: during the execution f(v), no other function readsor modifies data within the v scope.

I Edge consistency: during the execution f(v), no other functionreads or modifies any of the data on v or any of the edges adja-cent to v.

I Vertex consistency: during the execution f(v), no other functionwill be applied to v.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 49 / 116

Page 64: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (1/3)

I Overlapped scopes: race-condition in simultaneous execution of twoupdate functions.

I Full consistency: during the execution f(v), no other function readsor modifies data within the v scope.

I Edge consistency: during the execution f(v), no other functionreads or modifies any of the data on v or any of the edges adja-cent to v.

I Vertex consistency: during the execution f(v), no other functionwill be applied to v.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 49 / 116

Page 65: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (2/3)

Consistency vs. Parallelism

[Low, Y., GraphLab: A Distributed Abstraction for Large Scale Machine Learning (Doctoral dissertation, University of

California), 2013.]

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 50 / 116

Page 66: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (3/3)

I Proving the correctness of a parallel algorithm: sequential consistency

I Sequential consistency: if for every parallel execution, there exists asequential execution of update functions that produces an equivalentresult.

I A simple method to achieve serializability is to ensure that the scopesof concurrently executing update functions do not overlap.

• The full consistency model is used.• The edge consistency model is used and update functions do not modify

data in adjacent vertices.• The vertex consistency model is used and update functions only access

local vertex data.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 51 / 116

Page 67: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (3/3)

I Proving the correctness of a parallel algorithm: sequential consistency

I Sequential consistency: if for every parallel execution, there exists asequential execution of update functions that produces an equivalentresult.

I A simple method to achieve serializability is to ensure that the scopesof concurrently executing update functions do not overlap.

• The full consistency model is used.• The edge consistency model is used and update functions do not modify

data in adjacent vertices.• The vertex consistency model is used and update functions only access

local vertex data.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 51 / 116

Page 68: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Consistency (3/3)

I Proving the correctness of a parallel algorithm: sequential consistency

I Sequential consistency: if for every parallel execution, there exists asequential execution of update functions that produces an equivalentresult.

I A simple method to achieve serializability is to ensure that the scopesof concurrently executing update functions do not overlap.

• The full consistency model is used.• The edge consistency model is used and update functions do not modify

data in adjacent vertices.• The vertex consistency model is used and update functions only access

local vertex data.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 51 / 116

Page 69: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphLab Implementation

I Shared memory implementation

I Distributed implementation

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 52 / 116

Page 70: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphLab Implementation

I Shared memory implementation

I Distributed implementation

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 52 / 116

Page 71: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Tasks Schedulers (1/2)

I In what order should the tasks (vertex-update function pairs) becalled?

• A collection of base schedules, e.g., round-robin, and synchronous.• Set scheduler: enables users to compose custom update schedules.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 53 / 116

Page 72: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Tasks Schedulers (1/2)

I In what order should the tasks (vertex-update function pairs) becalled?

• A collection of base schedules, e.g., round-robin, and synchronous.• Set scheduler: enables users to compose custom update schedules.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 53 / 116

Page 73: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Tasks Schedulers (2/2)

I How to add new task in the queue?

• FIFO: only permits task creation but do not permit task reordering.• Prioritized: permits task reordering at the cost of increased overhead.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 54 / 116

Page 74: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Tasks Schedulers (2/2)

I How to add new task in the queue?• FIFO: only permits task creation but do not permit task reordering.• Prioritized: permits task reordering at the cost of increased overhead.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 54 / 116

Page 75: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency

I Implemented in C++ using PThreads for parallelism.

I Consistency: read-write lock

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock)• Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks)• Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following acanonical order.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 55 / 116

Page 76: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency

I Implemented in C++ using PThreads for parallelism.

I Consistency: read-write lock

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock)• Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks)• Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following acanonical order.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 55 / 116

Page 77: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphLab Implementation

I Shared memory implementation

I Distributed implementation

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 56 / 116

Page 78: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Distributed Implementation

I Graph partitioning• How to efficiently load, partition and distribute the data graph across

machines?

I Consistency• How to achieve consistency in the distributed setting?

I Fault tolerance

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 57 / 116

Page 79: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Partitioning - Phase 1 (1/2)

I Two-phase partitioning.

I Partitioning the data graph into k parts, called atom: k � numberof machines.

I meta-graph: the graph of atoms (one vertex for each atom).

I Atom weight: the amount of data it stores.

I Edge weight: the number of edges crossing the atoms.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 58 / 116

Page 80: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Partitioning - Phase 1 (2/2)

I Each atom is stored as a separate file on a distributed storage system,e.g., HDFS.

I Each atom file is a simple binary that stores interior and the ghostsof the partition information.

I Ghost: set of vertices and edges adjacent to the partition boundary.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 59 / 116

Page 81: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Partitioning - Phase 2

I Meta-graph is very small.

I A fast balanced partition of the meta-graph over the physical ma-chines.

I Assigning graph atoms to machines.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 60 / 116

Page 82: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency

I To achieve a serializable parallel execution of a set of dependenttasks.

I Chromatic Engine

I Distributed Locking Engine

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 61 / 116

Page 83: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency - Chromatic Engine

I Construct a vertex coloring: assigns a color to each vertex such thatno adjacent vertices share the same color.

I Edge consistency: executing, synchronously, all update tasks asso-ciated with vertices of the same color before proceeding to the nextcolor.

I Full consistency: no vertex shares the same color as any of its dis-tance two neighbors.

I Vertex consistency: assigning all vertices the same color.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 62 / 116

Page 84: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency - Chromatic Engine

I Construct a vertex coloring: assigns a color to each vertex such thatno adjacent vertices share the same color.

I Edge consistency: executing, synchronously, all update tasks asso-ciated with vertices of the same color before proceeding to the nextcolor.

I Full consistency: no vertex shares the same color as any of its dis-tance two neighbors.

I Vertex consistency: assigning all vertices the same color.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 62 / 116

Page 85: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency - Chromatic Engine

I Construct a vertex coloring: assigns a color to each vertex such thatno adjacent vertices share the same color.

I Edge consistency: executing, synchronously, all update tasks asso-ciated with vertices of the same color before proceeding to the nextcolor.

I Full consistency: no vertex shares the same color as any of its dis-tance two neighbors.

I Vertex consistency: assigning all vertices the same color.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 62 / 116

Page 86: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency - Chromatic Engine

I Construct a vertex coloring: assigns a color to each vertex such thatno adjacent vertices share the same color.

I Edge consistency: executing, synchronously, all update tasks asso-ciated with vertices of the same color before proceeding to the nextcolor.

I Full consistency: no vertex shares the same color as any of its dis-tance two neighbors.

I Vertex consistency: assigning all vertices the same color.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 62 / 116

Page 87: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Consistency - Distributed Locking Engine

I Associating a readers-writer lock with each vertex.

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock), Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks), Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following acanonical order.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 63 / 116

Page 88: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Fault Tolerance - Synchronous

I The systems periodically signals all computation activity to halt.

I Then synchronizes all caches (ghosts) and saves to disk all datawhich has been modified since the last snapshot.

I Simple, but eliminates the systems advantage of asynchronous com-putation.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 64 / 116

Page 89: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Fault Tolerance - Asynchronous

I Based on the Chandy-Lamport algorithm.

I The snapshot function is implemented as an update function invertices.

I The Snapshot update takes priority over all other update functions.

I Edge Consistency is used on all update functions.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 65 / 116

Page 90: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphLab Summary

I Asynchronous model

I Vertex-centric

I Communication: distributed shared memory

I Three consistency levels: full, edge-level, and vertex-level

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 66 / 116

Page 91: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphLab Limitations

I Poor performance on Natural graphs.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 67 / 116

Page 92: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Natural Graphs

I Graphs derived from natural phenomena.

I Skewed Power-Law degree distribution.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 68 / 116

Page 93: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Natural Graphs Challenges

I Traditional graph-partitioning algorithms (edge-cut algorithms) per-form poorly on Power-Law Graphs.

I Challenges of high-degree vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 69 / 116

Page 94: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Proposed Solution

Vertex-Cut Partitioning

Edge-cut Vertex-cut

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 70 / 116

Page 95: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Proposed Solution

Vertex-Cut Partitioning

Edge-cut Vertex-cut

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 70 / 116

Page 96: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Edge-cut vs. Vertex-cut Partitioning

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 71 / 116

Page 97: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Edge-cut vs. Vertex-cut Partitioning

Edge-cut Vertex-cut

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 72 / 116

Page 98: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

PowerGraph

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 73 / 116

Page 99: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

PowerGraph

I Vertex-cut partitioning of graphs.

I Factorizes the GraphLab update function into the Gather, Apply andScatter phases (GAS).

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 74 / 116

Page 100: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Gather-Apply-Scatter Programming Model

I Gather• Accumulate information about neighborhood

through a generalized sum.

I Apply• Apply the accumulated value to center vertex.

I Scatter• Update adjacent edges and vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 75 / 116

Page 101: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Gather-Apply-Scatter Programming Model

I Gather• Accumulate information about neighborhood

through a generalized sum.

I Apply• Apply the accumulated value to center vertex.

I Scatter• Update adjacent edges and vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 75 / 116

Page 102: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Gather-Apply-Scatter Programming Model

I Gather• Accumulate information about neighborhood

through a generalized sum.

I Apply• Apply the accumulated value to center vertex.

I Scatter• Update adjacent edges and vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 75 / 116

Page 103: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Model

I A directed graph that stores the program state, called data graph.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 76 / 116

Page 104: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (1/2)

I Vertex-centric programming: implementing the GASVertexPrograminterface (vertex-program for short).

I Similar to Comput in Pregel, and update function in GraphLab.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 77 / 116

Page 105: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/2)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 78 / 116

Page 106: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Execution Model (2/2)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 78 / 116

Page 107: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: PageRank

PowerGraph_PageRank(i):

Gather(j -> i):

return wji * R[j]

sum(a, b):

return a + b

// total: Gather and sum

Apply(i, total):

R[i] = 0.15 + total

Scatter(i -> j):

if R[i] changed then activate(j)

R[i ] = 0.15 +∑

j∈Nbrs(i)wjiR[j ]

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 79 / 116

Page 108: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (1/5)

I PowerGraph inherits the dynamic scheduling of GraphLab.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 80 / 116

Page 109: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (2/5)

I Initially all vertices are active.

I PowerGraph executes the vertex-program on the active vertices untilnone remain.

I The order of executing activated vertices is up to the PowerGraphexecution engine.

I Once a vertex-program completes the scatter phase it becomes in-active until it is reactivated.

I Vertices can activate themselves and neighboring vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 81 / 116

Page 110: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (2/5)

I Initially all vertices are active.

I PowerGraph executes the vertex-program on the active vertices untilnone remain.

I The order of executing activated vertices is up to the PowerGraphexecution engine.

I Once a vertex-program completes the scatter phase it becomes in-active until it is reactivated.

I Vertices can activate themselves and neighboring vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 81 / 116

Page 111: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (2/5)

I Initially all vertices are active.

I PowerGraph executes the vertex-program on the active vertices untilnone remain.

I The order of executing activated vertices is up to the PowerGraphexecution engine.

I Once a vertex-program completes the scatter phase it becomes in-active until it is reactivated.

I Vertices can activate themselves and neighboring vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 81 / 116

Page 112: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (2/5)

I Initially all vertices are active.

I PowerGraph executes the vertex-program on the active vertices untilnone remain.

I The order of executing activated vertices is up to the PowerGraphexecution engine.

I Once a vertex-program completes the scatter phase it becomes in-active until it is reactivated.

I Vertices can activate themselves and neighboring vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 81 / 116

Page 113: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (2/5)

I Initially all vertices are active.

I PowerGraph executes the vertex-program on the active vertices untilnone remain.

I The order of executing activated vertices is up to the PowerGraphexecution engine.

I Once a vertex-program completes the scatter phase it becomes in-active until it is reactivated.

I Vertices can activate themselves and neighboring vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 81 / 116

Page 114: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling (3/5)

I PowerGraph can execute both synchronously and asynchronously.

• Bulk synchronous execution

• Asynchronous execution

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 82 / 116

Page 115: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Bulk Synchronous Execution (4/5)

I Similar to Pregel.

I Minor-step: executing the gather, apply, and scatter in order.• Runs synchronously on all active vertices with a barrier at the end.

I Super-step: a complete series of GAS minor-steps.

I Changes made to the vertex/edge data are committed at the end ofeach minor-step and are visible in the subsequent minor-steps.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 83 / 116

Page 116: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Bulk Synchronous Execution (4/5)

I Similar to Pregel.

I Minor-step: executing the gather, apply, and scatter in order.• Runs synchronously on all active vertices with a barrier at the end.

I Super-step: a complete series of GAS minor-steps.

I Changes made to the vertex/edge data are committed at the end ofeach minor-step and are visible in the subsequent minor-steps.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 83 / 116

Page 117: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Bulk Synchronous Execution (4/5)

I Similar to Pregel.

I Minor-step: executing the gather, apply, and scatter in order.• Runs synchronously on all active vertices with a barrier at the end.

I Super-step: a complete series of GAS minor-steps.

I Changes made to the vertex/edge data are committed at the end ofeach minor-step and are visible in the subsequent minor-steps.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 83 / 116

Page 118: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Bulk Synchronous Execution (4/5)

I Similar to Pregel.

I Minor-step: executing the gather, apply, and scatter in order.• Runs synchronously on all active vertices with a barrier at the end.

I Super-step: a complete series of GAS minor-steps.

I Changes made to the vertex/edge data are committed at the end ofeach minor-step and are visible in the subsequent minor-steps.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 83 / 116

Page 119: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Asynchronous Execution (5/5)

I Changes made to the vertex/edge data during the apply and scatterfunctions are immediately committed to the graph.

• Visible to subsequent computation on neighboring vertices.

I Serializability: prevents adjacent vertex-programs from running con-currently using a fine-grained locking protocol.

• Dining philosophers problem, where each vertex is a philosopher, andeach edge is a fork.

• GraphLab implements Dijkstras solution, where forks are acquiredsequentially according to a total ordering.

• PowerGraph implements Chandy-Misra solution, which acquires allforks simultaneously.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 84 / 116

Page 120: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Asynchronous Execution (5/5)

I Changes made to the vertex/edge data during the apply and scatterfunctions are immediately committed to the graph.

• Visible to subsequent computation on neighboring vertices.

I Serializability: prevents adjacent vertex-programs from running con-currently using a fine-grained locking protocol.

• Dining philosophers problem, where each vertex is a philosopher, andeach edge is a fork.

• GraphLab implements Dijkstras solution, where forks are acquiredsequentially according to a total ordering.

• PowerGraph implements Chandy-Misra solution, which acquires allforks simultaneously.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 84 / 116

Page 121: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Asynchronous Execution (5/5)

I Changes made to the vertex/edge data during the apply and scatterfunctions are immediately committed to the graph.

• Visible to subsequent computation on neighboring vertices.

I Serializability: prevents adjacent vertex-programs from running con-currently using a fine-grained locking protocol.

• Dining philosophers problem, where each vertex is a philosopher, andeach edge is a fork.

• GraphLab implements Dijkstras solution, where forks are acquiredsequentially according to a total ordering.

• PowerGraph implements Chandy-Misra solution, which acquires allforks simultaneously.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 84 / 116

Page 122: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Asynchronous Execution (5/5)

I Changes made to the vertex/edge data during the apply and scatterfunctions are immediately committed to the graph.

• Visible to subsequent computation on neighboring vertices.

I Serializability: prevents adjacent vertex-programs from running con-currently using a fine-grained locking protocol.

• Dining philosophers problem, where each vertex is a philosopher, andeach edge is a fork.

• GraphLab implements Dijkstras solution, where forks are acquiredsequentially according to a total ordering.

• PowerGraph implements Chandy-Misra solution, which acquires allforks simultaneously.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 84 / 116

Page 123: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Scheduling - Asynchronous Execution (5/5)

I Changes made to the vertex/edge data during the apply and scatterfunctions are immediately committed to the graph.

• Visible to subsequent computation on neighboring vertices.

I Serializability: prevents adjacent vertex-programs from running con-currently using a fine-grained locking protocol.

• Dining philosophers problem, where each vertex is a philosopher, andeach edge is a fork.

• GraphLab implements Dijkstras solution, where forks are acquiredsequentially according to a total ordering.

• PowerGraph implements Chandy-Misra solution, which acquires allforks simultaneously.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 84 / 116

Page 124: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Delta Caching (1/2)

I Changes in a few of its neighbors → triggering a vertex-program

I The gather operation is invoked on all neighbors: wasting compu-tation cycles

I Maintaining a cache of the accumulator av from the previous gatherphase for each vertex.

I The scatter can return an additional ∆a, which is added to thecached accumulator av .

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 85 / 116

Page 125: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Delta Caching (1/2)

I Changes in a few of its neighbors → triggering a vertex-program

I The gather operation is invoked on all neighbors: wasting compu-tation cycles

I Maintaining a cache of the accumulator av from the previous gatherphase for each vertex.

I The scatter can return an additional ∆a, which is added to thecached accumulator av .

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 85 / 116

Page 126: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Delta Caching (2/2)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 86 / 116

Page 127: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Delta Caching (2/2)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 86 / 116

Page 128: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example: PageRank (Delta-Caching)

PowerGraph_PageRank(i):

Gather(j -> i):

return wji * R[j]

sum(a, b):

return a + b

// total: Gather and sum

Apply(i, total):

new = 0.15 + total

R[i].delta = new - R[i]

R[i] = new

Scatter(i -> j):

if R[i] changed then activate(j)

return wij * R[i].delta

R[i ] = 0.15 +∑

j∈Nbrs(i)wjiR[j ]

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 87 / 116

Page 129: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Partitioning

I Vertex-cut partitioning.

I Evenly assign edges to machines.• Minimize machines spanned by each vertex.

I Two proposed solutions:• Random edge placement.• Greedy edge placement.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 88 / 116

Page 130: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Random Vertex-Cuts

I Randomly assign edges to machines.

I Completely parallel and easy to distribute.

I High replication factor.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 89 / 116

Page 131: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Greedy Vertex-Cuts (1/2)

I A(v): set of machines that contain adjacent edges of v.

I Case 1: If A(u) and A(v) intersect, then the edge should be assignedto a machine in the intersection.

I Case 2: If A(u) and A(v) are not empty and do not intersect, thenthe edge should be assigned to one of the machines from the vertexwith the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, thenchoose a machine from the assigned vertex.

I Case 4: If neither vertex has been assigned, then assign the edge tothe least loaded machine.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 90 / 116

Page 132: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Greedy Vertex-Cuts (1/2)

I A(v): set of machines that contain adjacent edges of v.

I Case 1: If A(u) and A(v) intersect, then the edge should be assignedto a machine in the intersection.

I Case 2: If A(u) and A(v) are not empty and do not intersect, thenthe edge should be assigned to one of the machines from the vertexwith the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, thenchoose a machine from the assigned vertex.

I Case 4: If neither vertex has been assigned, then assign the edge tothe least loaded machine.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 90 / 116

Page 133: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Greedy Vertex-Cuts (1/2)

I A(v): set of machines that contain adjacent edges of v.

I Case 1: If A(u) and A(v) intersect, then the edge should be assignedto a machine in the intersection.

I Case 2: If A(u) and A(v) are not empty and do not intersect, thenthe edge should be assigned to one of the machines from the vertexwith the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, thenchoose a machine from the assigned vertex.

I Case 4: If neither vertex has been assigned, then assign the edge tothe least loaded machine.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 90 / 116

Page 134: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Greedy Vertex-Cuts (1/2)

I A(v): set of machines that contain adjacent edges of v.

I Case 1: If A(u) and A(v) intersect, then the edge should be assignedto a machine in the intersection.

I Case 2: If A(u) and A(v) are not empty and do not intersect, thenthe edge should be assigned to one of the machines from the vertexwith the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, thenchoose a machine from the assigned vertex.

I Case 4: If neither vertex has been assigned, then assign the edge tothe least loaded machine.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 90 / 116

Page 135: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Greedy Vertex-Cuts (1/2)

I A(v): set of machines that contain adjacent edges of v.

I Case 1: If A(u) and A(v) intersect, then the edge should be assignedto a machine in the intersection.

I Case 2: If A(u) and A(v) are not empty and do not intersect, thenthe edge should be assigned to one of the machines from the vertexwith the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, thenchoose a machine from the assigned vertex.

I Case 4: If neither vertex has been assigned, then assign the edge tothe least loaded machine.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 90 / 116

Page 136: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Greedy Vertex-Cuts (2/2)

I Coordinated edge placement:• Requires coordination to place each edge• Slower, but higher quality cuts

I Oblivious edge placement:• Approx. greedy objective without coordination• Faster, but lower quality cuts

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 91 / 116

Page 137: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

PowerGraph Summary

I Gather-Apply-Scatter programming model

I Synchronous and Asynchronous models

I Vertex-cut graph partitioning

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 92 / 116

Page 138: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

I Any limitations?

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 93 / 116

Page 139: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data-Parallel vs. Graph-Parallel Computation

I Graph-parallel computation: restricting the types of computation toachieve performance.

I But, the same restrictions make it difficult and inefficient to expressmany stages in a typical graph-analytics pipeline.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 94 / 116

Page 140: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data-Parallel vs. Graph-Parallel Computation

I Graph-parallel computation: restricting the types of computation toachieve performance.

I But, the same restrictions make it difficult and inefficient to expressmany stages in a typical graph-analytics pipeline.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 94 / 116

Page 141: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data-Parallel and Graph-Parallel Pipeline

I Moving between table and graph views of the same physical data.

I Inefficient: extensive data movement and duplication across the net-work and file system.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 95 / 116

Page 142: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphX vs. Data-Parallel/Graph-Parallel Systems

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 96 / 116

Page 143: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphX vs. Data-Parallel/Graph-Parallel Systems

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 96 / 116

Page 144: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 97 / 116

Page 145: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphX

I New API that blurs the distinction between Tables and Graphs.

I New system that unifies Data-Parallel and Graph-Parallel systems.

I It is implemented on top of Spark.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 98 / 116

Page 146: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Unifying Data-Parallel and Graph-Parallel Analytics

I Tables and Graphs are composable views of the same physical data.

I Each view has its own operators that exploit the semantics of theview to achieve efficient execution.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 99 / 116

Page 147: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Data Model

I Property Graph: represented using two Spark RDDs:• Edge collection: VertexRDD• Vertex collection: EdgeRDD

// VD: the type of the vertex attribute

// ED: the type of the edge attribute

class Graph[VD, ED] {

val vertices: VertexRDD[VD]

val edges: EdgeRDD[ED]

}

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 100 / 116

Page 148: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Primitive Data Types

// Vertex collection

class VertexRDD[VD] extends RDD[(VertexId, VD)]

// Edge collection

class EdgeRDD[ED] extends RDD[Edge[ED]]

case class Edge[ED](srcId: VertexId = 0, dstId: VertexId = 0,

attr: ED = null.asInstanceOf[ED])

// Edge Triple

class EdgeTriplet[VD, ED] extends Edge[ED]

I EdgeTriplet represents an edge along with the vertex attributes ofits neighboring vertices.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 101 / 116

Page 149: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example (1/3)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 102 / 116

Page 150: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example (2/3)

val sc: SparkContext

// Create an RDD for the vertices

val users: VertexRDD[(String, String)] = sc.parallelize(

Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")),

(5L, ("franklin", "prof")), (2L, ("istoica", "prof"))))

// Create an RDD for edges

val relationships: EdgeRDD[String] = sc.parallelize(

Array(Edge(3L, 7L, "collab"), Edge(5L, 3L, "advisor"),

Edge(2L, 5L, "colleague"), Edge(5L, 7L, "pi")))

// Define a default user in case there are relationship with missing user

val defaultUser = ("John Doe", "Missing")

// Build the initial Graph

val userGraph: Graph[(String, String), String] =

Graph(users, relationships, defaultUser)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 103 / 116

Page 151: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Example (3/3)

// Constructed from above

val userGraph: Graph[(String, String), String]

// Count all users which are postdocs

userGraph.vertices.filter((id, (name, pos)) => pos == "postdoc").count

// Count all the edges where src > dst

userGraph.edges.filter(e => e.srcId > e.dstId).count

// Use the triplets view to create an RDD of facts

val facts: RDD[String] = graph.triplets.map(triplet =>

triplet.srcAttr._1 + " is the " +

triplet.attr + " of " + triplet.dstAttr._1)

// Remove missing vertices as well as the edges to connected to them

val validGraph = graph.subgraph(vpred = (id, attr) => attr._2 != "Missing")

facts.collect.foreach(println(_))

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 104 / 116

Page 152: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Property Operators (1/2)

class Graph[VD, ED] {

def mapVertices[VD2](map: (VertexId, VD) => VD2): Graph[VD2, ED]

def mapEdges[ED2](map: Edge[ED] => ED2): Graph[VD, ED2]

def mapTriplets[ED2](map: EdgeTriplet[VD, ED] => ED2): Graph[VD, ED2]

}

I They yield new graphs with the vertex or edge properties modifiedby the map function.

I The graph structure is unaffected.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 105 / 116

Page 153: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Property Operators (2/2)

val newGraph = graph.mapVertices((id, attr) => mapUdf(id, attr))

val newVertices = graph.vertices.map((id, attr) => (id, mapUdf(id, attr)))

val newGraph = Graph(newVertices, graph.edges)

I Both are logically equivalent, but the second one does not preservethe structural indices and would not benefit from the GraphX systemoptimizations.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 106 / 116

Page 154: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Map Reduce Triplets

I Map-Reduce for each vertex

// what is the age of the oldest follower for each user?

val oldestFollowerAge = graph.mapReduceTriplets(

e => (e.dstAttr, e.srcAttr), // Map

(a, b) => max(a, b) // Reduce

).vertices

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 107 / 116

Page 155: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Map Reduce Triplets

I Map-Reduce for each vertex

// what is the age of the oldest follower for each user?

val oldestFollowerAge = graph.mapReduceTriplets(

e => (e.dstAttr, e.srcAttr), // Map

(a, b) => max(a, b) // Reduce

).vertices

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 107 / 116

Page 156: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Structural Operators

class Graph[VD, ED] {

// returns a new graph with all the edge directions reversed

def reverse: Graph[VD, ED]

// returns the graph containing only the vertices and edges that satisfy

// the vertex predicate

def subgraph(epred: EdgeTriplet[VD,ED] => Boolean,

vpred: (VertexId, VD) => Boolean): Graph[VD, ED]

// a subgraph by returning a graph that contains the vertices and edges

// that are also found in the input graph

def mask[VD2, ED2](other: Graph[VD2, ED2]): Graph[VD, ED]

}

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 108 / 116

Page 157: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Structural Operators Example

// Build the initial Graph

val graph = Graph(users, relationships, defaultUser)

// Run Connected Components

val ccGraph = graph.connectedComponents()

// Remove missing vertices as well as the edges to connected to them

val validGraph = graph.subgraph(vpred = (id, attr) => attr._2 != "Missing")

// Restrict the answer to the valid subgraph

val validCCGraph = ccGraph.mask(validGraph)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 109 / 116

Page 158: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Join Operators

I To join data from external collections (RDDs) with graphs.

class Graph[VD, ED] {

// joins the vertices with the input RDD and returns a new graph

// by applying the map function to the result of the joined vertices

def joinVertices[U](table: RDD[(VertexId, U)])

(map: (VertexId, VD, U) => VD): Graph[VD, ED]

// similarly to joinVertices, but the map function is applied to

// all vertices and can change the vertex property type

def outerJoinVertices[U, VD2](table: RDD[(VertexId, U)])

(map: (VertexId, VD, Option[U]) => VD2): Graph[VD2, ED]

}

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 110 / 116

Page 159: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Graph Builders

// load a graph from a list of edges on disk

object GraphLoader {

def edgeListFile(

sc: SparkContext,

path: String,

canonicalOrientation: Boolean = false,

minEdgePartitions: Int = 1)

: Graph[Int, Int]

}

// graph file

# This is a comment

2 1

4 1

1 2

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 111 / 116

Page 160: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

GraphX and Spark

I GraphX is implemented on top of Spark

I In-memory caching

I Lineage-based fault tolerance

I Programmable partitioning

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 112 / 116

Page 161: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Distributed Graph Representation (1/2)

I Representing graphs using two RDDs: edge-collection and vertex-collection

I Vertex-cut partitioning (like PowerGraph)

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 113 / 116

Page 162: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Distributed Graph Representation (2/2)

I Each vertex partition contains a bitmask and routing table.

I Routing table: a logical map from a vertex id to the set of edgepartitions that contains adjacent edges.

I Bitmask: enables the set intersection and filtering.• Vertices bitmasks are updated after each operation (e.g., mapRe-

duceTriplets).• Vertices hidden by the bitmask do not participate in the graph oper-

ations.

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 114 / 116

Page 163: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Summary

I Pregel• Synchronous model: super-step• Message passing

I GraphLab• Asynchronous model: distributed shared-memory• Edge-cut partitioning

I PowerGraph• GAS programming model• Vertex-cut partitioning

I GraphX• Unifying data-parallel and graph-parallel analytics• Vertex-cut partitioning

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 115 / 116

Page 164: Large-Scale Graph Processing · Graph-Parallel Processing I Restrictsthetypes of computation. I New techniques topartition and distribute graphs. I Exploit graph structure. I Executes

Questions?

Acknowledgements

Some pictures were derived from the Spark web site(http://spark.apache.org/).

Amir H. Payberah (SICS) Large-Scale Graph Processing May 13-15, 2014 116 / 116