You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-19Lines changed: 45 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Benchmark comparing [SpacetimeDB 2](https://github.com/clockworklabs/SpacetimeDB) vs [Doublets](https://github.com/linksplatform/doublets-rs) performance for basic CRUD operations with links.
4
4
5
-
SpacetimeDB is benchmarked via its SQLite storage backend (the same engine SpacetimeDB 2 uses internally). Doublets is benchmarked with its in-memory (volatile) storage variants.
5
+
SpacetimeDB is benchmarked using the official `spacetimedb-sdk` Rust crate connected to a running SpacetimeDB 2.0 server. Doublets is benchmarked with both in-memory (volatile) and file-backed (non-volatile) storage variants.
6
6
7
7
## Benchmark Operations
8
8
@@ -18,16 +18,18 @@ SpacetimeDB is benchmarked via its SQLite storage backend (the same engine Space
18
18
19
19
## Backends Benchmarked
20
20
21
-
### SpacetimeDB (SQLite backend)
22
-
-**SpacetimeDB Memory** — in-memory SQLite with B-tree indexes on `id`, `source`, `target`
21
+
### SpacetimeDB
22
+
-**SpacetimeDB** — connects to a running SpacetimeDB 2.0 server via the official `spacetimedb-sdk` Rust crate; uses the `links` table defined in the `spacetime-module` WebAssembly module
23
23
24
-
SpacetimeDB 2 uses SQLite as its underlying data store for persistent tables. This benchmark measures the performance of SpacetimeDB's storage layer (SQLite + WAL mode) for link CRUD operations.
24
+
The benchmark uses the official SpacetimeDB Rust client SDK, calling reducers to mutate data and reading from the client-side subscription cache.
25
25
26
26
### Doublets
27
27
-**Doublets United Volatile** — in-memory store; links stored as contiguous `(index, source, target)` units
28
28
-**Doublets Split Volatile** — in-memory store; separate data and index memory regions
29
+
-**Doublets United NonVolatile** — file-backed store; same contiguous layout but memory-mapped to a single file; data persists to disk
30
+
-**Doublets Split NonVolatile** — file-backed store; separate data and index files; both memory-mapped; data persists to disk
29
31
30
-
Doublets is a custom in-memory doublet link data structure with O(1) lookup by id and O(log n + k) traversal by source/target using balanced tree indexes.
32
+
Doublets uses a recursive-less size-balanced tree for O(1) lookup by id and O(log n + k) traversal by source/target. The file-backed variants use `memmap2` for memory-mapped file I/O, flushing changes to disk on drop via `sync_all()`. See [`rust/doublets-patched/PATCHES.md`](rust/doublets-patched/PATCHES.md) for why a local patched copy is used instead of the published crates.io version.
31
33
32
34
## Benchmark Background
33
35
@@ -44,15 +46,17 @@ Each benchmark iteration pre-populates the database with background links to sim
| Query by Source | O(n) cache scan | O(log n + k) | O(log n + k) |
57
+
| Query by Target | O(n) cache scan | O(log n + k) | O(log n + k) |
58
+
59
+
The algorithmic complexity is the same for volatile and non-volatile Doublets variants. The non-volatile variants have additional I/O overhead due to memory-mapped file writes (flushed to disk on drop).
56
60
57
61
## Related Benchmarks
58
62
@@ -64,18 +68,33 @@ Each benchmark iteration pre-populates the database with background links to sim
64
68
65
69
### Prerequisites
66
70
67
-
- Rust nightly-2022-08-22 (see `rust/rust-toolchain.toml`)
Copy file name to clipboardExpand all lines: changelog.d/20260224_spacetimedb_vs_doublets_benchmark.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,26 @@ bump: minor
4
4
5
5
### Added
6
6
7
-
-**SpacetimeDB 2 vs Doublets benchmark** (`rust/`): New Rust benchmark suite comparing SpacetimeDB's SQLite backend against Doublets in-memory link stores for basic CRUD operations, following best practices from the Neo4j and PostgreSQL comparison benchmarks.
7
+
-**SpacetimeDB 2 vs Doublets benchmark** (`rust/`): New Rust benchmark suite comparing SpacetimeDB 2.0 against Doublets in-memory link stores for basic CRUD operations.
8
8
9
9
-**7 benchmark operations**: Create, Delete, Update, Query All, Query by Id, Query by Source, Query by Target
-**3 backends**: SpacetimeDB 2.0 (via official `spacetimedb-sdk` Rust crate), Doublets United Volatile, Doublets Split Volatile
11
11
-**Configurable scale**: `BENCHMARK_LINK_COUNT` and `BACKGROUND_LINK_COUNT` environment variables
12
12
-**Criterion harness**: Uses criterion 0.3.6 with custom `iter_custom` timing to exclude setup/teardown from measurements
13
13
-**Fork/unfork lifecycle**: Each iteration starts from a clean database state with pre-populated background links
14
14
15
-
-**`rust/src/lib.rs`**: `Links` trait as the shared interface for both SpacetimeDB and Doublets backends; `Benched` trait for benchmark lifecycle management.
15
+
-**`spacetime-module/`**: SpacetimeDB WebAssembly module using the official `spacetimedb` Rust crate, defining the `links` table and CRUD reducers.
16
16
17
-
-**`rust/src/spacetimedb_impl.rs`**: SpacetimeDB SQLite client implementing the `Links` trait using the same schema and indexes that SpacetimeDB 2 uses internally.
17
+
-**`rust/src/module_bindings/`**: Client-side SDK bindings for the links module (equivalent to `spacetime generate --lang rust` output).
18
+
19
+
-**`rust/src/spacetimedb_impl.rs`**: SpacetimeDB 2.0 implementation using the official `spacetimedb-sdk` Rust crate. Connects to a running SpacetimeDB server, subscribes to the links table, and calls reducers for CRUD operations.
18
20
19
21
-**`rust/src/doublets_impl.rs`**: Doublets store adapters implementing the `Links` trait for both United Volatile and Split Volatile storage layouts.
20
22
21
23
-**`rust/benches/bench.rs`**: Criterion benchmark suite with 21 benchmark functions (7 operations × 3 backends).
22
24
23
25
-**`rust/out.py`**: Python script for generating comparison charts (linear and log scale PNG) and a Markdown results table from benchmark output.
24
26
25
-
-**`.github/workflows/rust-benchmark.yml`**: GitHub Actions CI workflow that runs tests on Ubuntu/macOS/Windows and generates benchmark charts on push to main.
27
+
-**`.github/workflows/rust-benchmark.yml`**: GitHub Actions CI workflow that installs the SpacetimeDB CLI, starts a local server, publishes the module, runs tests on Ubuntu/macOS/Windows, and generates benchmark charts on push to main.
26
28
27
29
-**Updated `README.md`**: Benchmark description, operation complexity table, and usage instructions.
0 commit comments