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
which can be the used as inputs to the
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
A single-threaded iteration on this graph takes about 0.67s on a 2013 MacBook
To run on inputs
$ cargo run --release --bin pagerank -- my-graph worker [options]
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;
-p can be used to
$ 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
-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
-max-iterations) option (default is 20). e.g.:
$ cargo run --release --bin pagerank -- my-graph worker -i 100
To learn more about timely dataflow in Rust, you might be interested in the following blog posts, too: