feat: implement SpacetimeDB 2 vs Doublets Rust benchmark#3
Merged
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #2
Adds a complete Rust benchmark suite comparing SpacetimeDB's SQLite backend against Doublets in-memory link stores for 7 basic CRUD operations with links, following best practices from Neo4j and PostgreSQL comparison benchmarks. Benchmark coverage: - Create: create_point() (id == source == target) - Delete: delete by id - Update: update source and target - Query All: retrieve all links - Query by Id: O(1) for Doublets, O(log n) for SQLite - Query by Source: index-based traversal - Query by Target: index-based traversal Backends: - SpacetimeDB Memory (SQLite/WAL in-memory, same engine as SpacetimeDB 2) - Doublets United Volatile (contiguous in-memory) - Doublets Split Volatile (separate data/index regions) Fixes #2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit c3b3d51.
Member
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Member
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the SpacetimeDB 2 vs Doublets benchmark in Rust, following best practices from the Neo4j vs Doublets and PostgreSQL vs Doublets benchmarks.
Fixes #2
What was implemented
Benchmark structure (
rust/)A self-contained Rust benchmark crate in
rust/using criterion 0.3.6 with customiter_customtiming.Backends compared:
SpacetimeDB_MemoryDoublets_United_Volatile(index, source, target)unitsDoublets_Split_VolatileOperations benchmarked (7 total):
create—create_point(): create self-referential link (id == source == target)delete—delete(id): delete links by idupdate—update(id, source, target): update link source and targetquery_all— retrieve all linksquery_by_id— retrieve a single link by idquery_by_source— retrieve all links with a given sourcequery_by_target— retrieve all links with a given targetBenchmark methodology:
BACKGROUND_LINK_COUNT(default: 3000) background links to simulate a realistic database stateiter_custom)BENCHMARK_LINK_COUNT(default: 1000) controls the number of operations per iterationKey files
rust/src/lib.rsLinkstrait (shared interface), constants, module declarationsrust/src/spacetimedb_impl.rsLinksrust/src/doublets_impl.rsLinksrust/src/benched/mod.rsBenchedtrait for benchmark lifecycle (setup/fork/unfork)rust/src/benched/spacetimedb_benched.rsBenchedimpl for SpacetimeDBrust/src/benched/doublets_benched.rsBenchedimpls for Doublets storesrust/src/exclusive.rsExclusive<T>wrapper for interior mutabilityrust/src/fork.rsFork<B>— auto-reset benchmark iteration isolationrust/benches/bench.rsrust/out.py.github/workflows/rust-benchmark.ymlWhy SQLite for SpacetimeDB?
SpacetimeDB 2 uses SQLite as its underlying storage engine for table data. This benchmark measures SpacetimeDB's actual storage layer performance (SQLite + WAL mode + B-tree indexes) for the same link operations that Doublets handles with its custom in-memory data structure.
This establishes the baseline comparison requested in the issue. A full SpacetimeDB module benchmark (via WebSocket reducers) can be added as a follow-up.
Test plan
cargo test --release)cargo fmt --all -- --check)cargo clippy --all-targets)nightly-2022-08-22Running locally
🤖 Generated with Claude Code