Benchmarking graph traversal performance on persistent storage against NetworkX, evaluating random access patterns on Patent Citations, Gene Regulatory Networks, and Human Brain connectomes.
By
Ash Vardanian
Published
Nov 12, 2020
At Unum, we develop a neuro-symbolic AI, which means combining discrete structural representations of data and semi-continuous neural representations.
Think of it as building a huge Knowledge Graphs.
Such graphs have an extremely irregular structure, which makes data access patterns very unpredictable.
Sounds like an ultimate workload for a serious DBMS benchmark.
All benchmarks ran on an Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz with 8 cores (16 threads @ 2.3 GHz), 16.0 GB of RAM and 931.5 GB of disk space, under Darwin and Python 3.7.7.
Databases were configured to use 512 MB of RAM for cache and 4 cores for query execution.
But before comparing DBs, let’s see what our SSD is capable of by simply parsing the list (2 or 3 columns CSV).
This will be our baseline for estimating the time required to build the indexes in each DB.
PatentCitations
MouseGenes
HumanBrain
Gains
Parsing in Python
276,762.85
269,444.25
242,972.78
1x
Sampling in Unum
4,025,752.40
3,932,870.14
3,449,392.42
14.45x
Most DBs provide some form of functionality for faster bulk imports, but not all of them were used in benchmarks for various reasons.
Neo4J supports CSV imports, but was excluded from the benchmarks — its JVM-based stack is prohibitively slow, doesn’t scale to these graph sizes, and repeatedly crashes with out-of-memory errors on the larger datasets.
Postgres and MySQL dialects of SQL have special functions for importing CSVs, but their functionality is very limited and performance gains aren’t substantial. A better approach is to use unindexed table of incoming edges and later submit it into the main store once the data is absorbed. That’s how we implemented it.
MongoDB provides a command-line tool, but it wasn’t used to limit the number of binary dependencies and simplify configuration.
PatentCitations
MouseGenes
HumanBrain
Gains
Postgres
5,902.69
6,812.14
6,700.64
1x
MySQL
11,889.85
16,095.21
10,807.24
2.00x
SQLite
32,854.49
42,350.66
25,289.73
5.19x
MongoDB
32,917.56
39,077.58
29,843.12
5.26x
UDisk
253,298.95
1,056,780.56
819,382.93
106.78x
The benchmarks were repeated dozens of times.
These numbers translate into following import duration for each dataset.
PatentCitations
MouseGenes
HumanBrain
Postgres
46 mins, 39 secs
35 mins, 29 secs
3 hours, 37 mins
MySQL
23 mins, 9 secs
15 mins, 1 secs
2 hours, 14 mins
SQLite
8 mins, 23 secs
5 mins, 43 secs
57 mins, 31 secs
MongoDB
8 mins, 22 secs
6 mins, 11 secs
48 mins, 44 secs
UDisk
1 mins, 5 secs
0 mins, 14 secs
1 mins, 47 secs
Those benchmarks only tell half of the story.
SSDs have a relatively short lifespan, especially new high-capacity technologies like TLC and QLC.
Most DBs don’t have high-performance bulk I/O options.
It means, that when you import the data there is no way to inform the DB about various properties of the imported dataset.
Which in turn results in huge write-amplification.
Combine this with inefficient and slow built-in compression and prepare to give all your money to AWS!
PatentCitations
Postgres63GB
MySQL140GB
SQLite16GB
MongoDB6.3GB
UDisk1.2GB
MouseGenes
Postgres44GB
MySQL69GB
SQLite8GB
MongoDB3.1GB
UDisk0.8GB
HumanBrain
Postgres340GB
MySQL560GB
SQLite97GB
MongoDB38GB
UDisk5.3GB
Import overhead: total bytes written while importing each dataset.
Once the data is imported, it’s on-disk representation has different layouts in each DB.
Some are more compact than others. For comparison, let’s take the HumanBrain 4 GB graph.
According to the chart above, a total of 5.3 GB was written during the import.
However, thanks to our compression, the resulting DB size is only 0.8 GB.
The same graph uses ~3.5 GB in MongoDB, ~15 GB in MySQL, ~15 GB in Postgres, and ~15 GB in SQLite.
Following are simple lookup operations.
Their speed translates into the execution time of analytical queries like:
Shortest Path Calculation,
Clustering Analysis,
Pattern Matching.
As we are running on a local machine and within the same filesystem,
the networking bandwidth and latency between server and client applications
can’t be a bottleneck.
We don’t benchmark edge insertions as those operations are uncommon in graph workloads.
Instead of that we benchmark upserts = inserts or updates.
Batch operations have different sizes for different DBs depending on memory consumption
and other limitations of each DB.
Concurrency is tested only in systems that explicitly support it.