MCPcopy Create free account
hub / github.com/LayerZero-Labs/qmdb

github.com/LayerZero-Labs/qmdb @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,559 symbols 5,805 edges 127 files ⚖ MIT 505 documented · 32% ● updated 30d ago★ 32911 open issues

Browse by type

⨍ Functions 1,374◇ Types & classes 185
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

QMDB: Breaking the DRAM Barrier in Authenticated Data Structures — PVLDB Artifact

License: MIT PVLDB Vol. 20

This repository is the artifact of the PVLDB paper QMDB: Breaking the DRAM Barrier in Authenticated Data Structures (Sijie Cui, Ziyue Qiu, Isaac Zhang, Ryan Zarick, Daniel Wong, Thomas Kim, Mignon Li, Kelvin Wong, George Amvrosiadis; Carnegie Mellon University and LayerZero Labs).

[!WARNING] This repository exists only to reproduce the paper's results. It is not for production use. To keep the measurements reproducible, the code and its dependencies, including the vendored baselines, are pinned to the exact versions used in the evaluation. Some of these versions have known critical vulnerabilities. We keep them on purpose and will not update or patch them here, because changing them would change what the paper measured. Security findings against these pinned versions will not be addressed in this repository.

It contains: - speed, a benchmark driver that runs QMDB and the three baselines (NOMT, LVMT, Reth) through one shared workload generator, so all systems see the same operations; it also replays the Ethereum mainnet trace (bench/), - the QMDB engine used in the paper's evaluation (crates/); the production implementation is maintained at LayerZero-Labs/qmdb, and Section 8.2 lists every difference between that code and the copy here, - the baselines at the exact upstream commits we measured: NOMT and Reth vendored, NOMT with one documented patch, and LVMT as an unmodified git submodule (nomt/, reth/, lvmt/).

Paper: Proceedings of the VLDB Endowment, Vol. 20, 2027.


Contents

  1. Repository layout
  2. Requirements
  3. Setup and build
  4. Kick the tires
  5. Workloads and datasets
  6. Reproducing the paper's results
  7. Output and metrics
  8. Differences from upstream
  9. Extending the harness
  10. Troubleshooting
  11. License and citation

1. Repository layout

.
├── crates/                  QMDB engine (Cargo workspace members)
│   ├── qmdb/                Merkle tree (twigs), indexers, entry files, prefetcher, updater, flusher, compactor
│   ├── qmdb-common/         shared types, change sets, compile-time constants (src/def.rs)
│   └── hpfile/              head-prunable files that back the entry and twig logs
├── bench/                   benchmark driver `speed` and one adapter per backend
│   ├── src/bin/speed.rs     populate -> CRUD "hover" phases -> optional Ethereum replay
│   ├── src/cli.rs           every command-line flag
│   ├── src/speed/           qmdb.rs, nomt_adapter.rs, lvmt_adapter.rs, reth_adapter.rs, eth_replay.rs, generators, metrics
│   └── Cargo.toml.{lvmt,reth}, Cargo.lock.{lvmt,reth}, switch_backend.sh   manifest switch between the LVMT and Reth builds (Section 3.4)
├── nomt/  reth/             vendored baselines (upstream commits and the NOMT patch in Section 8.1)
└── lvmt/                    git submodule: upstream LVMT, unmodified

2. Requirements

Hardware

We recommend the machine used in the paper, AWS c7gd.metal: - CPU: 64-core Graviton3 at 2.6 GHz - Memory: 128 GiB DDR5 - Storage: 2 × 1.7 TiB local NVMe in RAID-0, ext4 - OS: Ubuntu 24.04, Linux 6.17 (io_uring and cgroup v2)

Software

  • Rust 1.94.0, pinned by rust-toolchain.toml (rustup installs it on first build).
  • A C/C++ toolchain for the native dependencies (RocksDB in LVMT, MDBX in Reth, jemalloc): GCC/G++ ≥ 13, clang, cmake, pkg-config.
  • sudo (memory caps through systemd-run, dropping the page cache), systemd with cgroup v2.
  • git with submodule support, mdadm for the RAID-0 array, and python3-venv for the Hugging Face CLI that downloads the Ethereum dataset.
sudo apt-get update
sudo apt-get install -y build-essential clang libclang-dev cmake pkg-config git mdadm python3-venv
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

3. Setup and build

3.1 Source

LVMT is a git submodule, so clone recursively (or run git submodule update --init in an existing clone):

git clone --recursive https://github.com/LayerZero-Labs/qmdb.git
cd qmdb

3.2 Storage

These commands set up the two local NVMe drives of c7gd.metal (/dev/nvme1n1, /dev/nvme2n1) as a RAID-0 array mounted at /mnt/ssd.

sudo mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/nvme1n1 /dev/nvme2n1
sudo mkfs.ext4 -F /dev/md0
sudo mkdir -p /mnt/ssd && sudo mount /dev/md0 /mnt/ssd && sudo chown "$USER" /mnt/ssd

3.3 Workload seed

The synthetic workload is generated deterministically from a file of random bytes. Use the same file for every system so that all of them see the same key stream.

head -c 10M </dev/urandom > /mnt/ssd/randsrc.dat

3.4 Building the backends

The backend is selected at compile time by a Cargo feature; without a feature, speed runs QMDB. LVMT and Reth link incompatible versions of zstd-sys, so bench/switch_backend.sh swaps bench/Cargo.toml and the workspace Cargo.lock between two variants before building (details in bench/BACKEND_SWITCH.md). Every build writes target/release/speed at the repository root, so copy each binary out.

mkdir -p ~/bin
cd bench
# QMDB, NOMT and LVMT build with the LVMT manifest
./switch_backend.sh lvmt && cargo build --release --bin speed && cp ../target/release/speed ~/bin/speed_qmdb
cargo build --release --bin speed --features qmdb/use_hybridindexer && cp ../target/release/speed ~/bin/speed_qmdb_hybrid
cargo build --release --bin speed --features qmdb/pipeline_off && cp ../target/release/speed ~/bin/speed_qmdb_pipeoff
cargo build --release --bin speed --features use_nomt && cp ../target/release/speed ~/bin/speed_nomt
# RocksDB in LVMT needs these flags with GCC >= 13
CXXFLAGS="-fpermissive -std=c++17 -include cstdint" \
  cargo build --release --bin speed --features use_lvmt && cp ../target/release/speed ~/bin/speed_lvmt
# Reth needs its own manifest; switch back afterwards
./switch_backend.sh reth && cargo build --release --bin speed --features use_reth && cp ../target/release/speed ~/bin/speed_reth
./switch_backend.sh lvmt
cd ..

4. Kick the tires

These runs exercise every backend end to end on a small state (1 million entries). Run them from bench/, because the LVMT adapter keeps its public parameters in ../lvmt/pp; LVMT generates them on its first run.

# QMDB keeps more files open than the default limit of 1,024
ulimit -n 65535
ARGS="--ops-per-block 100000 --rayon-threads 16 --randsrc-filename /mnt/ssd/randsrc.dat"
# NOMT preallocates 4 KiB of SSD per bucket: 16 GB here
export NOMT_BUCKETS=4000000
# One run per backend: 1M entries, then 2-block Update, Read, Insert and Delete phases
for b in qmdb nomt lvmt reth; do
  mkdir -p /mnt/ssd/${b}_smoke
  ~/bin/speed_$b --db-dir /mnt/ssd/${b}_smoke --entry-count 1000000 --hover-interval 5 --hover-write-block 2 --hover-recreate-block 2 $ARGS
done

Each run ends with the phase reports and a results summary. The QMDB run prints, for example (numbers will differ):

Hover Test updates (200000 ops, 2 blocks, stride=random)...updates@1000000 entries: 200000 in 0.26s (781397.95/s), total: 400000 in 0.50s (806517.80/s)
...
TEST_REPORT: Phase=updates | Ops=200000
  > Total KV Size (Pure)  = 10400000 bytes (9.92 MB)
  [OS-level Disk IO]
  > OS Physical Write = 25120768 bytes (23.96 MB)
  > OS Physical Read  = 253952 bytes (0.24 MB)
...
MEM(entries=1000000) Memory usage: physical=0.93GB virtual=10.53GB; physical/entry=996.09bytes
SSD(entries=1000000) Usage: 0.33GB, 352.18bytes/entry
...
Results summary
    entry_count: 1000000
    db_backend: QMDB
    ...
    deletes: 766338.719/s
    inserts: 772736.210/s
    reads: 871625.182/s
    updates: 781397.947/s

A run is healthy if it prints TEST_REPORT lines for updates, reads, inserts and deletes and no panicked message. Delete the smoke databases afterwards: rm -rf /mnt/ssd/*_smoke.


5. Workloads and datasets

5.1 Synthetic CRUD workload

speed first populates the database block by block. Every --hover-interval blocks it pauses population and runs hover phases that time Update and Read throughput; after population a final hover also times Insert and Delete.

Flag Meaning Default
--entry-count entries to populate; must be a multiple of --ops-per-block 500,000,000
--ops-per-block operations per block 100,000
--hover-interval blocks of population between hovers 10,000
--hover-write-block blocks in each Update and Read phase 50 (5M operations)
--hover-recreate-block blocks in each Insert and Delete phase 50 (5M operations)
--hover-zipf-theta key distribution: 0 is uniform, 0.99 is YCSB-style skew, above 1 is extreme skew; not exactly 1.0 0
--randsrc-filename file of random bytes from which all workload randomness is drawn ./randsrc.dat

All flags are documented in bench/src/cli.rs.

5.2 Ethereum mainnet replay

The replay uses the state operations of Ethereum mainnet blocks 15,012,300 – 15,312,299 (2022-06-23 to 2022-08-10): 1,002,507,459 state operations, 60.2% of them Reads. Each block's operations are stored as {height}_operation_kv.bin (bincode). The initial state at block 15,012,300 is packed into an InitDbBundle that speed streams in before the replay starts.

The dataset is hosted on Hugging Face at usiie/qmdb-eth-replay:

File Size SHA-256 Contents
traces_op_300k.tar 77,031,680,000 bytes cfd54b95900d9847856e23a9dbf7f77cf904eb0a2791e6ea55da1b4ac4243f94 265,397 per-block {height}_operation_kv.bin files (73 GiB)
init_db_bundle_15012300_20407400.bin 99,862,323,012 bytes a31560b3353fdd9e94e9576bba3feaa5e6fcb98576abcebac2ff1e0553de92a3 InitDbBundle, 63,830,024 initial entries

Download, verify and extract (≈ 260 GB of disk at the peak; hf comes with the huggingface_hub Python package, which on Ubuntu 24.04 goes into a virtual environment):

python3 -m venv ~/hfenv && ~/hfenv/bin/pip install -U huggingface_hub
~/hfenv/bin/hf download usiie/qmdb-eth-replay --repo-type dataset --local-dir /mnt/ssd/init_db_output
cd /mnt/ssd/init_db_output && sha256sum -c SHA256SUMS
mkdir -p /mnt/ssd/real_eth_workload/kv_decompressed
tar xf traces_op_300k.tar -C /mnt/ssd/real_eth_workload/kv_decompressed && rm traces_op_300k.tar

The commands in Section 6.3 expect these two paths.


6. Reproducing the paper's results

6.1 Measurement protocol

  • Machine: c7gd.metal; the RAID-0 array mounted at /mnt/ssd. The Ethereum replay also runs on c6id.16xlarge and r6gd.2xlarge (Section 6.3).
  • Memory: a 32 GiB cgroup-v2 cap (MemoryMax=32G, MemoryHigh=32G) that limits allocations and the page cache: sudo systemd-run --scope -p MemoryMax=32G -p MemoryHigh=32G .... The Ethereum replay sets the cap only after the initial state is loaded (Section 6.3).
  • CPUs: all 64 cores (the commands below pin them with taskset -c 0-63; Section 6.3 lists the CPU sets of the other two instances). File descriptors: ≥ 65,535 (1,048,576 for NOMT in Section 6.2), set with prlimit inside the scope.
  • Before each run: delete the database directory and drop the page cache: rm -rf /mnt/ssd/<db> && sync && echo 3 | sudo tee /proc/sys/vm/drop_caches.

6.2 Database-size sweep (Fig. 5 and Fig. 8)

Uniform CRUD at 100M, 300M, 600M, 900M, 1.2B and 1.5B entries, 32 GiB cap. Fig. 8 uses the memory, SSD and CPU lines printed by the same runs.

System Settings
QMDB 16 shards and compaction threshold 0.7 (source defaults SHARD_COUNT = 16 and UTILIZATION_RATIO = 7 in crates/qmdb-common/src/def.rs); --rayon-threads 128
NOMT page cache 16 GiB, leaf cache 10 GiB, commit concurrency 8, 32 IO workers, 2 upper levels prepopulated; buckets 39,073,369 (100M), 93,329,983 (300M), 248,354,236 (600M), 575,546,222 (≥ 900M); --rayon-threads 64
LVMT RocksDB memory budget 2 GiB, 16 shards
Reth default MDBX settings; 100M–600M only

QMDB (from bench/):

for n in 100000000 300000000 600000000 900000000 1200000000 1500000000; do
  rm -rf /mnt/ssd/QMDB && sync && echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
  sudo systemd-run --scope -p MemoryMax=32G -p MemoryHigh=32G \
    prlimit --nofile=65535:65535 taskset -c 0-63 \
    ~/bin/speed_qmdb --db-dir /mnt/ssd/QMDB --entry-count $n --ops-per-block 100000 \
      --hover-write-block 500 --hover-recreate-block 500 --hover-interval 30000 \
      --rayon-threads 128 --randsrc-filename /mnt/ssd/randsrc.dat \
    2>&1 | tee qmdb_${n}.log
done

Baselines (from bench/; example: NOMT at 1.5B; replace the binary for LVMT and Reth):

rm -rf /mnt/ssd/NOMT && sync && echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
sudo systemd-run --scope -p MemoryMax=32G -p MemoryHigh=32G \
  env NOMT_BUCKETS=575546222 prlimit --nofile=1048576:1048576 taskset -c 0-63 \
  ~/bin/speed_nomt --db-dir /mnt/ssd/NOMT --entry-count 1500000000 --ops-per-block 100000 \
    --hover-write-block 500 --hover-recreate-block 500 --hover-interval 30000 \
    --rayon-threads 64 --randsrc-filename /mnt/ssd/randsrc.dat \
  2>&1 | tee nomt_1500M.log

NOMT reads its bucket count from NOMT_BUCKETS (values in the table above; the default is 575,546,222) and preallocates 4 KiB of SSD per bucke

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 914
Function 460
Class 165
Enum 11
Interface 9

Languages

Rust100%
Python1%

Modules by API surface

crates/qmdb/src/merkletree/tree.rs57 symbols
crates/qmdb/src/updater.rs55 symbols
crates/qmdb/src/prefetcher/dioprefetcher.rs47 symbols
crates/qmdb/src/metadb.rs40 symbols
crates/hpfile/src/file_slots.rs40 symbols
crates/qmdb/src/lib.rs39 symbols
crates/qmdb-common/src/entryfile/entry.rs39 symbols
crates/qmdb/src/indexer/memidx.rs36 symbols
crates/hpfile/src/aligned_buf.rs36 symbols
crates/qmdb/src/indexer/hybrid/mod.rs34 symbols
crates/qmdb/src/entryfile/uring_reader.rs30 symbols
crates/qmdb/examples/v1_refdbfuzz/refdb.rs30 symbols

For agents

$ claude mcp add qmdb \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page