graph processing
play

Graph Processing & Bulk Synchronous Parallel Model - PowerPoint PPT Presentation

Graph Processing & Bulk Synchronous Parallel Model CompSci 590.03 Instructor: Ashwin Machanavajjhala Lecture 14 : 590.02 Spring 13 1 Recap: Graph


  1. Graph ¡Processing ¡& ¡ ¡ Bulk ¡Synchronous ¡Parallel ¡Model ¡ CompSci ¡590.03 ¡ Instructor: ¡Ashwin ¡Machanavajjhala ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 1 ¡

  2. Recap: ¡Graph ¡Algorithms ¡ • Many ¡graph ¡algorithms ¡need ¡iteraFve ¡computaFon ¡ • No ¡naFve ¡support ¡for ¡iteraFon ¡in ¡Map-­‑Reduce ¡ – Each ¡iteraFon ¡writes/reads ¡data ¡from ¡disk ¡leading ¡to ¡overheads ¡ – Need ¡to ¡design ¡algorithms ¡that ¡can ¡minimize ¡number ¡of ¡iteraFons ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 2 ¡

  3. This ¡Class ¡ • IteraFon ¡Aware ¡Map-­‑Reduce ¡ • Pregel ¡(Bulk ¡Synchronous ¡Parallel ¡Model) ¡for ¡Graph ¡Processing ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 3 ¡

  4. ITERATION ¡AWARE ¡MAP-­‑REDUCE ¡ Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 4 ¡

  5. IteraFve ¡ComputaFons ¡ ¡PageRank: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡do ¡ ¡p next ¡= ¡(cM ¡+ ¡(1-­‑c) ¡U)p cur ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ while(p next ¡!= ¡p cur ) ¡ ¡ ¡ • Loops ¡are ¡not ¡supported ¡in ¡Map-­‑Reduce ¡ – Need ¡to ¡encode ¡iteraFon ¡in ¡the ¡launching ¡script ¡ • M ¡is ¡a ¡loop ¡invariant. ¡But ¡needs ¡to ¡wriZen ¡to ¡disk ¡and ¡read ¡from ¡ disk ¡in ¡every ¡step. ¡ ¡ • M ¡may ¡not ¡be ¡co-­‑located ¡with ¡mappers ¡and ¡reducers ¡running ¡the ¡ iteraFve ¡computaFon. ¡ ¡ Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 5 ¡

  6. � � � HaLoop ¡ • IteraFve ¡Programs ¡ R i +1 = R 0 [ ( R i . / L ) IniFal ¡ Invariant ¡ RelaFon ¡ RelaFon ¡ Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 6 ¡

  7. Loop ¡aware ¡task ¡scheduling ¡ • Inter-­‑IteraFon ¡Locality ¡ • Caching ¡and ¡Indexing ¡of ¡invariant ¡tables ¡ M20: R0-split0 R00: partition 0 M21: R1-split0 R01: partition 0 n1 n3 n1 n3 M00: L-split0 R10: partition 1 M01: L-split0 R11: partition 1 n2 n1 n2 n1 M10: L-split1 R20: partition 2 M11: L-split1 R21: partition 2 n3 n2 n3 n2 Unnecessary computation Unnecessary communication Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 7 ¡

  8. iMapReduce ¡ • Reduce ¡output ¡is ¡directly ¡sent ¡to ¡mappers, ¡instead ¡of ¡wriFng ¡to ¡ distributed ¡file ¡system. ¡ ¡ • Loop ¡invariant ¡is ¡loaded ¡onto ¡the ¡maps ¡only ¡once. ¡ ¡ Graph Graph Graph Partition (1) Partition (2) Partition (n) ... Map 1 Map 2 Map n Shuffle K V K V K V Reduce 1 Reduce 2 Reduce n Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 8 ¡

  9. PREGEL ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 9 ¡

  10. Seven ¡Bridges ¡of ¡ Konigsberg ¡ River ¡Pregel ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 10 ¡

  11. Pregel ¡Overview ¡ • Processing ¡occurs ¡in ¡a ¡series ¡of ¡supersteps ¡ ¡ • In ¡superstep ¡S: ¡ ¡ Vertex ¡may ¡read ¡messages ¡sent ¡to ¡V ¡in ¡superstep ¡S-­‑1 ¡ Vertex ¡may ¡perform ¡some ¡computaFon ¡ Vertex ¡may ¡send ¡messages ¡to ¡other ¡verFces ¡ • Vertex ¡computaFon ¡within ¡a ¡superstep ¡can ¡be ¡arbitrarily ¡ parallelized. ¡ • All ¡communicaFon ¡happens ¡between ¡two ¡supersteps ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 11 ¡

  12. Pregel ¡ • Input: ¡A ¡directed ¡graph ¡G. ¡ ¡ Each ¡vertex ¡is ¡associated ¡with ¡an ¡id ¡and ¡a ¡value. ¡ ¡ Edges ¡may ¡also ¡contain ¡values. ¡ ¡ • Edges ¡are ¡not ¡a ¡first ¡class ¡ciFzen ¡– ¡they ¡have ¡no ¡associated ¡ computaFon ¡ – VerFces ¡can ¡modify ¡its ¡state/edge ¡state/edge ¡set ¡ • ComputaFon ¡finishes ¡when ¡ ¡ all ¡verFces ¡enter ¡the ¡inacFve ¡state ¡ Vote to halt Active Inactive Message received Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 12 ¡

  13. Example ¡ Superstep 0 3 6 2 1 Superstep 1 6 6 2 6 Superstep 2 6 6 6 6 Superstep 3 6 6 6 6 Figure 2: Maximum Value Example. Dotted lines are messages. Shaded vertices have voted to halt. Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 13 ¡

  14. Vertex ¡API ¡ template <typename VertexValue, User ¡overrides ¡this ¡ typename EdgeValue, compute ¡funcFon ¡ ¡ typename MessageValue> class Vertex { public: virtual void Compute(MessageIterator* msgs) = 0; Vertex ¡value ¡can ¡be ¡ const string& vertex_id() const; modified ¡ int64 superstep() const; const VertexValue& GetValue(); VertexValue* MutableValue(); Messages ¡can ¡be ¡sent ¡ OutEdgeIterator GetOutEdgeIterator(); to ¡any ¡dest_vertex ¡ (whose ¡id ¡is ¡known) ¡ void SendMessageTo(const string& dest_vertex, const MessageValue& message); void VoteToHalt(); }; Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 14 ¡

  15. Vertex ¡API ¡ • MessageIterator ¡contains ¡all ¡the ¡messages ¡received. ¡ ¡ ¡ • Message ¡ordering ¡is ¡not ¡guaranteed, ¡but ¡all ¡messages ¡are ¡ guaranteed ¡to ¡be ¡delivered ¡without ¡duplicaFon. ¡ ¡ • VerFces ¡can ¡also ¡send ¡messages ¡to ¡other ¡verFces ¡(whose ¡id ¡it ¡ knows ¡from ¡prior ¡messages) ¡ • No ¡need ¡to ¡explicitly ¡maintain ¡an ¡edgeset. ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 15 ¡

  16. PageRank ¡ class PageRankVertex : public Vertex<double, void, double> { public: virtual void Compute(MessageIterator* msgs) { if (superstep() >= 1) { double sum = 0; for (; !msgs->Done(); msgs->Next()) sum += msgs->Value(); *MutableValue() = 0.15 / NumVertices() + 0.85 * sum; } if (superstep() < 30) { const int64 n = GetOutEdgeIterator().size(); SendMessageToAllNeighbors(GetValue() / n); } else { VoteToHalt(); } } }; Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 16 ¡

  17. Combiners ¡ • If ¡messages ¡are ¡aggregated ¡(“reduced”) ¡using ¡an ¡associaFve ¡and ¡ commutaFve ¡funcFon, ¡then ¡the ¡system ¡can ¡combine ¡several ¡ messages ¡intended ¡for ¡a ¡vertex ¡into ¡1. ¡ ¡ • Reduces ¡the ¡number ¡of ¡messages ¡communicated/buffered. ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 17 ¡

  18. Single ¡Source ¡Shortest ¡Paths ¡ class ShortestPathVertex All ¡VerFces ¡iniFalized ¡to ¡INF ¡ : public Vertex<int, int, int> { void Compute(MessageIterator* msgs) { int mindist = IsSource(vertex_id()) ? 0 : INF; for (; !msgs->Done(); msgs->Next()) mindist = min(mindist, msgs->Value()); Distance ¡to ¡source ¡ if (mindist < GetValue()) { *MutableValue() = mindist; OutEdgeIterator iter = GetOutEdgeIterator(); for (; !iter.Done(); iter.Next()) SendMessageTo(iter.Target(), Edge ¡Weight ¡ mindist + iter.GetValue()); } VoteToHalt(); } class MinIntCombiner : public Combiner<int> { }; virtual void Combine(MessageIterator* msgs) { int mindist = INF; for (; !msgs->Done(); msgs->Next()) mindist = min(mindist, msgs->Value()); Output("combined_source", mindist); } }; Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 18 ¡

  19. AggregaFon ¡ • Global ¡communicaFon ¡ • Each ¡vertex ¡can ¡provide ¡a ¡value ¡to ¡an ¡aggregator ¡in ¡a ¡superstep ¡S. ¡ ResulFng ¡value ¡is ¡made ¡available ¡to ¡all ¡verFces ¡in ¡superstep ¡S+1. ¡ • System ¡aggregates ¡these ¡values ¡using ¡a ¡reduce ¡step. ¡ ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 19 ¡

  20. Topology ¡MutaFons ¡ • Compute ¡funcFon ¡can ¡add ¡or ¡remove ¡verFces ¡ • But ¡this ¡can ¡cause ¡race ¡condiFons ¡ – Vertex ¡1 ¡creates ¡an ¡edge ¡to ¡vertex ¡100 ¡ Vertex ¡2 ¡deletes ¡vertex ¡100 ¡ – Vertex ¡1 ¡creates ¡vertex ¡100 ¡with ¡value ¡10 ¡ Vertex ¡2 ¡also ¡creates ¡vertex ¡100 ¡with ¡value ¡12 ¡ • ParFal ¡Order ¡on ¡operaFons ¡ – Edge ¡removal ¡< ¡vertex ¡removal ¡< ¡vertex ¡add ¡< ¡edge ¡add ¡(< ¡means ¡earlier) ¡ • Handlers ¡for ¡conflicts ¡ – Default: ¡Pick ¡a ¡random ¡acFon ¡ – Can ¡specify ¡more ¡complex ¡handlers ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 20 ¡

  21. PREGEL ¡ARCHITECTURE ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 21 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend