alibaba / GraphScope

🔨 🍇 💻 🚀 GraphScope: A One-Stop Large-Scale Graph Computing System from Alibaba | 一站式图计算系统
https://graphscope.io
Apache License 2.0
3.24k stars 438 forks source link

[NetworkX] Benchmark of memory footprint, IO, and performance #999

Open acezen opened 2 years ago

acezen commented 2 years ago

1. Systems

system single or distributed multi-threads performance or flexibility static or dynamic
NetworkX single no flexibility dynamic
graphscope.nx distributed yes in-between dynamic

2. Memory Consumption

Use undirected Erdõs-Rényi random graphs, G(n, m), where n represents the number of nodes, and m represents the number of edges in the graph.

Graph size Memory usage [MB] -
(Nodes, Edges) NetworkX graphscope.nx
(1M, 10M) 3,789 4,474
(1M, 100M) 33,280 21,196
(10M, 100M) 36,864
(50M, 500M) 174,080 116,326

3. Graph basic Operations

We measure execution times of basic graph operations for an Erdõs-Rényi random graph G(n, m).

generation graph execution time(seconds)

Graph size NetworkX graphscope.nx
(1M, 10M) 45.8 228
(1M, 100M) 482s 2920

edge existence operation (seconds)

Edges are random, the number of tests is equal to the number of total edges in the graph. Graph size Execution time [seconds] -
(Nodes, Edges) NetworkX graphscope.nx
(1M, 10M) 20.027 36,541

delete nodes operation (seconds)

Execution times for deleting 10% of nodes and their corresponding edges from Erdős-Rényi random graph G(1M, 10M).

Graph size NetworkX graphscope.nx(one by one) graphscope.nx(batch)
(1M, 10M) 2.79812 0.078031 * 100000 0.83415 + 3.97145( 0.61 + 3.36) = 4.8056 \n preprocess + op_eval

delete all nodes

adding nodes operation (seconds)

Execution times for adding 10% of random generated nodes to Erdős-Rényi random graph G(1M, 10M).

Graph size NetworkX graphscope.nx
(1M, 10M) 0.09270 0.88083 + 1.61759(0.85 + 0.75) = 2.498424 \n preprocess + op.eval

delete edges operation (seconds)

Execution times for deleting 10% of edges from Erdős-Rényi random graph G(1M, 10M).

Graph size NetworkX graphscope.nx(one by one) graphscope.nx(batch)
(1M, 10M) 2.11016 0.083911 * 1000000 4.2661 + 11.19209(3.44 + 7.75) = 15.45819 \n preprocess + op.eva

Refactor

Graph size NetworkX graphscope.nx
(1M, 10M) 3.1571 0.3(append) + 0.35(json.dumps) + 5.7(engine) = 6.35
(1M, 10M) add with data { weight=0.5, type="edge"} 3.4257 0.5243 (append) + 1.235(json dumps) + 6.45(engine) = 8.2153
(1M, 10M) add with random edges and new nodes 10.257 0.355(append) + 0.345(json dumps) + 6.524(engine) = 7.224
(50M, 500M) 212.259021 17.7618(append) + 18.1837(json.dumps) + 165.252(engine) = 201.196

profiling of graphscope.nx add_edge operation

optimization 1: dumps the cache to one json str

optimization 2: parse json with nlomann-json

rapidjson (engine)

full rapidjson (engine)

Refactor (e2e)

json.dumps vs pickle.dumps

Edge size json.dumps pickle.dumps
1M 0.3614 0.47275
1M with data {weight=0.5, type="edge"} 1.235 0.6837
50M 18.1837 19.79538

4. Graph Algorithms

ego-twitter

algorithm NetworkX graphscope.nx (built-in) graphscope.nx (forward)
pagerank 6.03 2.25 413
sssp length 1.64 4.73s 206
average clustering coefficient 85 2.98
closeness_centrality > 15h
betweeness centrality >15h

LiveJournal

algorithm NetworkX graphscope.nx (built-in) graphscope.nx (forward)
pagerank
sssp length
average clustring coefficient
closeness_centrality
betweeness centrality
acezen commented 2 years ago

dataset

datagen-7_5-fb

loading time:

sssp

computation time

pagerank

computaion time

hits

computaion time

wcc

computaion time

acezen commented 2 years ago

Found a tool to do benchmark of popular graph / network packages FYI: https://github.com/timlrx/graph-benchmarks

graph-tool benchmark https://graph-tool.skewed.de/performance

acezen commented 2 years ago

snap benchmark: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5361061/

acezen commented 2 years ago

reference:

SNAP benchmark

To evaluate system performance on a real-world graph, we used a friendship graph of the LiveJournal online social network [Leskovec and Krevl 2014] (About 4.8M nodes and 69M edges).

Measured execution times for common graph analytics operations:

Networkit benchmark

Datasets 截屏2021-12-01 下午6.23.27.png

Algorithms

ref: https://github.com/networkit/networkit/tree/master/benchmark

Datasets (bold means selected):

Name Type n m Source
fb-Caltech36 Social (friendship) 769 16,656 (Traud et al., 2012)
PGPgiantcompo Social (trust) 10,680 24,316 (Boguna et al. 2014)
CoAuthorsDBLP Coauthorship (science) 299,067 977,676 (Bader et al., 2014)
fb-Texas84 Social (friendship) 36,371 1,590,655 (Traud et al., 2012)
Foursquare Social (friendship) 639,014 3,214,986 (Zafarani and Liu, 2009)
Lastfm Social (friendship) 1,193,699 4,519,020 (Zafarani and Liu, 2009)
wiki-Talk Social 2,394,385 4,659,565 (Leskovec and Krevl, 2014)
Flickr Social (friendship) 639,014 55,899,882 (Zafarani and Liu, 2009)
in-2004 Web 1,382,908 13,591,473 (Boldi et al., 2004)
Actor-collaboration Collaboration (film) 382,219 15,038,083 (Kunegis, 2013)
eu-2005 Web 862,664 16,138,468 (Boldi et al., 2004)
Flickr-growth-u Social (friendship) 2,302,925 33,140,017 (Kunegis, 2013)
Con-fiber big Brain (connectivity) 591,428 46,374,120 http://openconnecto.me
LiveJournal Social (friendship) 4.8M 69M Leskovec and Krevl 2014
Twitter Social (followership) 15,395,404 85,331,845 (Zafarani and Liu, 2009)
uk-2002 Web 18,520,486 261,787,258 (Boldi et al., 2004)
uk-2007-05 Web 105,896,555 3,301,876,564 (Boldi et al., 2004)

Algorithms:

Graph-tool benchmark

Dataset: PGP web of trust network N=39,796 vertices and E=301,498 edges

Algorithms:

ref: https://graph-tool.skewed.de/performance

timlrxx benchmark

Datasets:

Algorithms:

acezen commented 2 years ago

rapidjson::Value vs folly::Dynamic

NUM = 100000000

folly::dynamic

Create Int objects: 5180901483 nanoseconds Read Int objects: 40 nanoseconds Create double objects: 5152739898 nanoseconds Read double objects: 40 nanoseconds Create string objects: 5960905406 nanoseconds Read string objects: 469619201 nanoseconds Create dict objects: 97816101798 nanoseconds Read dict objects: 75542622651 nanoseconds MEM: 58.4g

parseJson and toJson (1M edges) parseJson: 12.5208 s toJson: 2.78841 s

rapidjsonValue

Create Int objects: 4375781716 nanoseconds Read Int objects: 54 nanoseconds Create double objects: 4361932757 nanoseconds Read double objects: 335556902 nanoseconds Create string objects: 5096663566 nanoseconds Read string objects: 67 nanoseconds Create dict objects: 31279850071 nanoseconds Read dict objects: 3407108904 nanoseconds MEM: 65.9g

parseJson and toJson (1M edges) parseJson: 0.197372 s toJson: 0.17069 s

acezen commented 2 years ago

Refactor

traverse

graph DynamicFragment DynamicFragment(MutableCSR) MutableFragment DynamicProjectedFragment
livejournal 10.371 0.010999 0.0105071 0.0104051

pagerank

graph DynamicFragment DynamicFragment(MutableCSR)
twitter 0.112367 0.01387
gnm random(1M, 10M) 0.287429 0.02356
livejounal 1.91776 0.169634
acezen commented 2 years ago

Iterate nodes / edges performance with data caching

iterate nodes

cnt = 0
for n in G.nodes:
    cnt = cnt + 1
graph NetworkX graphscope.nx graphscope.nx without cache
gnm (1M, 10M) 0.06205149s 0.211255s 18.986365s

profiling

I/O asynchronize

cnt = 0
for n in G.nodes:
    for i in range(100):
        cnt = cnt + 1
graph NetworkX graphscope.nx
gnm (1M, 10M) 3.22714s 3.270931s
cnt = 0
for n in G.nodes:
    cnt = cnt + 1
graph NetworkX graphscope.nx
datagen-7_8_zf (16M, 41M) 0.82825s 2.76879s
soc-livejounal(5M, 69M) 0.43554s 0.28923s
cnt = 0
for n in G.nodes:
    for i in range(10):
         cnt = cnt + 1
graph NetworkX graphscope.nx
datagen-7_8_zf (16M, 41M) 7.91136s 9.296s
soc-livejounal(5M, 69M) 2.59347s 2.35384s

iterate edges

cnt = 0
for u in G.adj:
     for v in G.adj[n]:
          cnt = cnt + 1
graph NetworkX graphscope.nx graphscope.nx without cache
gnm (1M, 10M) 4.150698s 12.957603s > 1200s

profiling

I/O asynchronize

graph NetworkX graphscope.nx
gnm (1M, 10M) 4.150698s 8.10182
cnt = 0
for u in G.adj:
     for v in G.adj[n]:
          for i in range(10):
              cnt = cnt + 1
graph NetworkX graphscope.nx
gnm (1M, 10M) 13.50960s 17.04617
cnt = 0
for u in G.adj:
     for v in G.adj[n]:
           cnt = cnt + 1
graph NetworkX graphscope.nx
datagen-7_8_zf (16M, 41M) 26.178357s 45.2949s
soc-livejounal(5M, 69M) 15.71435s 19.19453s