Blog IO

Networks Processing Performance Report

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.

Reproduce Our Results

§ Setup

DatasetSizeEdgesAverage Degree
Patent Citation Network272 MB16,518,9478
Mouse Gene Regulatory Network295 MB14,506,199670
Human Brain Network4 GB87,273,967186

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.

§ Results

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.

PatentCitationsMouseGenesHumanBrainGains
Parsing in Python276,762.85269,444.25242,972.781x
Sampling in Unum4,025,752.403,932,870.143,449,392.4214.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.
PatentCitationsMouseGenesHumanBrainGains
Postgres5,902.696,812.146,700.641x
MySQL11,889.8516,095.2110,807.242.00x
SQLite32,854.4942,350.6625,289.735.19x
MongoDB32,917.5639,077.5829,843.125.26x
UDisk253,298.951,056,780.56819,382.93106.78x

The benchmarks were repeated dozens of times. These numbers translate into following import duration for each dataset.

PatentCitationsMouseGenesHumanBrain
Postgres46 mins, 39 secs35 mins, 29 secs3 hours, 37 mins
MySQL23 mins, 9 secs15 mins, 1 secs2 hours, 14 mins
SQLite8 mins, 23 secs5 mins, 43 secs57 mins, 31 secs
MongoDB8 mins, 22 secs6 mins, 11 secs48 mins, 44 secs
UDisk1 mins, 5 secs0 mins, 14 secs1 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
Postgres 63 GB
MySQL 140 GB
SQLite 16 GB
MongoDB 6.3 GB
UDisk 1.2 GB
MouseGenes
Postgres 44 GB
MySQL 69 GB
SQLite 8 GB
MongoDB 3.1 GB
UDisk 0.8 GB
HumanBrain
Postgres 340 GB
MySQL 560 GB
SQLite 97 GB
MongoDB 38 GB
UDisk 5.3 GB
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.

§ Read Queries

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.

§ Random Reads: Find Specific Edge

  • Input: 2 vertex identifiers (order is important).
  • Output: edge that connects them in a given direction.
  • Metric: number of queries per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres530.98210.12333.011x
MySQL588.10463.66460.771.57x
SQLite501.45336.2020.130.87x
MongoDB615.85101.4457.600.61x
UDisk21,447.6568,585.2037,048.96159.35x

§ Random Reads: Find Connected Edges

  • Input: 1 vertex identifier.
  • Output: all edges attached to it.
  • Metric: number of queries per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres280.667.5420.551x
MySQL411.9633.0381.643.27x
SQLite237.1112.4024.551.23x
MongoDB642.8348.7350.033.73x
UDisk33,426.608,809.7716,543.26697.31x

§ Random Reads: Find Ingoing Edges

  • Input: 1 vertex identifier.
  • Output: all edges incoming into it.
  • Metric: number of queries per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres303.7661.2017.721x
MySQL522.4371.84128.353.38x
SQLite249.5173.3027.431.19x
MongoDB987.99170.6361.513.17x
UDisk33,748.7811,677.9020,017.27477.19x

§ Random Reads: Find Friends

  • Input: 1 vertex identifier.
  • Output: the identifiers of all unique vertexes that share an edge with the input.
  • Metric: number of queries per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres312.7111.3321.651x
MySQL427.0232.5377.542.61x
SQLite238.2423.1424.691.31x
MongoDB790.2951.5750.883.14x
UDisk45,616.0010,306.8221,258.48679.06x

§ Random Reads: Count Friends

  • Input: 1 vertex identifier.
  • Output: the total number of attached edges and their accumulated weight.
  • Metric: number of queries per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres333.8069.3827.221x
MySQL453.037.9445.581.05x
SQLite276.89166.3432.691.48x
MongoDB972.77107.4766.582.30x
UDisk37,335.198,770.0817,737.67296.66x

§ Random Reads: Count Followers

  • Input: 1 vertex identifier.
  • Output: the total number of incoming edges and their accumulated weight.
  • Metric: number of queries per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres384.53523.7628.281x
MySQL600.77134.06211.053.09x
SQLite295.23364.0634.200.89x
MongoDB1,451.90547.8581.042.56x
UDisk41,296.4211,964.8221,197.98293.25x
Find Specific Edge
Postgres 530 MB
MySQL 620 MB
SQLite 1,600 MB
MongoDB 300 MB
UDisk 51 MB
Find Connected Edges
Postgres 2,500 MB
MySQL 450 MB
SQLite 1,200 MB
MongoDB 570 MB
UDisk 29 MB
Find Ingoing Edges
Postgres 2,000 MB
MySQL 490 MB
SQLite 1,400 MB
MongoDB 460 MB
UDisk 29 MB
Find Friends
Postgres 2,300 MB
MySQL 480 MB
SQLite 1,200 MB
MongoDB 270 MB
UDisk 32 MB
Read amplification: bytes read from disk in each random-read benchmark.

§ Write Operations

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.

§ Random Writes: Upsert Edge

  • Input: 1 new edge.
  • Output: success/failure indicator.
  • Metric: number inserted edges per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres398.77447.46394.251x
MySQL295.08382.02262.420.75x
SQLite443.18390.89333.930.94x
MongoDB2,014.472,310.431,474.334.65x
UDisk6,746.846,025.575,589.3214.85x

§ Random Writes: Upsert Edges Batch

  • Input: 500 new edges.
  • Output: 500 success/failure indicators.
  • Metric: number inserted edges per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres1,922.622,088.482,503.271x
MySQL2,269.232,213.562,261.521.05x
SQLite3,758.683,317.963,626.231.66x
MongoDB5,211.364,634.203,440.202.10x
UDisk28,673.7520,244.7118,075.7310.61x

§ Random Writes: Remove Edge

  • Input: 1 existing edge.
  • Output: success/failure indicator.
  • Metric: number removed edges per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres845.35964.71679.981x
MySQL582.90709.48714.840.83x
SQLite358.19401.46303.400.43x
MongoDB688.57863.73481.640.81x
UDisk5,832.345,885.345,500.317.03x

§ Random Writes: Remove Edges Batch

  • Input: 500 existing edges.
  • Output: 500 success/failure indicators.
  • Metric: number removed edges per second.
PatentCitationsMouseGenesHumanBrainGains
Postgres1,188.461,343.771,126.291x
MySQL577.58608.91560.440.48x
SQLite581.98594.95605.300.49x
MongoDB8,792.928,393.005,165.726.08x
UDisk28,980.2020,700.4619,079.6118.91x
Upsert Edge
Postgres 670 MB
MySQL 6,600 MB
SQLite 610 MB
MongoDB 17 MB
UDisk 60 MB
Upsert Edges Batch
Postgres 63 MB
MySQL 1,700 MB
SQLite 260 MB
MongoDB 4.8 MB
UDisk 31 MB
Remove Edge
Postgres 180 MB
MySQL 2,000 MB
SQLite 610 MB
MongoDB 270 MB
UDisk 59 MB
Remove Edges Batch
Postgres 240 MB
MySQL 4,700 MB
SQLite 600 MB
MongoDB 2.6 MB
UDisk 21 MB
Write amplification: bytes written to disk in each random-write benchmark.