frankmcsherry / pagerank

Implementation of PageRank in timely dataflow
MIT License
73 stars 16 forks source link

PageRank in timely dataflow

This repository contains an implementation of the PageRank algorithm in timely dataflow, implemented in Rust. By default, it runs 20 PageRank iterations and then prints some statistics.

To run, clone the repo, prepare the inputs and run. We assume that you have a working Rust installation, and that your input graph is in text-based edge list format.

Preparing the inputs

The input format for our PageRank implementation is a binary-packed adjacency list for a graph. You can use the parse binary to transform an ASCII/UTF-8 edge list into this format:

$ cargo run --release --bin parse -- my-graph < my-edgelist.txt

This will generate binary files my-graph.offsets and my-graph.targets, which can be the used as inputs to the pagerank binary.

parse assumes that the inputs are in tab-seperated text, but you can change to a different delimiter by editing src/bin/parse.rs. For a small example data set that works out of the box, use the LiveJournal graph. A single-threaded iteration on this graph takes about 0.67s on a 2013 MacBook Air.

Our blog posts have links to the larger twitter_rv and uk_2007_05 data sets.

Running PageRank

To run on inputs my-graph.offsets and my-graph.targets, run:

$ cargo run --release --bin pagerank -- my-graph worker [options]

The worker argument indicates you would like worker-level aggregation. You can alternately use process for process-level aggregation.

Without any options, the code runs single-threadedly. The -w option can be used to set the number of threads to use; -h,-n and -p can be used to run distributedly:

$ cat hosts.txt
hostname0:port
hostname1:port
hostname2:port
hostname3:port

hostname0$ cargo run --release --bin pagerank -- my-graph -h hosts.txt -n 4 -p 0
hostname1$ cargo run --release --bin pagerank -- my-graph -h hosts.txt -n 4 -p 1
hostname2$ cargo run --release --bin pagerank -- my-graph -h hosts.txt -n 4 -p 2
hostname3$ cargo run --release --bin pagerank -- my-graph -h hosts.txt -n 4 -p 3

The inputs must already be present in the working directory on all hosts.

To output the results add the -o (or -output) option with the output file (TSV). A suffix will be added for the peer (the position can be controlled using ? in the filename). e.g.:

$ cargo run --release --bin pagerank -- my-graph worker -o pagerank-peer-?.tsv

The number of iterations can be controlled via the -i (or -max-iterations) option (default is 20). e.g.:

$ cargo run --release --bin pagerank -- my-graph worker -i 100

Context

We have written blog posts about the development of this implementation; there, we also compare it against the widely used GraphX system for Apache Spark.

To learn more about timely dataflow in Rust, you might be interested in the following blog posts, too: