we’ve been considering leveldb plugin support for rosbag2. any comments and feedback will be good
Problems
- especially on edge devices, we need light-weight implementation.
- the faster, the better. (most likely throughput for rosbag2 use cases)
Conclusion
- leveldb is light-weight implementation.
-
leveldb can provide better performance than sqlite3 on
read
. -
leveldb with
writer buffer
, it can have betterwrite
performance than sqlite3.
Design Comparison
Category | leveldb | sqlite | Remark |
---|---|---|---|
license | BSD-3-Clause License | Public Domain | |
architecture | in-process library | in-process library | |
storage model | persist (cache available) | persist and in-memery support | leveldb cache |
sql | Non-SQL | SQL Full | |
model | Key-Value Store | Relational DBMS | |
multi-thread | support | support | |
ACID-compliance | ACID-compliance with WriteBatch | ACID-compliance | Also leveldb Synchronous |
compression | snappy | Not supported | |
utilities | Not available | CLI Available | sqlite3 command is available, leveldbutil needs to compile |
footprint | 371KB(libleveldb.so.1.20) | 1.1M(/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6) | Dynamic shared library code size |
Benchmark
Public Performance Comparison
you can refer the the following result from Google. (it is old but worth to take a look)
Internal Performance Test Result
we also checked the performance by our own, compared to sqlite3.
- Raspberry Pi 4 Model B Rev 1.1
Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz, memory 3.7GiB - Ubuntu 20.04.1 and leveldb (commit: 1454924)
- Performance Test Program
- Performance Result Comparison
Sequential Reads
MB/s | 100 | 10K | 100K | 1M | 2M | 4M | 8M |
---|---|---|---|---|---|---|---|
leveldb | 175.5 | 492.4 | 563.0 | 501.8 | 578.1 | 562.6 | 45.8 |
sqlite | 115.9 | 361.3 | 441.1 | 328.8 | 345.2 | 135.9 | 41.8 |
Random Reads
ops/sec | 100 | 10K | 100K | 1M | 2M | 4M | 8M |
---|---|---|---|---|---|---|---|
leveldb | 53333 | 13527 | 1643 | 176 | 129 | 91 | 5 |
sqlite | 54528 | 3785 | 470 | 40 | 21 | 5 | 1 |
Sequential Writes
MB/s | 100 | 10K | 100K | 1M | 2M | 4M | 8M |
---|---|---|---|---|---|---|---|
leveldb | 8.7 | 16.9 | 15.2 | 8.4 | 5.5 | 8.9 | 13.5 |
sqlite | 2.3 | 26.7 | 24.1 | 3.5 | 4.3 | 6.8 | 9.4 |
Random Writes
MB/s | 100 | 10K | 100K | 1M | 2M | 4M | 8M |
---|---|---|---|---|---|---|---|
leveldb | 5.4 | 4.0 | 2.8 | 1.4 | 1.7 | 2.9 | 4.3 |
sqlite | 1.1 | 13.0 | 16.4 | 3.4 | 4.8 | 12.1 | 9.6 |
According to above result, we can see
The read performance (sequential/random read) of leveldb is much better than sqlite3.
For some write cases, sqlite3 has better performance than leveldb.
- Performance Result Comparison with DB cache buffer
Sequential Writes
MB/s | 10K | 100K | 1M |
---|---|---|---|
leveldb (writer buffer: 100M) | 25.9 | 19.4 | 21.9 |
sqlite3 (cache: 100M) | 22.3 | 11.7 | 13.3 |
Random Writes
MB/s | 10K | 100K | 1M |
---|---|---|---|
leveldb (writer buffer: 100M) | 28.1 | 24 | 10.2 |
sqlite3 (cache: 100M) | 14 | 16.2 | 15.1 |
According to above result, we can find
leveldb improves performance with writer buffer
better than sqlite3 obviously.